akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ok = false;
    for (int i = 0; i < b; i++) {
        if (a * i % b == c) ok = true;
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll A, B;
    cin >> A >> B;
    cout << A * B - (A + B - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
#include<map>
#include<vector>
#include <math.h>
using namespace std;
#define ll long long


int main(){
    int h,n,a;
    cin>>h>>n;
    //int a[100005];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
/*
*
* author: ian macleod
*
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef vector<long long int> vll;

#define IO                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b) for(ll i=a;i>=b;i--)

ll power(ll x, ll y) {
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0) {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}


void solve() {
    
    ll a,b,c,k, sum=0;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
        return ;
    }
    else {
        k -= a;
        sum += a;
        if (k > b) {
            k-=b;
            sum -= k;
            cout << sum << endl;
        }
        else {
            cout << sum << endl;
        }
    }
    
    return ;
}



int main() {
    solve();
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int A[102345];

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , A + i);
	}
	sort(A,A+N,greater<int>());
	LL x = 0, y = 0;
	repp(i,1,N){
		if(A[i-1] == A[i]){
			if(x == 0){
				x = A[i];
				++i;
			} else {
				y = A[i];
				break;
			}
		}
	}
	printf("%lld\n" , x * y);
	return 0;
}


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


 
int main() {


    int n;
    cin>>n;

    vector<int64_t> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }

    int64_t sum=0;
    int64_t sum1=0;
    for(int i=n-2;i>=0;i--){
        sum1+=(a.at(i+1));
        sum+=((sum1%(1000000007))*a.at(i))%(1000000007);
        sum%=1000000007;
    }

    cout<<sum<<endl;

 	return 0;
}

Measured memory_bytes: 4844
s = input()

mod = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(len(s))]

if s[0] == '?':
    dp[0] = [1] * 10 + [0] * 3
else:
    dp[0][int(s[0])] = 1

for i in range(len(s)-1):
    if s[i+1] == '?':
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j]) % mod
    else:
        n = int(s[i+1])
        for j in range(13):
            dp[i+1][(j*10+n)%13] = (dp[i+1][(j*10+n)%13] + dp[i][j]) % mod

print(dp[len(s)-1][5])

Measured memory_bytes: 87972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

void solve1()
{
    int n; cin >> n;
    vector<vector<int>> d(n, vector<int>(2));
    rep(i, n) {
        rep(j, 2) {
            cin >> d[i][j];
        }
    }

    int cnt = 0;
    bool f = false;
    rep(i, n) {
        if(d[i][0] == d[i][1]) {
            cnt ++;
        } else {
            cnt = 0;
        }

        if(cnt >= 3) {
            f = true;
        }
    }

    if(f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main()
{
    solve1();
}


Measured memory_bytes: 3600
N,A,B=map(int,input().split())
S = input()

count = 0
abroadCount = 0

for c in S:
    result = False
    if c == "a":
        if count<A+B:
            result = True
            count+=1
    if c=="b":
        if count<A+B and abroadCount < B:
            result = True
            count+=1
            abroadCount +=1
    if result: print('Yes')
    else: print('No')

Measured memory_bytes: 4016
#include<iostream>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int a[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i+=2){
    if(a[i]%2==1) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=200100;
typedef long long LL;
int n,m;LL a[maxn],b[maxn],t1,t2,tot,c[maxn];
LL ans,mod=1e9+7;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&c[i]);
		if(c[i]>=0)
		{
			a[++t1]=c[i];
		}
		else
		{	
			b[++t2]=c[i];
		}
	}
	ans=1;
	sort(a+1,a+1+t1);
	sort(b+1,b+1+t2);
	if(t1==0&&m%2==1)
	{
		for(int i=t2;i>t2-m;--i)
		{
			ans=ans*b[i]%mod;
		}
	}
	else
	{
		sort(c+1,c+1+n);
		int x=n,y=1;	
		LL k1,k2;
		while(m>0)
		{
			if(m%2==1)
			{
				ans=ans*c[x]%mod;
				x--;m--;
			}
			else if(m>=2)
			{
				k1=c[x]*c[x-1];
			//	cout<<a[x]<<" "<<a[x-1]<<" "<<a[x]*a[x-1]<<endl;
				k2=c[y]*c[y+1];
			//	cout<<k1<<" "<<k2<<endl;
				if(k1<k2)
				{
					ans=k2%mod*ans%mod;
					y+=2;
					m-=2;
				}
				else
				{
					ans=k1%mod*ans%mod;
					x-=2;
					m-=2;
					
				}
			//	cout<<ans<<endl;
			}
			
		}
		
	}
		
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}


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

using namespace std;

int N;
vector<pair<int, int>> xs, ys;
vector<bool> vis;

int main() {

  cin >> N;
  vector<pair<int, int>> ls, rs;
  for(int i=0; i<N; i++) {
    string S; cin >> S;
    int M = S.size();
    int mini = 0, cnt = 0;
    for(int j=0; j<M; j++) {
      if(S[j] == '(') cnt++;
      else cnt--;
      mini = min(mini, cnt);
    }
    if(cnt >= 0)
      ls.emplace_back(mini, cnt);

    cnt = 0, mini = 0;
    for(int j=M-1; j>=0; j--) {
      if(S[j] == ')') cnt++;
      else cnt--;
      mini = min(mini, cnt);
    }
    if(cnt > 0)
      rs.emplace_back(mini, cnt);
  }

  sort(ls.begin(), ls.end(), [&](pair<int, int> const& l, pair<int, int> const& r) { return l.first != r.first ? l.first > r.first : l.second > r.second; });
  sort(rs.begin(), rs.end(), [&](pair<int, int> const& l, pair<int, int> const& r) { return l.first != r.first ? l.first > r.first : l.second > r.second; });

  int sum1 = 0;
  bool ok = 1;
  for(int i=0; i<ls.size(); i++) {
    if(sum1 + ls[i].first < 0) {
      ok = 0;
    }
    sum1 += ls[i].second;
  }

  int sum2 = 0;

  for(int i=0; i<rs.size(); i++) {
    if(sum2 + rs[i].first < 0) {
      ok = 0;
    }
    sum2 += rs[i].second;
  }

  cout << (ls.size() + rs.size() == N && ok && sum1 == sum2 ? "Yes" : "No") << endl;

  return 0;
}

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

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	std::vector<std::array<int, 3>> city(M);	// i, y, p
	for (int i{}; i < M; i++)
	{
		scanf("%d%d", &city[i][2], &city[i][1]);
		city[i][2]--;
		city[i][0] = i;
	}
	std::sort(city.begin(), city.end(),
		[](auto& a, auto& b) { return a[1] < b[1]; }
	);
	std::vector<int> prefecture(N);
	std::vector<int64_t> ans(M);
	for (auto& e: city)
	{
		prefecture[e[2]]++;
		ans[e[0]] = 1'000'000ll * (e[2] + 1) + prefecture[e[2]];
	}
	for (auto& e: ans) printf("%012lld\n", e);

	return 0;
}

Measured memory_bytes: 3840
import java.io.*;
import java.util.*;
import java.lang.*;
import static java.lang.System.*;
public class Main
{
public static void main (String args[]) throws Exception
{
	Scanner sc=new Scanner(in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if((a+b)%3==0 || a%3==0 || b%3==0)
    out.println("Possible");
    else
    out.println("Impossible");


}
}


class Berland
{
char ch;
int pos;
public Berland(int a,char b)
{
ch=b;
pos=a;
}
}
class ChComparator implements Comparator<Berland>
{
public int compare(Berland f1,Berland f2)
{
if(f1.ch==f2.ch)
return 0;
if(f1.ch<f2.ch)
return -1;
return 1;
}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;



int main(){
    string a,b ;
    cin >> a >> b ;
    a += b ;
    int n = stoi(a) ;
    for (size_t i = 1; i < 1000; i++)
    {
        if (i*i == n)
        {
            cout << "Yes" << endl ;
            return 0 ;
        }
        
    }
    cout << "No" << endl ;
}

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

int main() {
	int n;
	cin >> n;

	vector<long long> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

	long long x = a[0], y = b[0];

	for (int i = 1; i < n; i++) {
		long long t = max((x + a[i] - 1) / a[i], (y + b[i] - 1) / b[i]);
		x = t * a[i];
		y = t * b[i];
	}

	cout << x + y << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i++) {
			if (i + k - 1 <= n) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import sys

N, Y = map(int, input().split())
for i in range(N+1):
  for j in range(N-i+1):
    if 9000 * i + 4000 * j + 1000 * N == Y:
      print(i, j, N-i-j)
      sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a < 0){
        cout << (-a)*c+d+b*e << endl;
    }
    if(a == 0){
        cout << d+b*e << endl;
    }
    if(a > 0){
        cout << (b-a)*e << endl;
    }
}


Measured memory_bytes: 3096
#-*- coding: utf-8 -*-
"""
"""

from collections import defaultdict
import sys

import math


def sol(a, b, c):
    return int(a * b / 2)


do_submit = True


def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    a, b, c = parsed_lines[0]
    return a, b, c


if not do_submit:
    a, b, c = input_parse("""
    45 28 53
    """)
    print(sol(a, b, c))
else:
    a, b, c = list(map(int, input().split()))
    print(sol(a, b, c))




Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>
#include<functional>
#include<queue>
#pragma warning(disable:4996)
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
const int smallinf = 1 << 30;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[100006], b[100006], c[100006], d[100006];
int u[200006], v[200006];
vector<int>G[300006];//G[k]:kがつながっている辺の番号
int dis[200006];
int V;

signed main() {
	int x, y, z, n, m, s, t; 
	scanf("%d%d%d%d%d%d%d",&x,&y,&z,&n,&m,&s,&t);
	
	rep(i, n) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;
	}
	rep(i, m) {
		scanf("%d%d", &c[i], &d[i]);
		c[i]--; d[i]--;
	}

	rep(i, n) {
		u[i] = a[i];
		v[i] = x + b[i];
		G[u[i]].push_back(i);
		G[v[i]].push_back(i);
	}
	rep(i, m) {
		u[n + i] = c[i] + x;
		v[n + i] = d[i] + x + y;
		G[u[n + i]].push_back(i + n);
		G[v[n + i]].push_back(i + n);
	}
	V = x + y + z;
	s--; t--; t += n;
	queue<P>Q;
	Q.push(P(0, s));
	fill(dis, dis + n+m, smallinf);
	dis[s] = 0;
	while (Q.size()) {
		P p = Q.front();
		Q.pop();
		int nv = p.second;
		if (dis[nv] < p.first)continue;
		for (int e : G[u[nv]]) {
			if (dis[e] > dis[nv] + 1) {
				dis[e] = dis[nv] + 1;
				Q.push(P(dis[e], e));
				if (e == t) {
					printf("%d\n", dis[e]); return 0;
				}
			}
		}
		for (int e : G[v[nv]]) {
			if (dis[e] > dis[nv] + 1) {
				dis[e] = dis[nv] + 1;
				Q.push(P(dis[e], e));
				if (e == t) {
					printf("%d\n", dis[e]); return 0;
				}
			}
		}
	}

	puts("-1");
}


Measured memory_bytes: 21612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  list<long long>A;
  for(int i=0;i<N;i++){
    long long a;
    cin>>a;
    if(i%2==0){
      A.push_back(a);
    }
    else{
      A.push_front(a);
    }
  }
  if(N%2==1){
    reverse(A.begin(),A.end());
  }
  for_each(A.cbegin(), A.cend(), [](long long x){
    cout << x << " ";
  });
}


Measured memory_bytes: 8448
//先頭の数字が9以外の場合、一つ下げて残りを９
#include <bits/stdc++.h>
using namespace std;

int main(){
long long n;
  cin >> n;
  int count =0;
  bool ans = true; 
  while(n>=10){
    if(n%10!=9){
      ans = false;
    }
    n /= 10;
    count++;
  }
  
  if(ans) cout << 9*(count)+n << endl;
  else cout << 9*(count)+n-1 << endl;
}
  

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
char a[5];
signed main(){
	int cnt = 0;
	for (int i = 0; i < 3; i++)cin >> a[i];
	for (int i = 0; i < 3; i++) {
		if (a[i] == '1')cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;


int main() {

	double a, b;

	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;

	return 0;
}

Measured memory_bytes: 384
import math

N = int(input())
X,Y = [],[]
for i in range(N):
    x,y = input().split()
    x,y = int(x),int(y)
    X.append(x)
    Y.append(y)
    
sum_ = 0
for i in range(N):
    for j in range(N):
        if(i != j):
            sum_ += math.sqrt((X[i]-X[j])**2+(Y[i]-Y[j])**2)

print(sum_/N)

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

ll double_function( string s ){
reverse(s.begin(),s.end()) ;
int d = 0 ; 
int k = 1 ;
for(int i = 0 ; i < s.size() ; i++ ){
    if(s[i] == '.') continue ;
d += ( s[i] - '0' )*k ;
k *= 10 ;
}
return d ;
}

int main(){
ll n ; cin >> n ;
string s ;
cin >> s ;
ll m = double_function(s) ;
//cout << m << endl ;
cout << n*m/100 << endl ; 
}

Measured memory_bytes: 3628
import java.util.Scanner;

/**
 * https://abc052.contest.atcoder.jp/tasks/abc052_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		sc.close();
		
		System.out.println(Math.max(a*b,c*d));

	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;

struct edge {
    edge() : link_to(0), cost(0) {}
    edge(int t, int c) : link_to(t), cost(c) {}
    int link_to;
    int cost;
};

void dijkstra(std::vector<std::vector<edge>>& g, std::vector<int>& d, std::vector<int>& from, int s) {
    priority_queue<P, std::vector<P>, greater<P>> que;
    d[s] = 0;
    from[s] = s;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : g[v]) {
            if (d[e.link_to] > d[v] + e.cost) {
                d[e.link_to] = d[v] + e.cost;
                from[e.link_to] = v;
                que.push(make_pair(d[e.link_to], e.link_to));
            }
        }
    }
}

int main(int argc, char **argv) {
    i64 n,m;
    cin >> n >>m;

    vector<vector<edge>> graph(n);
    for (int i=0; i<m; ++i) {
        int a, b;
        cin >> a>> b;
        --a; --b;
        graph[a].push_back(edge(b, 1));
        graph[b].push_back(edge(a, 1));
    }
    std::vector<int> dist(n,int_max), root(n,-1);
    dijkstra(graph, dist, root, 0);

    for (auto f : root) {
        if (f == -1) {
            cout << "No"<< endl;
            return 0;
        }
    }
            cout << "Yes" <<endl;
    for (int i=1; i<n; ++i) {
        cout << (root[i]+1) << "\n";
    }
    return 0;
}


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

int main() {
  set<ll> a;
  for (int i = 0; i < 100000; i++) {
    int s = 0;
    for (int j = 1; j <= i; j *= 10) {
      s += i % (10 * j) / j;
    }

    for (int j = 0; j <= 13; j++) {
      ll d = 1;
      for (int k = 0; k < j; k++) {
        d *= 10;
      }
      // ((i + 1) * d - 1) / (s + 9 * j) <= ((i + 2) * d - 1) / (s + 9 * j + 1)
      if (((i + 1) * d - 1) * (s + 9 * j + 1) <= ((i + 2) * d - 1) * (s + 9 * j)) {
        a.insert((i + 1) * d - 1);
      }
    }
  }
  a.erase(0);

  int k;
  cin >> k;
  vector<ll> r;
  for (auto it = begin(a); r.size() < k && it != end(a); it++) {
    r.push_back(*it);
  }
  for (auto e : r) {
    cout << e << endl;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, k; std::cin >> n >> k;
    std::cout << (n - 1 + k - 2) / (k - 1) << std::endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main() {
    srand((unsigned)time(NULL));
    int n; char a[11][11]; int b, c[11], d = -1;
    for (int i = 0; i < 11; i++) { c[i] = 0; }
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            if (a[i][j] != 'x') { c[i]++; }
        }
        if (c[i] == n) { d = i; }
    }
    for (int i = 0; i < 1000; i++) {
        if (d >= 0) { cout << d + 1 << endl; }
        else { cout << rand() % n + 1 << endl; }
        cin >> b;
    }
    return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N;
vector<int> g[size];
pair<long,long> dfs(int p, int v){
	long x = 1, y = 1;
	pair<long,long> t;
	for(int u:g[v]){
		if(u == p) continue;
		t = dfs(v, u);
		(x *= t.second) %= mod;
		(y *= (t.first + t.second) % mod) %= mod;
	}return {x, y};
}
int main(){
	cin>>N;
	int a,b;
	rep(i,0,N-1){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	pair<long,long> t = dfs(-1, 0);
	cout<<(t.first + t.second) % mod<<endl;
}

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

const string STR = "CODEFESTIVAL2016";

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 16; i++)
	{
		if (s[i] != STR[i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
#include <tuple>

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  std::set<std::tuple<int, int, int>> set;
  set.emplace(A, B, C);
  for (int i=0; i<1e7; ++i) {
    if (A % 2 || B % 2 || C % 2) {
      printf("%d\n", i);
      return 0;
    }

    int a=(B+C)/2;
    int b=(C+A)/2;
    int c=(A+B)/2;
    A = a;
    B = b;
    C = c;

    if (set.count(std::make_tuple(a, b, c))) {
      printf("-1\n");
      return 0;
    }

    set.emplace(a, b, c);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int ans[N];
int32_t main()
{
    IOS;
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n-1;i++)
    {
        if(i<=x)
        {
            for(int j=i+1;j<=n;j++)
            {
                if(j>=y)
                {
                    int p=x-i;
                    p+=j-y+1;
                    ans[p]++;
                }
                else
                {
                    ans[min(j-i,x-i+1+y-j)]++;
                    
                }
            }
        }
        else
        {
            for(int j=i+1;j<=n;j++)
            {
                ans[min(j-i,i-x+1+abs(y-j))]++;
               
            }
        }
    }
    for(int i=1;i<=n-1;i++)
        cout<<ans[i]<<" ";
    cout<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, e;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    
    cout << (max(a, 40)+max(b, 40)+max(c, 40)+max(d, 40)+max(e, 40))/5 << endl;
    
}



Measured memory_bytes: 3096
import sys
import numpy as np

# w 判定する文字列取得
w = input()

char_cnt = np.zeros(27)

for c in w:
    # アスキーコードで'a'からの変位を取得
    i = ord(c) - ord('a')
    # 出現した文字数をカントアップ
    char_cnt[i] += 1

# 2で割った余りを求める
char_mod = char_cnt % 2

if char_mod.sum() == 0:
    # 余りの合計が 0 なら美しい
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20332
/*
ex3_4
tomatokan
*/
#include<stdio.h>

int main(void){
    int n;
    int b=0;/*bは出力がyesなら1,noなら0*/
    scanf("%d",&n);
    for (int i=0;i<9;i++){
        /*nが(i+1)の段にあるか判定*/
        if(n%(i+1)==0&&n/(i+1)<=9){
            printf("Yes\n");
            b=1;
            break;
        }
    }
    if (b==0){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限
input = sys.stdin.readline

def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
#print(edges)
px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])


Measured memory_bytes: 273360
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

#define endl '\n'

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

mt19937 gen(34);
//mt19937_64 gen(41);


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	ll x;
	cin >> x;
	cout << (x / 500) * 1000 + (x % 500) / 5 * 5;
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    ll n;
    cin >> n;
    string ans = "";
    ll div = 26;
    // n--;
    while(n != 0){
        n--;
        ans += (char)('a' + n%div);
        n /= div;
    }
    REV(ans);
    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, 0, n)cin >> v[i];
	int m;
	cin >> m;
	vector<int> vv(m);
	rep(i, 0, m)cin >> vv[i];

	Sort(v); Sort(vv);

	int ans = 0;
	rep(i, 0, m) {
		if (binary_search(v.begin(), v.end(), vv[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3408
#include<stdio.h>
int main(void)
{
	while(1){
		int i,j,a,b;
		scanf("%d",&a);
		scanf("%d",&b);
		if(a==0 && b==0){
			break;
		}
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2120
from collections import deque
import sys
input = sys.stdin.readline
N=int(input())
ki=[[] for f in range(N)]
for i in range(N-1):
 u,v,w = map(int,input().split())
 ki[u-1].append([v-1,w%2])
 ki[v-1].append([u-1,w%2])
stack = deque([[0,0]])
check = [0]*N #チェック済みリスト
ans=[2]*N
ans[0]=0
while stack != deque([]) :
 a=stack.pop()
 ne=a[0]
 if check[ne]==0:
  check[ne]=1
  for i in range(len(ki[ne])):
   eda=ki[ne][i][0]
   edanum=ki[ne][i][1]
   edaans=(edanum+ans[ne])%2
   if check[eda]==0:
    stack.append([eda,edaans])
    ans[eda]=edaans
for i in ans:
 print(i)

Measured memory_bytes: 79904
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int S = sc.nextInt();
        int W = sc.nextInt();

        if(S <= W) {
        	System.out.println("unsafe");
        } else {
        	System.out.println("safe");
        }
    }
}

Measured memory_bytes: 27048
#include <stdio.h>

int main()
{
  int n, x, min, max;
  long sum=0;
  scanf("%d\n", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &x);
    if (i==0 || x<min) min=x;
    if (i==0 || x>max) max=x;
    sum += x;
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}


Measured memory_bytes: 2136
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string s;
  cin >> s;

  string tmp = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'x') tmp += s[i];
  }

  string p = tmp;
  reverse(ALL(p));
  if (tmp != p) {
    cout << -1 << endl;
    return 0;
  }

  int n = tmp.size() / 2;

  static int n1[101010];
  m0(n1);

  int t = 0;
  for (int i = 0; i <= n; i++) {
    while (s[t] == 'x') {
      n1[i]++;
      t++;
    }
    t++;
  }

  t = 0;
  int ans = 0;
  reverse(ALL(s));
  for (int i = 0; i <= n; i++) {
    int res = 0;
    while (s[t] == 'x') {
      res--;
      n1[i]--;
      t++;
    }
    ans += abs(n1[i]);
    t++;
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  rep(i, h) {
    rep(j, w) {
      if (i < b && j < a) cout << 0;
      else if (i < b) cout << 1;
      else if (j < a) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }

  return 0;
}


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

#define F first
#define S second

using namespace std;
typedef long double ld;
typedef long long ll;

const int max_n = 100011, max_m = 1000011, inf = 1000111222;
const ll inff = 1000111222333444;
const int mod = 1000000007;

int n, k;
vector<int> v[max_n];
int ans = 1;

void dfs(int x, int p, int d) {
    if (p == -1) ans = k;
    else ans = 1LL * ans * (k - d) % mod;
    d = p == -1 ? 1 : 2;
    for (int i = 0; i < v[x].size(); ++i) {
        if (v[x][i] == p) continue;
        dfs(v[x][i], x, d++);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k;
    for (int i  =0; i < n - 1; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        --x; --y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(0, -1, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int arr[] = new int [n+1]; 
		boolean flag = false;
		for(int i=1 ; i <= n ; i++){
			arr[i] = scanner.nextInt();
		}
		int count = 0;
		int i = 1;
		
		while(flag == false){
			if(i == n+1){
				i=1;
			}
			if(arr[i] == i){
				if(i!=n){
					int temp = arr[i];
					arr[i] = arr[i+1];
					arr[i+1] = temp;
					i++;
					count ++;
				}else{
					int temp = arr[i];
					arr[i] = arr[i-1];
					arr[i-1] = temp;
					i++;
					count ++;
				}
			}else{
				i++;
			}
			
			if(i == n+1){
				for(int j=1 ; j<=n ; j++){
					if(arr[j] == j){
						break;
					}
					if(j == n) flag = true;
				}
			}
		}
		
		System.out.println(count);
		
	}
}


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

int main(){
	ll L,R;
	cin >> L >> R;
	int ans;
	if(R-L>=2019){
		ans = 0;
	}else{
		L %= 2019;
		R %= 2019;
		if(R > L){
			ll min(2020);
			for(int i(L);i<R;++i){
				for(int j(i+1);j<R+1;++j){
					if(min > (i*j)%2019) min = (i*j)%2019;
				}
			}
			ans = min;
		}else{
			ans = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,t; cin>>n>>t;
    ll ans=INF;
    rep(i,n){
        ll cost,time;
        cin>>cost>>time;
        if(time > t) continue;
        else ans=min(ans,cost);
    }
    if(ans==INF) cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

#define OUTPUT__LENGTH (128)
char _out[OUTPUT__LENGTH];
char *_o = _out;
void write_uint(int n) {
    if(!n) {
        *_o++ = '0';
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (n % 10 + '0'), n /= 10;
    while(i--) *_o++ = buf[i];
}
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
int *find(int *first, int *last, const int value) {
    for(;first!=last;++first)
        if(*first == value) return first;
    return last;
}

typedef struct Node {
    int parent, left, right, depth, height, sibling;
} Node;
typedef struct BinaryTree {
    Node nodes[40];
    int root;
} BinaryTree;
void bt_init(BinaryTree *BT) {
    for(int i = 0; i < 40; ++i) BT->nodes[i].parent = -1;
}
void bt_make(BinaryTree *BT) {
    for(int i = 0; i < 40; ++i) {
        if(BT->nodes[i].parent == -1) {
            BT->root = i;
            break;
        }
    }
}
void bt_add_node(BinaryTree *BT, int id, int l, int r) {
    BT->nodes[id].left = l;
    BT->nodes[id].right = r;
    if(~l) BT->nodes[l].parent = id;
    if(~r) BT->nodes[r].parent = id;
}
int bt_pre_in(BinaryTree *BT, int *pre, int *in, int l, int r) {
    static int pos = 0;
    if(l >= r) return -1;
    int root = pre[pos++];
    int mid = (int)(find(in, in+r, root) - in);
    int ln = bt_pre_in(BT, pre, in, l, mid);
    int rn = bt_pre_in(BT, pre, in, mid+1, r);
    bt_add_node(BT, root, ln, rn);
    return root;
}
void bt_pr_postorder(BinaryTree *BT, int id) {
    if(id == -1) return;
    bt_pr_postorder(BT, BT->nodes[id].left);
    bt_pr_postorder(BT, BT->nodes[id].right);
    *_o++ = ' ';
    write_uint(id+1);
}
int main(int argc, char **argv) {
    int n = get_uint();
    int pre[n], in[n];
    for(int i = 0; i < n; ++i) pre[i] = get_uint()-1;
    for(int i = 0; i < n; ++i) in[i] = get_uint()-1;
    BinaryTree BT;
    bt_init(&BT);
    bt_pre_in(&BT, pre, in, 0, n);
    bt_make(&BT);
    bt_pr_postorder(&BT, BT.root);
    for(char *p = _out+1; p!=_o;++p) putchar_unlocked(*p);
    putchar_unlocked('\n');
    return 0;
}




Measured memory_bytes: 2052
//aoj0001
import std.stdio;
import std.algorithm;

void main()
{
    int[] h;
    h.length = 10;
    for(int i=0;i<10;i++)
    {
        readf("%d\n", &h[i]);
    }
    sort!("a > b")(h);
    for(int i=0;i<3;i++)
    {
        writeln(h[i]);
    }
}

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




int main()
{
	int area[14][14] = {0};
	int x,nx,ny,y,size;
	int count = 0;
	int max = 0;
	char ch1,ch2;
	while(cin >> x >>ch1>> y >>ch2>> size){
		nx=x+2;
		ny=y+2;
		switch (size){
		case 3:
			area[nx-2][ny]++;
			area[nx+2][ny]++;
			area[nx][ny-2]++;
			area[nx][ny+2]++;
		case 2:
			area[nx-1][ny-1]++;
			area[nx+1][ny-1]++;
			area[nx-1][ny+1]++;
			area[nx+1][ny+1]++;
		case 1:
			area[nx-1][ny]++;
			area[nx+1][ny]++;
			area[nx][ny-1]++;
			area[nx][ny+1]++;
		}
		area[nx][ny]++;
	}

	for (int i=2;i<12;i++){
		for (int j=2;j<12;j++){
			if (area[i][j]==0){
				count++;
			}
			if(max<area[i][j]){
				max=area[i][j];
			}
		}
	}
	
	cout << count <<endl;
	cout << max << endl;


	return 0;
}

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

using namespace std;

int borw, counter;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(vector<vector<int> >& canGo, int i, int j){
  canGo[i][j] = 3;
  counter++;

  for(int k = 0; k < 4; k++){
    if(canGo[i + dx[k]][j + dy[k]] == 0) dfs(canGo, i + dx[k], j + dy[k]);
    if(canGo[i + dx[k]][j + dy[k]] == 1){
      if(borw == 0 || borw == 1)  borw = 1;
      else borw = 3;
    }

    if(canGo[i + dx[k]][j + dy[k]] == 2){
      if(borw == 0 || borw == 2)  borw = 2;
      else borw = 3;
    }
  }
}


int main(void)
{
  int w, h;
  while(1){
    cin >> w >> h; if(w == 0 && h == 0) break;

    int B = 0, W = 0;
    vector<vector<int> > canGo(h + 2, vector<int>(w + 2, 3));

    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	char input; cin >> input;
	if(input == '.') canGo[i][j] = 0;
	if(input == 'B') canGo[i][j] = 1;
	if(input == 'W') canGo[i][j] = 2;
      }
    }
   
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	borw = 0;
	counter = 0;
       if(canGo[i][j] == 0){
	  dfs(canGo, i, j);
	  if(borw == 1) B += counter;
	  if(borw == 2) W += counter;
        }
      }
    }

    cout << B << " " << W << endl;

  }
  return 0;
  
}

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

int main(){
    int n;
    cin >> n;

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

    for(int i=0; i<n; i++){
        c[i] -= v[i];
    }
    sort(c.begin(),c.end());

    int count = 0, sum = 0;
    while(c[count] < 0){
        sum -= c[count];
        count += 1;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{	
	int num1=0,num2=0,num3=0,num4=0,num5=0,num6=0,num7=0,num8=0,num9=0,num10=0,num11=0,num12=0,num13=0,num14=0,num15=0,num16=0,num17=0,num18=0,num19=0,num20=0,num21=0,num22=0,r=0;
	
	cin>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8>>num9>>num10>>num11>>num12>>num13>>num14>>num15>>num16>>num17>>num18>>num19>>num20;
	if(num1<num2){
		r=num1;
		num1=num2;
		num2=r;
	}
	if(num1<num3){
		r=num1;
		num1=num3;
		num3=r;
	}
	if(num1<num4){
		r=num1;
		num1=num4;
		num4=r;
	}
	if(num1<num5){
		r=num1;
		num1=num5;
		num5=r;
	}
	if(num1<num6){
		r=num1;
		num1=num6;
		num6=r;
	}
	if(num1<num7){
		r=num1;
		num1=num7;
		num7=r;
	}
	if(num1<num8){
		r=num1;
		num1=num8;
		num8=r;
	}
	if(num1<num9){
		r=num1;
		num1=num9;
		num9=r;
	}
	if(num1<num10){
		r=num1;
		num1=num10;
		num10=r;
	}
	if(num2<num3){
		r=num2;
		num2=num3;
		num3=r;
	}
	if(num2<num4){
		r=num2;
		num2=num4;
		num4=r;
	}
	if(num2<num5){
		r=num2;
		num2=num5;
		num5=r;
	}
	if(num2<num6){
		r=num2;
		num2=num6;
		num6=r;
	}
	if(num2<num7){
		r=num2;
		num2=num7;
		num7=r;
	}
	if(num2<num8){
		r=num2;
		num2=num8;
		num8=r;
	}
	if(num2<num9){
		r=num2;
		num2=num9;
		num9=r;
	}
	if(num2<num10){
		r=num2;
		num2=num10;
		num10=r;
	}
	if(num3<num4){
		r=num3;
		num3=num4;
		num4=r;
	}
	if(num3<num5){
		r=num3;
		num3=num5;
		num5=r;
	}
	if(num3<num6){
		r=num3;
		num3=num6;
		num6=r;
	}
	if(num3<num7){
		r=num3;
		num3=num7;
		num7=r;
	}
	if(num3<num8){
		r=num3;
		num3=num8;
		num8=r;
	}
	if(num3<num9){
		r=num3;
		num3=num9;
		num9=r;
	}
	if(num3<num10){
		r=num3;
		num3=num10;
		num10=r;
	}
	if(num11<num12){
		r=num11;
		num11=num12;
		num12=r;
	}
	if(num11<num13){
		r=num11;
		num11=num13;
		num13=r;
	}
	if(num11<num14){
		r=num11;
		num11=num14;
		num14=r;
	}
	if(num11<num15){
		r=num11;
		num11=num15;
		num15=r;
	}
	if(num11<num16){
		r=num11;
		num11=num16;
		num16=r;
	}
	if(num11<num17){
		r=num11;
		num11=num17;
		num17=r;
	}
	if(num11<num18){
		r=num11;
		num11=num18;
		num18=r;
	}
	if(num11<num19){
		r=num11;
		num11=num19;
		num19=r;
	}
	if(num11<num20){
		r=num11;
		num11=num20;
		num20=r;
	}
	if(num12<num13){
		r=num12;
		num12=num13;
		num13=r;
	}
	if(num12<num14){
		r=num12;
		num12=num14;
		num14=r;
	}
	if(num12<num15){
		r=num12;
		num12=num15;
		num15=r;
	}
	if(num12<num16){
		r=num12;
		num12=num16;
		num16=r;
	}
	if(num12<num17){
		r=num12;
		num12=num17;
		num17=r;
	}
	if(num12<num18){
		r=num12;
		num12=num18;
		num18=r;
	}
	if(num12<num19){
		r=num12;
		num12=num19;
		num19=r;
	}
	if(num12<num20){
		r=num12;
		num12=num20;
		num20=r;
	}
	if(num13<num14){
		r=num13;
		num13=num14;
		num14=r;
	}
	if(num13<num15){
		r=num13;
		num13=num15;
		num15=r;
	}
	if(num13<num16){
		r=num13;
		num13=num16;
		num16=r;
	}
	if(num13<num17){
		r=num13;
		num13=num17;
		num17=r;
	}
	if(num13<num18){
		r=num13;
		num13=num18;
		num18=r;
	}
	if(num13<num19){
		r=num13;
		num13=num19;
		num19=r;
	}
	if(num13<num20){
		r=num13;
		num13=num20;
		num20=r;
	}
	num21=num1+num2+num3;
	num22=num11+num12+num13;
	cout<< num21 <<" "<< num22 <<"\n";
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int min = 100000;
  int sum = 0;
  for (int i = 0; i < m.size(); i++) {
    cin >> m.at(i);
    sum += m.at(i);
    if (m.at(i) < min) min = m.at(i);
  }
  
  cout << N + (X-sum) / min << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_6_C2
{
    class Program
    {
        static void Main(string[] args)
        {
            Output output = new Output();

            //1フロア10部屋・3階建て　×4棟
            //入力1行目：全体の情報件数 n件
            //入力2行目：入居or退去情報「b棟f階r番目の部屋にv人」　→b f r v
            //b,f,r,vの初期値は0

            int n = int.Parse(Console.ReadLine());
            int[,,] build = new int[4, 3, 10];

            for (int i = 0; i < n; i++)
            {
                int[] info = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int b = info[0] - 1;
                int f = info[1] - 1;
                int r = info[2] - 1;
                int v = info[3];

                build[b, f, r] += v;
            }

            for (int b = 0; b < 4; b++)
            {
                output.InfoOutput(build, b);
            }
        }
    }

    public class Output
    {
        public void InfoOutput(int[,,] build, int b)
        {
            const string line = "####################";
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.Write(" " + build[b, i, j]);
                }
                Console.WriteLine();
            }
            if (b < 3)
            {
                Console.WriteLine(line);
            }
            else { }
        }
    }
}



Measured memory_bytes: 16220
#include <iostream>
#include<string.h>
using namespace std;

int main(){
  int n = 0,m = 0;
  cin >> n >> m;
  int A[n][m];

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

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] +=  A[i][j] *b[j];
    }
    cout << c[i] << endl;
  }

}



Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) { LLI res = 1; while (b > 0) { if (b & 1)res = res * a % MOD; a = a * a % MOD; b >>= 1; }return res; }
int main()
{
	cout << fixed << setprecision(10);
	LLI h;
	cin >> h;
	LLI tmp = h;
	LLI b = -1;
	while (0 < tmp)
	{
		b++;
		tmp >>= 1;
	}

	cout << (((LLI)2 << b) - 1);

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a,b string
	fmt.Scan(&a)
	fmt.Scan(&b)
	rune_a := []rune(a)
	rune_b := []rune(b)
	count := 0
	for i, v := range rune_a {
		if (v == rune_b[i]) {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<numeric>
int main() {
	using i64 = long long int;
	i64 n, q;
	scanf("%lld%lld", &n, &q);
	std::vector<i64> a(n), x(q), ans(q),index(q);
	i64 sum = 0;
	for (i64 i = n;i--;) {
		scanf("%lld", &a[i]);
		if (i % 2 == 0) {
			sum += a[i];
		}
	}
	for (auto &e : x) {
		scanf("%lld", &e);
	}
	std::iota(index.begin(), index.end(), 0);
	std::sort(index.begin(), index.end(),
		[&x](i64 l, i64 r) {return x[l] > x[r];});
	i64 l = 0, r = 0;
	for (const auto i : index) {
		while (r < n&&std::abs(a[l] - x[i]) >= std::abs(a[r] - x[i])) {
			sum -= a[r];
			sum += a[l];
			l += 1;
			r += 2;
		}
		ans[i] = sum;
	}
	for (const auto &e : ans) {
		printf("%lld\n", e);
	}
	return 0;
}


Measured memory_bytes: 4864
n, m = map(int, input().split())
st = [list(map(int, input().split())) for i in range(n)]
cp = [list(map(int, input().split())) for i in range(m)]
for s in st:
  ans = -1
  dmin = 10**9
  for i, c in enumerate(cp):
    dist = abs(c[0] - s[0]) + abs(c[1] - s[1])
    if dist < dmin:
      dmin = dist
      ans = i + 1
  print(ans)

Measured memory_bytes: 3064