akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <malloc.h>
#include<stack>
#include<stdio.h>
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#include<stack>
using namespace std;
  int a[10000];
  char s[100002];
int main()
{
     memset(a,0,sizeof(a));
   scanf("%s",s);
     int len=strlen(s);
     for(int i=0;i<len;i++)
     {
         if(s[i]=='a')
            a[0]++;
         else if(s[i]=='b')
            a[1]++;
         else
            a[2]++;
     }
     sort(a,a+3);
   //  cout<<a[0]<<a[1]<<a[2]<<endl;
     if(a[2]-a[0]>=2)
        printf("NO\n");
     else
        printf("YES\n");

    return 0;
}


Measured memory_bytes: 384
n = int(input())
up = list(map(int,input().split()))
dw = list(map(int,input().split()))
ans = up[0]+sum(dw)
tmp = up[0]+sum(dw)
for i in range(1,n):
  tmp = tmp+up[i]-dw[i-1]
  ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 9188
import sys
import math
from collections import deque
import copy
input = sys.stdin.readline
INF = float("inf")
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    tempW, tempV = map(int, input().split())
    weight.append(tempW)
    value.append(tempV)

dp = [[INF for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for l in range(N * 1000 + 1):
        if l - value[i - 1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - value[i - 1]] + weight[i - 1])
        else:
            dp[i][l] = dp[i - 1][l]
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)


Measured memory_bytes: 320208
N = int(input())
b = list(map(int,input().split()))

ans = []
while(True):
    if len(b) == 0:
        ans.reverse()
        print(*ans,sep="\n")
        break
    for i in range(len(b)-1,-1,-1):
        if b[i] == i+1:
            ans.append(b.pop(i))
            break
    else:
        print(-1)
        break

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
    string s;
    int a = 0;
    int b = 0;
    int c = 0;

    cin >> s;
    for(int i = 0;i < 3;i++){
        if(s[i] == 'a') a++;
        if(s[i] == 'b') b++;
        if(s[i] == 'c') c++;
    }
    if(a && b && c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	long long DP[100][21]={0};
	int N,E[100];
	cin >> N;
	for (int i=0;i<N;i++){
		cin >> E[i];
	}
	DP[0][E[0]]=1;
	for (int i=1;i<N-1;i++){
		for(int j=0;j<=20;j++){
			if(j-E[i]<=20 && j-E[i]>=0)
		DP[i][j]+=DP[i-1][j-E[i]];
			if(j+E[i]<=20 && j+E[i]>=0)
		DP[i][j]+=DP[i-1][j+E[i]];
		}
		}
	cout << DP[N-2][E[N-1]]<< endl;
	return 0;
}

Measured memory_bytes: 1180
h, w = gets.split.map(&:to_i)
strs = (1..h).map { |i| gets.chomp }

def get_new_str(strs, i)
  new_str = ''
  strs[i].each_char.with_index do |s, j|
    if s == '#'
      new_str << s
    else
      new_str << get_bomb_count(strs, i, j).to_s
    end
  end
  new_str
end

class NilClass
  def [](i)
    nil
  end
end

def get_bomb_count(strs, i, j)
  dxs = [1,1, 1,0, 0,-1,-1,-1]
  dys = [0,1,-1,1,-1, 0, 1,-1]
  cnt = 0
  dxs.each_with_index do |dx, k|
    dy = dys[k]
    x = i + dx; y = j + dy
    if x >= 0  && y >= 0 && strs[x][y] == '#'
      cnt += 1
    end
  end
  cnt
end

ans = []
strs.each_with_index do |str, i|
  a = get_new_str(strs, i)
  ans << a
end
puts ans

Measured memory_bytes: 3836
using System;

namespace abc100_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int people = 2;
            string[] array = Console.ReadLine().Split(' ');
            int red = int.Parse(array[0]);
            int blue = int.Parse(array[1]);
            int ave = 16 / people;
            if (ave < red || ave < blue)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	K := sc.nextInt()
	count := 0
	queue := &Queue{}
	bfs := func(n int) bool {
		s := strconv.Itoa(n)
		last, _ := strconv.Atoi(string(s[len(s)-1]))
		for i := max(last-1, 0); i <= min(last+1, 9); i++ {
			count++
			next := n*10 + i
			if count == K {
				fmt.Fprintln(wtr, next)
				return true
			}
			queue.push(Node{next})
		}
		return false
	}
	for i := 1; i < 10; i++ {
		count++
		if count == K {
			fmt.Fprintln(wtr, i)
			return
		}
		queue.push(Node{i})
	}
	for !queue.isEmpty() {
		if bfs(queue.pop().num) {
			return
		}
	}
}

type Node struct {
	num int
}

type Queue struct {
	arr []Node
}

func (q *Queue) push(v Node) {
	q.arr = append(q.arr, v)
}

func (q *Queue) pop() Node {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}


Measured memory_bytes: 5376
n=int(input())
s=[]
for _ in range(n):
  s.append(int(input()))
s.sort()
ans=sum(s)
if ans%10!=0:
  print(ans)
else:
  l=[x for x in s if x%10!=0]
  if len(l)==0:
    print(0)
  else:
    print(ans-l[0])

Measured memory_bytes: 3060
fun main(args: Array<String>) {
	val (a, b) = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
	when {
		a == b -> println(a + b)
		a > b -> println(2 * a - 1)
		else -> println(2 * b - 1)
	}
}

Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ans = false;
  
  if(abs(a-c)<=d) ans = true;
  else if(abs(a-b)<=d && abs(c-b)<=d) ans = true;
  
  if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD (int)(1e9 + 7)

int main()
{
    int h, w;
    cin >> h >> w;
    int grid[h][w];
    for (int q = 0; q < h; q++)
    {
        string s;
        cin >> s;
        for (int e = 0; e < w; e++)
        {
            if (q==0)
            {
                if (e==0)
                {
                    grid[q][e]=1;
                }
                else
                {
                    if (s[e]=='#')
                    {
                        grid[q][e]=0;
                    }
                    else
                    {
                        grid[q][e]=grid[q][e-1];
                    }
                }
            }
            else
            {
                if (e==0)
                {
                    if (s[e]=='#')
                    {
                        grid[q][e]=0;
                    }
                    else
                    {
                        grid[q][e]=grid[q-1][e];
                    }
                }
                else
                {
                    if (s[e]== '#')
                    {
                        grid[q][e]=0;
                    }
                    else
                    {
                        grid[q][e]=(grid[q-1][e]+grid[q][e-1]) % MOD;
                    }
                }
            }
        //cout << grid[q][e] << " ";
        }
        //cout << endl;
    }
    cout << grid[h-1][w-1];
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 100000

vector<int> G[MAX];
int p[MAX];
using P = pair<pair<int, int>, int>;
P dp[MAX];

P dfs(int cur, int pre) {
    int mn = (p[cur] != -1 ? p[cur] : -INF), mx = (p[cur] != -1 ? p[cur] : INF),
        parity = (p[cur] != -1 ? p[cur] % 2 : -1);
    for (int to : G[cur]) {
        if (to == pre) continue;
        auto pp = dfs(to, cur);
        mn = max(mn, pp.first.first - 1);
        mx = min(mx, pp.first.second + 1);
        if (mx < mn) {
            cout << "No" << endl;
            exit(0);
        }
        if (parity != -1 && parity == pp.second) {
            cout << "No" << endl;
            exit(0);
        }
        if (pp.second != -1) parity = !pp.second;
    }
    return dp[cur] = P(pair<int, int>(mn, mx), parity);
}

int ans[MAX];

void dfss(int cur, int pre) {
    if (pre != -1) {
        if (dp[cur].first.first <= ans[pre] - 1 &&
            ans[pre] - 1 <= dp[cur].first.second) {
            ans[cur] = ans[pre] - 1;
        } else {
            ans[cur] = ans[pre] + 1;
        }
    }
    for (int to : G[cur]) {
        if (to == pre) continue;
        dfss(to, cur);
    }
}

signed main() {
    int n;
    cin >> n;
    int a, b;
    rep(i, n - 1) {
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int k;
    cin >> k;
    fill(p, p + n, -1);
    int v, P;
    rep(i, k) {
        cin >> v >> P;
        v--;
        p[v] = P;
    }
    dfs(0, -1);
    ans[0] = dp[0].first.first;
    dfss(0, -1);
    cout << "Yes" << endl;
    rep(v, n) {
        cout << ans[v] << endl;
    }
    return 0;
}

Measured memory_bytes: 21924
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      	Scanner sc = new Scanner(System.in);
      	int N1 = sc.nextInt();
      	int N2 = sc.nextInt();      
        System.out.println(Math.max(N1+N2,Math.max(N1-N2,N1*N2)));
    }
}


Measured memory_bytes: 21844
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
constexpr ll INF = 1ll << 60;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N + 2, 0);
    rep(i, N)cin >> H[i + 1];

    vector<vector<ll>> dp(K + 1, vector<ll>(N + 2, INF));
    dp[0][0] = 0;
    rep(k, K + 1)rep(i, N + 2) rep(alpha, K + 1) {
        ll to1 = k + alpha;
        ll to2 = i + alpha + 1;
        if (K < to1 || N + 1 < to2)continue;
        dp[to1][to2] = min(
            dp[to1][to2],
            dp[k][i] + max(0ll, H[to2] - H[i])
        );
    }
    /*
    for (auto row : dp) {
        for (auto col : row)cout << col << " ";
        cout << endl;
    }
    */
    ll res = INF;
    for (auto row : dp)res = min(res, row.back());
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool operator>(const pair<int, int> a, const pair<int, int> b){
    return a.first > b.first;
};//演算子オーバーロード


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> prev(n);
    vector<int> dist(n);
    // store distance and node
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;

    // Dijkstra
    int MAX_DIST = 10000000;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            dist[i] = 0;
        } else {
            dist[i] = MAX_DIST;
        }
    }
    que.push(make_pair(0, 0));

    unordered_set<int> not_visited;
    for (int i = 0; i < n; i++) {
        not_visited.insert(i);
    }

    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int u = p.second;

        // visited
        if (not_visited.find(u) == not_visited.end()) {
            continue;
        }
        for (int v: to[u]) {
            int d = dist[u] + 1;
            if (dist[v] > d) {
                dist[v] = d;
                prev[v] = u;
                que.push(make_pair(d, v));
            }
        }
        not_visited.erase(u);
        if (not_visited.size() == 0) {
            break;
        }
    }

    // for (int i = 0; i < n; i++) {
    //     if (dist[i] >= MAX_DIST) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            cout << "Yes" << endl;
        } else {
            cout << (prev[i] + 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

ll N,K;


ll man(ll N, ll val) {
  //  cout << val << endl;
  if(N==0) return val;
  return min(man(N-1, val*2),man(N-1, val + K));

}

int main() {
  ll N;
  ll M;
  cin >> N;
  map<int,int> mp;
  rep(i,N) {
	int a;
	cin >> a;
	mp[a]++;
  }
  bool f = true;
  cin >> M;
  rep(i,M) {
	int a;
	cin >> a;
	if(mp[a] == 0) f = false;
	mp[a]--;
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}



Measured memory_bytes: 12404
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=5,M=1005,mo=1e9+7;

ll lj[N][N],ls[N][N],jz[N][N];

ll w,h,k;

char s[M][M],t[M][M];

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

inline void fb()
{
	fo(i,1,3)
	fo(l,1,3){
		ls[i][l]=0;
		fo(j,1,3)ls[i][l]=ls[i][l]+jz[i][j]*jz[j][l];
	}
	fo(i,1,3)fo(l,1,3)jz[i][l]=ls[i][l]%mo;
}

inline void times()
{
	fo(i,1,3)
	fo(l,1,3){
		ls[i][l]=0;
		fo(j,1,3)ls[i][l]=ls[i][l]+lj[i][j]*jz[j][l];
	}
	fo(i,1,3)fo(l,1,3)lj[i][l]=ls[i][l]%mo;
}

int main()
{
	cin>>h>>w>>k;
	fo(i,1,h)scanf("%s",s[i]+1);
	int o1=0,o2=0;
	fo(i,1,h)if(s[i][1]=='#'&&s[i][w]=='#')o1=1;
	fo(i,1,w)if(s[1][i]=='#'&&s[h][i]=='#')o2=1;
	ll x=0;
	fo(i,1,h)fo(l,1,w)x+=(s[i][l]=='#');
	if(o1+o2==2)puts("1");
	else if(o1+o2==0){
		ll ans=ksm(x,k-1);
		cout<<ans<<endl;
	}else{
		if(o2==1){
			fo(i,1,h)fo(l,1,w)t[l][i]=s[i][l];
			swap(h,w);
			fo(i,1,h)fo(l,1,w)s[i][l]=t[i][l];
		}
		--k;
		ll a1=0,a2=0;
		fo(i,1,h)if(s[i][1]=='#'&&s[i][w]=='#'){
			++a2;
			int ok=1;
			fo(l,2,w-1)if(s[i][l]=='.')ok=0;
			a2-=ok; a1+=ok;
		}
		ll p=0;
		fo(i,1,h)fo(l,2,w)if(s[i][l]=='#'&&s[i][l-1]=='#')++p;
		if(k==0)puts("1");else
		if(k==1){
			cout<<p<<endl;
		}else {
			ll ans=ksm(x,k);
			--k;
			lj[1][1]=lj[2][2]=lj[3][3]=1;
			jz[1][1]=x;
			jz[2][1]=p;
			jz[3][1]=p;
			jz[2][3]=a2;
			jz[2][2]=a1;
			jz[3][3]=a2+a1;
			for(;k;k>>=1,fb())
			if(k&1)times();
			ans=(ans-(p*lj[1][1]%mo+a1*lj[2][1]%mo+a2*lj[3][1]%mo)%mo+mo)%mo;
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        boolean flag = true;
        
        String s = stdIn.next();
        char c[] = s.toCharArray();
        
        for(int i = 0; i < 3; i++){
            if(c[i] == c[i + 1]){
                flag = false;
                break;
            }
        }
        
        if(flag){
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    ll s=3;
    vector<ll>a(s),b(s);
    rep(i,s){
        cin>>a[i];
    }
    rep(i,s){
        cin>>b[i];
    }
    vector<ll>dp(n+1,n);
    ll ma=n;
    REP(i,1,n+1){
        dp[i]=max(dp[i-1],dp[i]);
        rep(j,s){
            if(i>=a[j]){
                dp[i]=max(dp[i],dp[i-a[j]]-a[j]+b[j]);
            }
        }
        ma=max(ma,dp[i]);
    }
    vector<ll>dp2(ma+1,ma);
    ll m=ma;
    REP(i,1,m+1){
        dp2[i]=max(dp2[i-1],dp2[i]);
        rep(j,s){
            if(i>=b[j]){
                dp2[i]=max(dp2[i],dp2[i-b[j]]-b[j]+a[j]);
            }
        }
        ma=max(ma,dp2[i]);
    }
    cout<<ma<<endl;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (i * j == N) // Don't write in terms of division. Better in multiplication of integers
            {
                cout << "Yes" << "\n";
                return 0;
            }
            
        }
        
    }
    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;


int main() {

  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
        cin >> a[i][j];
    }
  }

  int cnt = 0;
  for(int i = 0; i < n; i++){
    int sum = c;
    for(int j = 0; j < m; j++)
      sum += a[i][j] * b[j];
    if(sum > 0)
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main() {
    string str;
    cin >> str;
    int first, second;
    first = stoi(str.substr(0, 2));
    second = stoi(str.substr(2, 2));

    if (first >= 13) {
        if (second >= 1 && second <= 12)
            cout << "YYMM" << endl;
        else
            cout << "NA" << endl;
    } else if (first >= 1 && first <= 12) {
        if (second >= 13 || second == 0)
            cout << "MMYY" << endl;
        else
            cout << "AMBIGUOUS" << endl;
    } else if (first == 0) {
        if (second >= 1 && second <= 12)
            cout << "YYMM" << endl;
        else
            cout << "NA" << endl;
    } else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll d[310][310];
int n,m,l;
void init()
{
	cin>>n>>m>>l;
	for(int i=1;i<=301;i++)
	{
		for(int j=1;j<=301;j++)
		{
			d[i][j]=1e16;
		}
	}
	for(int i=1;i<=n;i++)
	{
		d[i][i]=0;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		d[x][y]=min(d[x][y],(ll)z);
		d[y][x]=min(d[y][x],(ll)z);
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==j)
				d[i][i]=0;
			else if(d[i][j]<=l)
				d[i][j]=1;
			else 
				d[i][j]=(ll)1e16;
		}
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}

int main()
{
	init();
	int T;
	cin>>T;
	while(T--)
	{
		int s,t,ans;
		scanf("%d%d",&s,&t);
		if(d[s][t]==(ll)1e16)
			cout<<"-1\n";
		else
			cout<<d[s][t]-1<<"\n";
	}
	return 0;	
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,i;
    char op;
    i=1;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '?')break;
    if(op == '+'){
    printf("%d\n",a + b);
}else if(op == '-'){
    printf("%d\n",a - b);
}else if(op == '*'){
    printf("%d\n",a * b);
}else if(op == '/'){
    printf("%d\n",a / b);
}
    i++;}

return 0;
}


Measured memory_bytes: 2104
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if (n % 2 == 0) {
            System.out.println(n / 2);
        } else {
            System.out.println(n / 2 + 1);
        }

    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

const int maxn = 200005;
int n, q, cnt;
vector <int> e[200005];
int pos[maxn], s[maxn], l[maxn], r[maxn], d[maxn];

void input(){
    cin >> n >> q;
    int u, v;
    for (int i = 1; i < n; i++){
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
}

void dfs(int u, int p){
    pos[u] = ++cnt;
    pos[u] = l[u] = cnt;
    for (int v : e[u])
    if (v != p){
        dfs(v, u);
    }
    r[u] = cnt;
}

void query(){
    int p, x;
    while (q--){
        cin >> p >> x;
        d[l[p]] += x;
        d[r[p] + 1] -= x;
    }
    for (int i = 1; i <= n; i++)
        s[i] = s[i - 1] + d[i];
    for (int i = 1; i <= n; i++)
        cout << s[pos[i]] << ' ';
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    input();
    dfs(1, 0);
    query();
    return 0;
}


Measured memory_bytes: 26368
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int t, n, k[MAXN], l[MAXN], r[MAXN], choose[MAXN];
vector<int> L[MAXN], R[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> t;
    while (t--) {
        cin >> n;
        FOR(i,0,n+1) {
            L[i].clear();
            R[i].clear();
            choose[i] = 0;
        }
        FOR(i,1,n) {
            cin >> k[i] >> l[i] >> r[i];
            L[k[i]].push_back(i);
            R[k[i]+1].push_back(i);
        }
        ll res = 0;
        set<II> s;
        FORE(i,n,1) {
            for (int j : L[i]) s.insert(II(l[j] - r[j], j));
            if (SZ(s)) {
                II x = *s.rbegin();
                if (x.FI > 0) {
                    choose[x.SE] = 1;
                    s.erase(x);
                }
            }
        }
        s.clear();
        FOR(i,1,n) {
            for (int j : R[i]) s.insert(II(r[j] - l[j], j));
            if (SZ(s)) {
                II x = *s.rbegin();
                if (x.FI > 0) {
                    choose[x.SE] = 1;
                    s.erase(x);
                }
            }
        }

        FOR(i,1,n)
            if (choose[i]) res += max(l[i], r[i]);
            else res += min(l[i], r[i]);
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 28060
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

long long stoi(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

void solve() {
	int n, k;
	cin >> n >> k;
	rep(i, n) {
		int a;
		cin >> a;
	}
	int ans = 1 + ceil(double(n - k) / double(k - 1));
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
mod = 10**9 + 7
n, k = map(int, input().split())

f = {0:0}
s = {0:0}

for i in range(1, 10**6):
    f[i] = (f[i-1] + i) % mod
    s[i] = (s[i-1] + pow(i, 2, mod)) % mod


def solve(n, k):
    ans = (n+1) * ((f[n+1]-f[k-1])%mod) % mod
    sub = (s[n+1] - s[k-1]) % mod
    ans = (ans - sub) % mod
    ans = (ans + n-k+2) % mod

    return ans

ans = solve(n, k)
print(ans)


Measured memory_bytes: 186256
(N,M,Q) = map(int,input().split())
Qs = []
for i in range(Q):
    Qs.append(list(map(int,input().split())))
A = [1]*N
score = 0
while(1):
    if A[0]>M:
        break
    current_score = 0
    for i in range(Q):
        if A[Qs[i][1]-1]-A[Qs[i][0]-1] == Qs[i][2]:
            current_score += Qs[i][3]
    score = max(score,current_score)
    for i in range(1,N):
        if A[i]== M:
            A[i-1] += 1
            for j in range(i,N):
                A[j] = A[i-1]
            break
        if i == N-1:
            A[N-1] += 1
print(score)


Measured memory_bytes: 9128
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strcmp()

int
main(int argc, char **argv)
{
	int n;
	char blood[3];

	int a = 0;
	int b = 0;
	int ab = 0;
	int o = 0;
	while (scanf("%d,%s", &n, blood) != EOF)
	{
		if (strcmp(blood, "A") == 0)
			a++;
		else if (strcmp(blood, "B") == 0)
			b++;
		else if (strcmp(blood, "AB") == 0)
			ab++;
		else if (strcmp(blood, "O") == 0)
			o++;
	}

	printf("%d\n", a);
	printf("%d\n", b);
	printf("%d\n", ab);
	printf("%d\n", o);
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
 
public class Main {
  public static void main(String[] args)  {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String[][] str = new String[H][W];
    boolean [] b1 = new boolean [H];
    boolean [] b2 = new boolean [W];
    
    for(int i=0;i<H;i++) {
      str[i]=sc.next().split("");
      for(int j=0;j<W;j++) {
        if(str[i][j].equals("#")) {
          b1[i]=true;
          b2[j]=true;
        }
      }
    }
 
    for(int i=0;i<H;i++) {
      if(b1[i]) {
        for(int j=0;j<W;j++) {
          if(b2[j]) {
            System.out.print(str[i][j]);
          }
        }
        System.out.println("");
      }
    }
  }
}

Measured memory_bytes: 40032
n = int(input())
listA = list(map(int, input().split()))
listB = list(map(int, input().split()))
listC = list(map(int, input().split()))

cnt = 0
temp = ""
for x in listA: 
    cnt += listB[x-1]
  
    if temp == x-1:
        cnt += listC[temp-1]   
        
   
    temp = x

print(cnt)    



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long x;
  cin>>x;
	for(long long a=1;a<=100LL;++a) {
      for(long long b=-a;b<a;++b) {
    	if(a*a*a*a*a-b*b*b*b*b==x){
            cout<<a<<" "<<b<<endl;
            return 0;
          }
      }
  }
  for(long long a=101;a<=200LL;++a){
  	for(long long b=0;b<a;++b){
      if(a*a*a*a*a-b*b*b*b*b==x){
         cout<<a<<" "<<b<<endl;
         return 0;
        }
      }
  }
  cout << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>

using namespace std;

int main() {

    int N; cin >> N;
    int a[N];
    int max=0;
    for (int i=0; i<N;++i){
        cin >> a[i];
    }
    for (int i=0; i<N;++i){
        for (int j=0; j<N;++j) {
            if (a[i] - a[j] > max) {
                max = a[i] - a[j];
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int x;
    cin >> x;
    int sta = x%1000;
    if(sta != 0)sta = 1000 - sta;
    cout << sta << "\n";
    return 0;
}


Measured memory_bytes: 3612
S = input()
mae = int(S[0:2])
ato = int(S[2:4])
mM = 0
aM = 0
if 1<=mae<=12:
    mM = 1
if 1<=ato<=12:
    aM = 1
if mM + aM == 2:
    print('AMBIGUOUS')
elif mM + aM == 0:
    print('NA')
elif mM == 1:
    print('MMYY')
else:
    print('YYMM')

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i= 0; i < n ; i++){
        cin >> x[i];
    }
    for(int i= 0; i < n ; i++){
        cin >> y[i];
    }
    double d1, d2, d3, d_infty;
    d1 = 0;
    d2=0;
    d3=0;
    d_infty = 0;
    for(int i=0; i<n ;++i){
        d1 += fabs(x[i]-y[i]);
        d2 += pow(x[i]-y[i], 2);
        d3 += pow(fabs(x[i]-y[i]), 3);
        if(d_infty < fabs(x[i]-y[i])) d_infty = fabs(x[i]-y[i]);
    }
    printf("%.8lf\n%.8lf\n%.8lf\n%.8lf", d1, sqrt(d2), pow(d3, 1/3.0), d_infty);

    return 0;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
    long long ans;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N % 2 == 1) {
        long middle = (N + 1) / 2 - 1;
        ans = B.at(middle) - A.at(middle) + 1;
    } else {
        long low = N / 2 - 1;
        long high = low + 1;
        ans = (B.at(high) + B.at(low)) - (A.at(high) + A.at(low)) + 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 6432
#include<iostream>
using namespace std;
int gcd(int b,int s){
    int a = b%s;
    if(a==0){
        return s;
    }else{
        gcd(s,a);
    }
}

int main(){
    int N;
    cin >> N;
    int lcm = (2*N)/gcd(N,2);
    cout << lcm << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
using namespace std;
char a[100005];
string s,s2,s3;
int main()
{
	scanf("%s",&a);
	s=a;
	for (int j=0;j<=s.size()-1;j++)
	{
		if(s[j]=='b')
		s2+='d';
		if(s[j]=='d')
		s2+='b';
		if(s[j]=='p')
		s2+='q';
		if(s[j]=='q')
		s2+='p';
	}
	for (int j=s2.size()-1;j>=0;j--)
	{
		s3+=s2[j];
	}
	if(s3==s)
	printf("Yes");
	else printf("No");
}

Measured memory_bytes: 768
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=1,t[105]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> t[i];
    ans=ans/__gcd(ans,t[i])*t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int j1, s1, r1, e1;
	int j2, s2, r2, e2;
	int sum1 = 0, sum2 = 0;
	
	scanf("%d %d %d %d %d %d %d %d", &j1, &s1, &r1, &e1, &j2, &s2, &r2, &e2);
	
	sum1 = j1+s1+r1+e1;
	sum2 = j2+s2+r2+e2;
	
	if (sum1 > sum2) printf("%d\n", sum1);
	else printf("%d\n", sum2);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p){return id<p.id;}
};
static const int MAX =1000000;
static const int NIL = -1;
int n;
Point P[MAX];
Node T[MAX];
int np;
bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}
int makeKDTree(int l,int r, int d){
  if(!(l<r))return NIL;
  int mid=(l+r)/2;
  int t=np++;
  if(d%2==0)sort(P+l,P+r,lessX);
  else sort(P+l,P+r,lessY);
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,d+1);
  T[t].r=makeKDTree(mid+1,r,d+1);
  return t;
}
void find(int v,int sx,int tx,int sy,int ty,int d,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].location]);
  if(d%2==0){
    if(T[v].l!=NIL)if(sx<=x)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(x<=tx)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
  else{
    if(T[v].l!=NIL)if(sy<=y)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(y<=ty)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
}
int main(){
  int x,y;
  cin>>n;
  rep(i,n){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }
  np=0;
  int root=makeKDTree(0,n,0);
  int q;
  cin>>q;
  int sx,sy,tx,ty;
  vector<Point>ans;
  rep(i,q){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    rep(j,ans.size())printf("%d\n",ans[j].id);
    cout<<endl;
  }return 0;
}

Measured memory_bytes: 16440
#include <bits/stdc++.h>
using namespace std;

int main() {
  int money = 0, mountCoin1 = 0;
  
  cin >> money;
  cin >> mountCoin1;
  
  if( (money % 500) <= mountCoin1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,a,b,c,i;
    scanf("%d",&n);
    b=0;c=0;
    for(i=1;i<=n;i++) {
        scanf("%d",&a);
        if(a%2==0) { b++;
        if(a%6==0 || a%10==0) { c++; }
        }
    }
    if(b==c) { printf("APPROVED\n"); }
    else { printf("DENIED\n"); }

    return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include<vector>
using namespace std;

int w,h;
int c[50][50];
vector<vector<int> > visited;
int dx[]={1,1,0,-1,-1,-1,0,1};
int dy[]={0,-1,-1,-1,0,1,1,1};

bool dfs(int x,int y){
    if(visited[x][y]) return false;
    visited[x][y]=1;

    for(int d=0;d<8;d++){
        int i=x+dx[d];
        int j=y+dy[d];
        if(0<=i&&i<h&&0<=j&&j<w){
            if(c[i][j]){
                dfs(i,j);
            }  
        }
    }
    return true;
}

int solve(int w,int h){

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j]){
                cnt+=dfs(i,j);
            }
        }
    }
    cout<<cnt<<endl;
}

int main(){
    visited.assign(50,vector<int>(50,0));
    while(1){
        cin>>w>>h;
        if(!(w))break;

        solve(w,h);
        visited.assign(50,vector<int>(50,0));
    }
    
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int m[110];
int main(){
    int n,x;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> m[i];
        x -= m[i];
    }
    sort(m,m+n);
    cout << n+x/m[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())
angle = max((h*30+m*0.5),(m*6)) - min((h*30+m*0.5),(m*6))
angle = min(angle,(360-angle))
ans = (a**2) + (b**2) - (2*a*b*math.cos(math.radians(angle)))
print(math.sqrt(ans))

Measured memory_bytes: 9512
# coding: utf-8
# lang: Ruby(2.3.3)
# submission # - User: herp_sy
# https://atcoder.jp/contests/
# ------------------------------------------------------------

a,b = gets.split(' ').map(&:to_i)

cable = 1
ans = 0
while cable < b
	ans += 1
	cable += (a - 1)
end

p ans


Measured memory_bytes: 1788
<?php

$input = explode(' ', trim(fgets(STDIN)));
$a = intval($input[0]);
$b = intval($input[1]);
$c = intval($input[2]);

$count = 0;
while ($a != $b || $a != $c || $b != $c) {
    $count++;

    if ($a == $b) {
        if ($c < $a) {
            $c += 2;
            continue;
        } else {
            $a += 1;
            $b += 1;
            continue;
        }
    }

    if ($a == $c) {
        if ($b < $a) {
            $b += 2;
            continue;
        } else {
            $a += 1;
            $c += 1;
            continue;
        }
    }

    if ($b == $c) {
        if ($a < $b) {
            $a += 2;
            continue;
        } else {
            $b += 1;
            $c += 1;
            continue;
        }
    }

    if ($a > $b && $a > $c) {
        $b += 1;
        $c += 1;
    }
    if ($b > $a && $b > $c) {
        $a += 1;
        $c += 1;
    }
    if ($c > $a && $c > $b) {
        $a += 1;
        $b += 1;
    }
}
echo $count;


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n,r;
	cin>>n>>r;
	if(n>=10){
		cout<<r;
		re 0;
	}
	int a=100*(10-n);
	cout<<r+a;
	re 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

x, n = map(int, input().split())
p = [int(item) for item in input().split()]
seen = set(p)

ans = None 
diff = 200
for val in range(200, -200, -1):
    if val not in seen:
        if abs(val - x) <= diff:
            ans = val
            diff = abs(val - x)

print(ans)

Measured memory_bytes: 9188
/**
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=200+10;
LL N,M;

int main()
{
#ifdef _WY
freopen("0905.in","r",stdin);
#endif // _WY
	scanf("%lld%lld",&N,&M);

	if(N%M==0)  puts("-1");
	else{
		for(int i=2;i*N<=1e18;++i){
			if(i*N%M!=0){
				printf("%lld\n",i*N);
				return 0;
			}
		}
		puts("-1");
	}
	return 0;
}


Measured memory_bytes: 256
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_i                                  end
def gf;             gets.to_f                                  end
def gs;             gets.chomp                                 end
def gmi(n=nil); n.nil? ? gets.split.map(&:to_i) : n.times.map{ gets.to_i } end
def gmf(n=nil); n.nil? ? gets.split.map(&:to_f) : n.times.map{ gets.to_f } end
def gms(n=nil); n.nil? ? gets.split : n.times.map{ gets.chomp } end
def ga2(h);        h.times.map{ gets.split.map(&:to_i) }      end
def gm(h);        h.times.map{ gets.chomp }      end
def yn(f); puts f ? "Yes" : "No" end
def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

n, k = gmi

ans = n % k
t = (ans-k).abs
ans = t if ans > t

puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//
// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// 逆元 a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 3000000;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理(main内にCOMinit();が必要)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n,k; cin>>n>>k;
    COMinit();
    rep(i,1,k+1){
        cout<<(COM(n-k+1,i)*COM(k-1,i-1))%MOD<<endl;
    }
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i;
	ll a,b;
	cin>>a>>b;
	if(((b-2*a)%2==0 && (b-2*a)>=0) && ((4*a-b)%2==0 && (4*a -b)>=0))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() {
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	return *cn++;
}

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int x = C - '0';
	while (isdigit(C = getchar())) x = x * 10 + C - '0';
	return x;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, Q;
	N = getint();
	Q = getint();
	char S[200000];
	fread(S, 1, N, stdin);
	char T[200000], D[200000];
	rep(i, Q) {
		getcha();
		T[i] = getcha();
		getcha();
		D[i] = getcha();;
	}
	int L = 0;
	int R = N;
	for (int i = Q - 1; i >= 0; i--) {
		if (R > 0 && D[i] == 'R' && S[R - 1] == T[i]) R--;
		else if (R < N && D[i] == 'L' && S[R] == T[i]) R++;
		if (L > 0 && D[i] == 'R' && S[L - 1] == T[i]) L--;
		else if (L < N && D[i] == 'L' && S[L] == T[i]) L++;
	}

	co(R - L);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
using namespace std;
bool dp[55][55][55]; // (maximum k, current, goal)
int main() {
	for (int i = 0; i <= 50; ++i) {
		for (int j = 0; j <= 50; ++j) {
			for (int k = 0; k <= j; ++k) {
				if (j == k) dp[i][j][k] = true;
				else if (i != 0 && dp[i - 1][j][k]) dp[i][j][k] = true;
				else if (i != 0 && dp[i - 1][j % i][k]) dp[i][j][k] = true;
			}
		}
	}
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) cin >> B[i];
	vector<long long> cur(N);
	for (int i = 0; i < N; ++i) {
		cur[i] |= 1LL << A[i];
	}
	long long ans = 0;
	for (int i = 51; i >= 1; --i) {
		bool exec = false;
		for (int j = 0; j < N; ++j) {
			bool ok = false;
			for (int k = 0; k <= 50; ++k) {
				if (((cur[j] >> k) & 1) && dp[i - 1][k][B[j]]) {
					ok = true;
				}
			}
			if (!ok) exec = true;
		}
		if (exec) {
			if (i == 51) {
				ans = -1;
				break;
			}
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k <= 50; ++k) {
					if ((cur[j] >> k) & 1) {
						cur[j] |= 1LL << (k % i);
					}
				}
			}
			ans += 1LL << i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
typedef pair<int, int> P;
typedef long long ll;

int N;
ll A[100010];
ll dp[100010];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A+N);

    rep(i, N) {
        if (i == 0) dp[i] = A[i];
        else dp[i] = dp[i-1] + A[i];
    }

    int i=-1;
    for (i=N-2; i>=0; --i) {
        if (dp[i]*2 >= A[i+1]) continue;
        else break;
    }

    int ans=N;
    if (i > 0) ans -= i+1;
    if (i == 0) i=-1;
    for (i=i+1; i<N; ++i) {
        bool flag=true;
        ll a = dp[i];
        for (int j=i+1; j<N; ++j) {
            if (i == j) continue;
            if (a*2 >= A[j]) {
                a += A[j];
            } else {
                ans--;
                flag = false;
                break;
            }
        }
        if (flag) {
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792