akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string.h>
#include<queue>
using namespace std;
const int N = 1e5 + 7;
string x[3] = { "RGB","GBR","BRG" };
int y[3][N];
int main() {
	int n, k;
	while (cin >> n >> k) {
		cout << n - k + 1 << '\n';
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

const int N=300005;

int n,ans;
int s1[N],s2[N];
char s[N];

int main(){
	int i;
	scanf("%d",&n);
	scanf("%s",s+1);
	ans=n;
	for (i=1;i<=n;i++){
		s1[i]=s1[i-1];
		if (s[i]=='W') s1[i]++;
	}
	for (i=n;i>=1;i--){
		s2[i]=s2[i+1];
		if (s[i]=='E') s2[i]++;
	}
	for (i=0;i<=n;i++) ans=min(ans,s1[i]+s2[i+1]);
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int N;
  cin >> N;
  int tmp = 0;
  int ans = 0;
  rep(i, N) {
    cin >> tmp;
    while (tmp % 2 == 0) {
      tmp /= 2;
      ans++;
    }
  }
  cout << ans;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
  int a;
  int m;
  int num[100];
  int d;
  int f;
  int c;
} graph;

int count=1;
graph g[101];
void serch(int);

int main(){
  int i,j,n;
  //input
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&g[i].a,&g[i].m);
    g[i].d=g[i].f=g[i].c=0;
    for(j=0;j<g[i].m;j++) scanf("%d",&g[i].num[j]);
  }

  for(i=1;i<=n;i++) serch(g[i].a);

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",g[i].a,g[i].d,g[i].f);
  
  }
  return 0;
}

void serch(int x){
  int i;

  if(g[x].c==0){
    g[x].c++;
    g[x].d=count;
    count++;
  }

  for(i=0;i<g[x].m;i++) if(g[g[x].num[i]].c==0) serch(g[x].num[i]);

  if(g[x].f==0){
    g[x].f=count;
    count++;
  }

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,i,j,k;
    cin >> n >> k;
    int h[n],dp[n];
    for(i=0;i<n;++i) cin >> h[i];
    dp[0] = 0;
    for(i=1;i<n;++i) {
        dp[i]=1000000000;
        for(j=1;j<=min(k,i);++j) 
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=333333,mod=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
template<typename T>
inline void read(T &x){
	x=0;
	char ch=getchar();bool f=false;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,ans;
ll a[maxn];
int main(){
	read(n);
	FOR(i,1,n) read(a[i]);
	FOR(i,0,60){
		int cnt=0;
		FOR(j,1,n) if((a[j]>>i)&1) cnt++;
		ans=(ans+(1ll<<i)%mod*cnt%mod*(n-cnt))%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<pair<int,int>,string> item;
main(){
	int n,i,w,s,S;
	string f;
	for(;cin>>n,n;){
		vector<item> items;
		vector<int> num,result;
		for(i=0;i<n;i++)cin>>f>>w>>s,items.push_back(make_pair(make_pair(w,s),f)),num.push_back(i);
		S=99999;
		do{
			for(s=w=0,i=n-1;~i;i--){
				if(items[num[i]].first.second<w)break;
				w+=items[num[i]].first.first;
				s+=(i+1)*items[num[i]].first.first;
			}
			if(i<0&&s<S)S=s,result=num;
		}while(next_permutation(num.begin(),num.end()));
		for(i=0;i<n;i++)cout<<items[result[i]].second<<endl;
	}
}

Measured memory_bytes: 1228
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ans = 0
    while N:
        N, mod = divmod(N, K)
        #print(N, mod)
        ans += 1

    print(ans)
    #print(int(str(N), K))
    #return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main()
{
    int n, m;
    cin >> n >> m;
    int k = 0;
    int temp;
    while (m--)
    {
        cin >> temp;
        k += temp;
    }
    if (k  > n)
        cout << -1;
    else
    {
        cout << n - k;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    string s, t;
    cin>>n>>s>>t;
    vector<char> shit;
    forr(i,n)
    	shit.pb(s[i]), shit.pb(t[i]);
    forr(i, 2*n)
    	cout<<shit[i];
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3776
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> widthList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			widthList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for (int i = 0; i < widthList.size(); i++) {
			for (int k = 0; k < heightList.get(i); k++) {
				for (int j = 0; j < widthList.get(i); j++) {
					if (k == 0 || k == heightList.get(i) - 1 || j == 0 || j == widthList.get(i) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
}

Measured memory_bytes: 24584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static int n;
	
	 public static void main(String args[]) throws Exception {
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	        n = Integer.parseInt(br.readLine());
	        
	        for(int j=0;j<n;j++){
	        	String line = br.readLine();
	        	char[] s = line.toCharArray();
	        	Arrays.sort(s);
	        	char[] rev = new char[s.length];

	        	for(int i=0;i<s.length;i++){
	        		rev[i] = s[s.length-i-1];
	        	}
	        	int a = Integer.parseInt(String.valueOf(s));
	        	int b = Integer.parseInt(String.valueOf(rev));
	        	System.out.println(b-a);
	        }	 
	    }
}

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

int main(){
    int n,m; cin >> n >> m;
    if(n % 2) {
        rep(i,m) cout << 1+i << " " << n-1-i << endl;
        return 0;
    }
    int a = n/2-1;
    vector<vector<int>> ans(a);
    if(n%4 == 0) {
        rep(i,a/2) {
            ans[i].push_back(i+1);
            ans[i].push_back(n-1-i);
        }
        rep(i,a/2+1){
            ans[i+a/2].push_back(i+a/2+1);
            ans[i+a/2].push_back(n-2-a/2-i);
        }
    }else{
        rep(i,a){
            ans[i].push_back(i+1);
            ans[i].push_back(n-2-i);
        }
        rep(i,a/2) ans[i][1]++;
    }
    rep(i,m) cout << ans[i][0] << " " << ans[i][1] << endl;
}

Measured memory_bytes: 6884
import itertools
N = int(input())
root = []
for i in range(N):
    num= [int(i) for i in input().split()]
    root.append(num)
#ここまで入力

n_list = list(itertools.permutations(root))
dist1 = []
for i in n_list:
    dist = 0
    for j in range(1,N):
        dist = dist + ((i[j][0]-i[j-1][0])**2+(i[j][1]-i[j-1][1])**2)**(1/2)
    dist1.append(dist)
print(sum(dist1)/len(dist1))

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

int a[55];


int main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]!=i){
			sum++;
		}
	}
	if(sum>2){
		cout<<"NO"<<endl;
	}
	else {
		cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt[200],p[200],n,x;
int main(){
	int i,j,k,l;
	cin>>x>>n;
	for(i=1;i<=n;i++){
		cin>>p[i];cnt[p[i]]++;
	}
	for(i=0;x-i>=0||x+i<=100;i++){
		if(x-i>=0&&cnt[x-i]==0){
			cout<<x-i;return 0;
		}
		if(cnt[x+i]==0){
			cout<<x+i;return 0;
		}
	}
}

Measured memory_bytes: 3588
<?php
    fscanf(STDIN, "%d %d %d", $a, $b, $c);
    for($i = 1; $i <= $b; $i++){
        if(($a * $i) % $b == $c){
            echo "YES\n";
            exit;
        }
    }
    echo "NO\n";
    exit;
?>


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
 
const int MOD = 998244353;
 
map<VI, LL> M;
 
LL get(VI a)
{
if (M.count(a)) return M[a];
if (a.empty()) return M[a] = 1;
 
int x = a.back();
a.pop_back();
LL res = get(a);
if (x == 1) res *= 2;
res %= MOD;
 
a.PB(x);
 
FOR (len, 1, SZ(a))
{
FOR (k, 2, SZ(a) + 1)
{
if (k * len > SZ(a)) break;
VI b = a;
VI c(len, 1);
FOR (i, 0, len * k)
{
c[i%len] &= b.back();
b.pop_back();
}
 
reverse(ALL(c));
 
LL cur = get(c) * get(b);
res = (res + cur) % MOD;
}
}
 
return M[a] = res;
}
 
int main()
{
//freopen("in.txt", "r", stdin);
//ios::sync_with_stdio(false); cin.tie(0);
 
string s;
cin>>s;
VI a;
FOR (i, 0, SZ(s))
{
a.PB(s[i] - '0');
}
 
LL res = get(a);
cout<<res<<endl;
}

Measured memory_bytes: 7552
module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end
include Memoizable

def f(arr, i, s)
    return 0 if s < 0
    return 1 if s == 0
    return 0 if i < 0
    a, b = arr[i]
    sum = (0..b).map {|k| f(arr, i-1, s - a * k)}.inject(:+)
end

memoize :f

loop do
    n = gets.to_i
    break if n == 0
    arr = (1..n).map { gets.split.map(&:to_i) }
    g = gets.to_i
    g.times do
        p f(arr, arr.size - 1, gets.to_i)
    end
end



Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define mp make_pair
#define pb push_back
#define p(k) printf("%d ",k)
#define pl(k) printf("%lld ",k)
#define pn(k) printf("%d\n",k)
#define pln(k) printf("%lld\n",k)
#define ps(str) printf("%s",str)
#define s(k) scanf("%d",&k)
#define sl(k) scanf("%lld",&k)
#define ss(str) scanf("%s",str)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define ppi pair<int,int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ft first
#define sd second
#define count(x) __builtin_popcount(x)

using namespace std;

void test_case(){
	int n,i,j,mask;
	s(n);
	int a[n][n];
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			s(a[i][j]);
		}
	}
	vector<int>dp((1<<n)+5,0);
	dp[0] = 1;
	for(mask=1;mask<(1<<n);mask++){
		dp[mask] = 0;
		for(i=0;i<n;i++){
			if(count(mask) == i+1){
				for(j=0;j<n;j++){
					if(mask & (1<<j) && a[i][j]==1){
						//~ p(dp[mask^(1<<j)]);pn(mask^(1<<j));
						dp[mask] = (dp[mask]+dp[mask^(1<<j)])%M;
					}
				}
			}
		}
		//~ pn(dp[mask]);
	}
	pn(dp[(1<<n)-1]);
	return ;
}
signed main(){
	int t;
	t = 1;
	//~ s(t);
	while(t--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 8448
from heapq import heappush, heappop, heapify
n, m = map(int, input().split())
jobs = [list(map(int, input().split())) for _ in range(n)]
jobs.sort()
cur = 0
ans = 0
q = []
for i in range(1, m+1):
	while cur < n and jobs[cur][0] <= i:
		heappush(q, -jobs[cur][1])
		cur += 1
	if q:
		ans += -heappop(q)
print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if (1 <= A && A <= 9 && 1 <= B && B <= 9){
    cout << A * B << endl;
  }
  
  else{
    cout << -1 << endl;
  }
}

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

int main() {
	int n,flag = 0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	sort(a,a+n);
	for(int j=0;j<n-1;j++){
	    if(a[j+1]==a[j]){
	        flag = 1;
	        break;
	    }
	}
	if(flag)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	
	
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int a, b;cin>>a>>b;
	string ans;
	if(a<=0&&0<=b)ans="Zero";
	else if(b<0)ans=((b-a)%2==0?"Negative":"Positive");
	else ans="Positive";
	cout << ans << endl;
}


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

int main(){
    long long n;
    cin >> n;
    long long a[n+1];
    for(long long i=0; i<=n; i++){
        a[i]=1;
    }
    for(long long i=2; i<=n; i++){
        long long j=1;
        while(i*j<=n){
            a[i*j]++;
            j++;
        }
    }
    long long ans=0;
    for(long long i=1; i<=n; i++){
        ans+=i*a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int s;
    cin >> s;
    int before = s%10;


    s /= 10;

    for (int i = 0;i < 3;i++) {
        int now = s%10;
        if (now == before) {
            cout << "Bad" << endl;
            return 0;
        }
        before = now;
        s /= 10;
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  string s;
  cin >> s;
  if(s[0] == 'S'){
    cout << "Cloudy" << endl;
  }else if(s[0] == 'C'){
    cout << "Rainy" << endl;
  }else if (s[0] == 'R')
  {
    cout << "Sunny" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int a,b,c,d;
    double x;
    cin >> a >> b;
    c= a/b;
    d= a%b;
    x= (double)a/b;
    
    cout << c << " " << d << " " <<  fixed << setprecision(5) << x << endl;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;
using ii = long long;
int main()
{
    int n, w;
    cin >> n >> w;
    vector<ii> best(w + 1, 0);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        for (int j = w - a; j >= 0; --j) {
            best[j + a] = max(best[j + a], best[j] + b);
        }
    }
    cout << *max_element(all(best)) << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int> > minpq;

int main() {
    while (true) {
        int b; cin >> b;
        if (b == 0) break;
        b *= 2;
        int start = (int)sqrt(b);
        for(int i=start;i>0;i--){
            if(b%i==0){
                int c = b/i;
                if(i%2 != c%2){
                    if(i == 1){
                        cout << b/2 << " "<<1<<endl;
                        break;
                    }
                    cout << (c-i+1)/2 << " "<<i << endl;
                    break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2992
#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  return i!=n;
}

int main(){
  int i,n,A[10000],q,key,sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key)){
      sum++;
    }
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 2744
#include<stdio.h>

int main(void)
{
	int a,b, xa, xb, n;
	while(scanf( "%d", &n ) == 1 && n != 0){
		xa = xb = 0;
		while(n--){
			scanf( "%d %d",&a, &b);
			if(a > b)
				xa += a + b;
			else if(a < b)
				xb += a + b;
			else {
				xa += a;
				xb += b;
			}
		}
		printf( "%d %d\n", xa, xb);
	}
	return 0;
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B, M int

const MAX = 100000 * 2

func main() {
	sc.Split(bufio.ScanWords)

	A, B, M = nextInt(), nextInt(), nextInt()
	mina, minb, minc := MAX, MAX, MAX
	a := make([]int, A)
	b := make([]int, B)
	for i := 0; i < A; i++ {
		a[i] = nextInt()
		mina = minInt(mina, a[i])
	}
	for i := 0; i < B; i++ {
		b[i] = nextInt()
		minb = minInt(minb, b[i])
	}

	for i := 0; i < M; i++ {
		x, y, c := nextInt(), nextInt(), nextInt()
		minc = minInt(a[x-1]+b[y-1]-c, minc)
	}

	fmt.Println(minInt(minc, mina+minb))

}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define T() long long t;cin>>t;for(long long i=1;i<=t;i++)
#define INF (int)MAX_INT
#define INFS (int)MIN_INT
#define mod 1000000007
#define FOR(a, b, n) for(int a = b; a < n; a++)
#define REP(a,c, b) for(int a = c; a < b; a++)
#define FORD(a, b, c) for(int a = b; a >= c; a--)
#define REPD(a, c,b) for(int a = b-1; a >= c; a--)
#ifdef HOHOHO
#define DEBUG(x) cerr << #x << " : " << x << '\n'
#define DEBUGV(x) cerr << #x << " : { "; REP(_it, x.size()) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define DEBUGA(x, y) cerr << #x << " : { "; REP(_it, y) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define CHECKPOINT cerr << "OK LINE #" << __LINE__ << '\n'
#else
#define DEBUG(x) {}
#define DEBUGV(x) {}
#define DEBUGA(x, y) {}
#define PRINTF(...) {}
#define CHECKPOINT {}
#endif
#define RESET(a, b) memset(a, b, sizeof a)
#define EPS 1e-9
#define m_p make_pair
#define pb push_back
#define fi first
#define se second
#define RALL(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define ALL(x, y) x, x+y
#define SZ(x) ((int)x.size())
#define  pi(a)  pair<a, a> 
#define  vi(a)  vector<a> 
#define  vii(a) vector<pi(a)>
#define  vs vector<string>
template<class T> T sqr(T x){ return x*x; }
template<class T> T binPow(T p, int q, int MOD) {
    if(q == 1) return p % MOD;
    if(q & 1) return p*(binPow(p, q-1, MOD) % MOD) % MOD;
    else return sqr(binPow(p, q/2, MOD) % MOD) % MOD;
}
 
ll nxt() {
    ll temporaryVariable;
    cin >> temporaryVariable;
    return temporaryVariable;
}
const double PI = acos(-1.0);
#define MAXN 100001
const int G = 2e5 + 5;
 
 
 
int main(){
  ios::sync_with_stdio(false);
 
ll n=nxt(),ans=n-1;

REP(i,2,n){
    if(n%i==0){
        ans+=(n/i)-1;
    }
    else{
        ans+=n/i;
    }
}

cout<<ans<<endl;

    #ifdef HOHOHO   
    fprintf(stderr, "%.3lf\n", clock() / (double) CLOCKS_PER_SEC );
#endif
}
 



Measured memory_bytes: 3656
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();

		int arr[] = new int[N];
		int one = -1;
		for(int n=0;n<N;n++){
			arr[n] = sc.nextInt();
			if(arr[n] == 1) one = n;
			one = Math.min(one,N-one-1);
		}

		
			if(one<M || one > N-M-1){
				System.out.println((int)Math.ceil((float)(N-M)/(M-1))+1);	
			}
			else{
				System.out.println((int)(Math.ceil((one)/(float)(M-1)) + 
					Math.ceil((N-one-1-(one)%(float)(M-1))/(float)(M-1))));
			}
		

	}
}

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

int main() {

    int a,b,c,x,y;

    cin >> a >> b >> c >> x >> y;

    int ans = 0;
/*
    if(a < c && b < c){
        ans =  a*x + b*y;
    }
    else if(a>c && b>c){
        for(int i=0; i<max(x,y); i++){
            ans += c*2;
        }
    }
    else{*/
        int p=0;
        int tx = x , ty = y;
        for(int i=0; i<min(x,y); i++){
            p += c*2;
            tx--;
            ty--;
        }
        if(tx > 0){
            p += a*tx;
        }
        else if(ty > 0){
            p += b*ty;
        }
        int o = 0;
        for(int i=0; i<max(x,y); i++){
            o += c*2;
        }
        int cy = a*x + b*y;
        ans = min(min(p,o),cy);
    //}

    cout << ans << endl;

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int C[10];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,4) {
		cin>>x;
		C[x]++;
	}
	
	if(min({C[1],C[4],C[7],C[9]})==1) {
		cout<<"YES"<<endl;
	}
	else {
		cout<<"NO"<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	long long x = 0, y = 0;
	for (int i = 1; i <= b; i++) x = x*10+a;
	for (int i = 1; i <= a; i++) y = y*10+b;
	printf("%lld\n", x>y?x:y);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);

  int t[MAX], x[MAX], y[MAX];
  t[0] = x[0] = y[0] = 0;
  rep(i, 1, n+1) scanf("%d %d %d", &t[i], &x[i], &y[i]);

  int ok = 1;
  rep(i, 1, n+1) {
    int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
    int time = t[i] - t[i-1];
    if ( time < dist ) ok = 0;
    if ( (time - dist) % 2 == 1 ) ok = 0;
  }
  printf( ok ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, S;
  cin >> N >> S;
  int a[N];
  FOR(i,0,N) cin>>a[i];
  int sum = 0, ans = 1e9;
  int l = 0, r = 0;
  // [l, r)の和をみる
  while(r <= N && l < N) {
    while(r < N && sum < S) {
      sum += a[r];
      r++;
    }
    if(sum >= S) ans = min(ans, r - l);
    sum -= a[l];
    l++;
  }
  cout << (ans != 1e9 ? ans : 0) << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int lens = s.length();
  int lent = t.length();
  if(lens + 1 != lent ){
    cout << "No" << endl;
    return 0;
  }
  bool flag = true;
  rep(i,lens) flag &= s[i] == t[i];
  cout << (flag ? "Yes" : "No") << endl;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<vector<ll>> f(n, vector<ll>(10));
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }

  vector<vector<ll>> p(n, vector<ll>(11));
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < 11; ++j) {
      cin >> p[i][j];
    }
  }

  ll ans = -1e18;
  for (ll bit = 1; bit < (1<<10); ++bit) {
    ll sum = 0;
    for (ll i = 0; i < n; ++i) {
      ll c = 0;
      for (ll j = 0; j < 10; ++j) {
        if (bit & (1<<j) && f[i][j]) ++c;
      }
      sum += p[i][c];
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
int n , k , a[100000],dp[100000];
int f(int i = 0)
{
    if(i == n-1) return 0;
    if( dp[i] != -1 ) return dp[i];
    dp[i] = 1e9;
    for(int j=1;j<=k;++j)
      if( i+j < n )
        dp[i] = min( dp[i] , f(i+j) + abs(a[i]-a[i+j]) );
    //cout << dp[i] << ' ' << i << endl;
    return dp[i];
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> k;
    for(int i=0;i<n;++i)
        cin >> a[i];
    cout << f();
    return 0;
}

Measured memory_bytes: 5760
import numpy as np
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
 
num_str = input()
 
num_list = [int(num_str[i]) for i in range(len(num_str))]
 
num_sum = sum(num_list)
 
if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 28656
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/8;

template <class T>
struct FenwickTree {
    int n;
    vector<T> x;
    FenwickTree(int n_ = 0) : n(n_), x(n_+1){
        fill(x.begin(), x.end(), 0);
    }
    T sum(int r){
        T S = 0;
        for (; r >= 0; r = (r&(r+1))-1) S += x[r];
        return S;
    }
    T sum(int l, int r){
        if(l >= r) return 0;
        else return l==0 ? sum(r-1) : sum(r-1) - sum(l-1);
    }
    void add(int k, T a){
        for (; k < n; k |= k+1) x[k] += a;
    }
    void set(int k, T a){
        int x = sum(k, k+1);
        add(k, a-x);
    }
    vi to_a(int l = -1, int r = -1){
        if(l == -1) l = 0;
        if(r == -1) r = n;
        vi res(r-l);
        range(i,l,r) res[i-l] = sum(i,i+1);
        return res;
    }
};

int main(){
    fastios();
    int n,q;
    cin >> n >> q;
    FenwickTree<ll> t(n);
    rep(i,q){
        int c,x,y;
        cin >> c >> x >> y;
        x--;
        if(c == 0) t.add(x,y);
        else cout << t.sum(x,y) << endl;
    }
}

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8){
        print("Yay!");
    }else{
        print(":(");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long gojo(long a, long b){
  if(a % b)
    gojo(b, a%b);
  else
    return b;
}
int main(){
  long a, b, c, d;  scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
  long ans = b - a + 1;
  ans = ans - ((b/c) - (a-1)/c);
  ans = ans - ((b/d) - (a-1)/d);
  long g = c/gojo(c, d)*d;
  ans = ans + ((b/g) - (a-1)/g);
  printf("%ld\n", ans);
  return 0;
}


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

using namespace std;

int N, M;
char S[55][55];
bool F[55][55];
bool V[4][55][55];
int sy, sx, sd;
int gy, gx;

const string dir = "^>v<";
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};

void init()
{
  memset(F, false, sizeof(F));
  memset(V, false, sizeof(V));
  for(int i = 0; i < 55; i++) {
    for(int j = 0; j < 55; j++) S[i][j] = '#';
  }
}

int cnt()
{
  int ret = 0;
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= M; j++) {
      if(F[i][j]) ret++;
    }
  }
  return ret;
}

int solve()
{
  int y = sy, x = sx, d = sd;
  while(!V[d][y][x]++) {
    F[y][x] = true;
    if(y == gy && x == gx) return cnt();
    int rhd = (d + 1) % 4, rhy = y + dy[rhd], rhx = x + dx[rhd];
    if(S[rhy][rhx] == '#') {
      if(S[y+dy[d]][x+dx[d]] == '#') d = (d + 3) % 4;
      else y += dy[d], x += dx[d];
    } else {
      y = rhy, x = rhx, d = rhd;
    }
  }
  return -1;
}

int main()
{
  cin >> N >> M;
  init();
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= M; j++) {
      cin >> S[i][j];
      if(dir.find(S[i][j]) != string::npos) {
	sy = i, sx = j, sd = dir.find(S[i][j]);
      } else if(S[i][j] == 'G') {
	gy = i, gx = j;
      }
    }
  }
  cout << solve() << endl;

  return 0;
}

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

string field[50];
bool isUsed[50][50];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int black,white;
int w,h;

void dfs(int x,int y){
  isUsed[y][x]=true;
  if(field[y][x] == 'W'){
    white++;
  }else if(field[y][x] == 'B'){
    black++;
  }else{
    for(int i=0 ; i < 4 ; i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx >= 0 && ny >= 0 && nx < w && ny < h && !isUsed[ny][nx]){
	dfs(nx,ny);
      }
    }
  }
}
int solve(int x,int y){
  black=0,white=0;
  for(int i=0 ; i < h ; i++){
    for(int j=0 ; j < w ; j++){
      isUsed[i][j]=false;
    }
  }
  dfs(x,y);
  if(black != 0 && white != 0){
    return 3;
  }else if(black == 0 && white != 0){
    return 1;
  }else if(black != 0 && white == 0){
    return 0;
  }
  return 3;
}
int main(){
  
  while(1){
    cin >>w>>h;
    if(w+h == 0)break;
    for(int i=0 ; i < h ; i++)cin >>field[i];
    int ans[3]={0,0,0};
    for(int i=0 ; i < h ; i++){
      for(int j=0 ; j < w ; j++){
	if(field[i][j] == '.'){
	  ans[solve(j,i)]++;
	}
      }
    }
    cout <<ans[0]<<" "<<ans[1]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1332
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong(); //next(文字列), nextDouble, nextLine(1行)とか
    long y = sc.nextLong();
    long z = x / y;
    x = x - y*z;
    if (Math.abs(x-y) < x){
      x = Math.abs(x-y);
    }
    
    System.out.println(x);
    
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	string s;
	cin >> a >> b;
	for (int i = 1; i <= a; i++)
		{
			cin >> s;
			cout << s << endl << s << endl;
		}
	return 0;	
 } 

Measured memory_bytes: 256
/*
整数 n を入力し、深さ n の再帰呼び出しによって作成されるコッホ曲線の頂点の座標を出力するプログラム
*/
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535897932     /*　円周率　*/

/* ある点のx座標、y座標を記憶する構造体　*/
typedef struct{

  double x;
  double y;
  
}XY;

void koch(int, XY, XY);

int main()
{
  int n;
  XY p1 = {0.0, 0.0}, p2 = {100.0, 0.0};

  scanf("%d", &n);

  /* コッホ曲線の各頂点の座標(x,y)を計算し、出力　端点は(0,0) , (100,0) */
  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);
  
  return 0;
}

/* 深さnの再帰呼び出しによって作成されるコッホ曲線の頂点を出力する関数　*/
void koch(int n, XY p1, XY p2)
{
  XY s, t, u;

  if( n == 0 )
    return;

  /* 線分 p1 -> p2 を３等分する２点 s,t　とs,tを頂点とする正三角形の残りの頂点uを求める */
  s.x = ( 2*p1.x + p2.x )/3;
  s.y = ( 2*p1.y + p2.y )/3;
  t.x = ( p1.x + 2*p2.x )/3;
  t.y = ( p1.y + 2*p2.y )/3;
  u.x = (t.x - s.x)*cos(PI/3) - (t.y - s.y)*sin(PI/3) + s.x;
  u.y = (t.x - s.x)*sin(PI/3) + (t.y - s.y)*cos(PI/3) + s.y;

  koch(n-1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, p2);
  
}



Measured memory_bytes: 2108
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

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

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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
#define For(i,n) for(int i=0;i<n;i++)

int main(){
    int t,i,n,j,r;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>r;
    if(n>=10)
        cout<<r;
    else{
        cout<<((r+100*(10-n)));
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));

	Vec memo(n);
	rep(i, n) memo[i] = c.end() - upper_bound(all(c), b[i]);
	repr(i, n - 1) memo[i] += memo[i + 1];

	ll ans = 0;
	rep(i, n) ans += memo[upper_bound(all(b), a[i]) - b.begin()];
	co(ans);

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  if (n == 1)
    cout << 1 << endl;
  
  else {
    int cnt = 0, res = 0;
    for (int i = 1; i <= n; i++) {
      int c = 0;
      int r = i;
      while (r % 2 == 0) {
        r /= 2;
        c++;
      }
    
      if (cnt < c) {
        cnt = max(cnt, c);
        res = i;
      }     
    }
  
    cout << res << endl;
  }
  
  return 0;
}      

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

int main()
{
    std::string s;
    long long k;
    std::cin>>s>>k;

    char res = '1';
    for(int i=0;i<(int)s.size() && i<k;i++){
        if(s[i] != '1'){
            res = s[i];
            break;
        }
    }
    std::cout<<res<<std::endl;
}

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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n;
	
	cin >> n;
	
	cout << (n+1)/2;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && B != C)
  {
    cout << "Yes" << endl;
  }
  else if (A == C && A != B)
  {
    cout << "Yes" << endl;
  }
  else if (B == C && A != B)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, v, b, w, t = map(int, read().split())
if a <= b:
    print('YES' if a + (v * t) >= b + (w * t) else 'NO')
else:
    print('YES' if a - (v * t) <= b - (w * t) else 'NO')

Measured memory_bytes: 9208
local N = tonumber(io.read("*line"))
local judge = {}

for i = 1, N do
    local line = io.read("*line")
    judge[#judge + 1] = line
end

local count = {
    AC = 0,
    WA = 0,
    TLE = 0,
    RE = 0
}

for _, result in ipairs(judge) do
    count[result] = count[result] + 1
end

print("AC x ", count.AC)
print("WA x ", count.WA)
print("TLE x ", count.TLE)
print("RE x ", count.RE)


Measured memory_bytes: 3332
def main():
    S = input()

    cnt1 = 0

    # 先頭を1にする場合
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s == '0':
                cnt1 += 1
        else:
            if s == '1':
                cnt1 += 1

    cnt2 = 0
    # 先頭を0にする場合
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s == '1':
                cnt2 += 1
        else:
            if s == '0':
                cnt2 += 1

    print(min(cnt1,cnt2))



main()

Measured memory_bytes: 40944