akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a[100010];
map<int,int> mpa;


int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mpa[a[i]]++;
    }
    m=0;
    for(auto it=mpa.begin();it!=mpa.end();++it){
        m+=int(it->second)%2;
    }
    C m E;
    
    
}

Measured memory_bytes: 5760
def solve():
    H, W = map(int, input().split())
    c = []
    for _ in range(H):
        c.append(list(map(int, input().split())))

    dp = [[0] * W for _ in range(H)]

    for x in range(H):
        dp[x][0] = 1 if c[x][0] == 0 else 0
    for y in range(W):
        dp[0][y] = 1 if c[0][y] == 0 else 0

    for x in range(H-1):
        for y in range(W-1):
            if c[x+1][y+1] == 0:
                dp[x+1][y+1] = min([dp[x][y], dp[x][y+1], dp[x+1][y]]) + 1

    print(max([max(item) for item in dp])**2)


if __name__ == '__main__':
    solve()

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli n;
lli c[e5];
lli dp[e5];
lli mem[e5];

int main(){
  cin >> n;
  for(lli i = 1;i <= n;i++) cin >> c[i];
  dp[0] = 1;
  for(lli i = 1;i <= n;i++){
    if(c[i-1] != c[i]){
      mem[c[i]] += dp[i-1];
      mem[c[i]] %= mod;
      dp[i] = mem[c[i]];

    }else{
      dp[i] = dp[i-1];
    }

  }
  cout << dp[n] << endl;

}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, k, q;
  vector<int> a, sorted;
  Solver(LL n) : n(n), a(n){};

  void solve() {
    cin >> k >> q;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sorted = a;
    sort(sorted.begin(), sorted.end());
    int ans = INF;
    for (int i = 0; i < n; ++i) {
      //取り除かれる最小値Yを, aでi番目に小さい要素に固定する
      int Y = sorted[i];
      //Y未満の数で区切られた区間ごとに取り除ける数を列挙
      vector<int> removable;
      vector<int> tmp;
      for (int j = 0; j <= n; ++j) {
        if (j == n or a[j] < Y) {
          sort(tmp.begin(), tmp.end());
          removable.insert(removable.end(), tmp.begin(), tmp.begin() + max<int>(0, tmp.size() - (k - 1)));
          tmp.clear();
        } else {
          tmp.push_back(a[j]);
        }
      }
      sort(removable.begin(), removable.end());
      if (removable.size() >= q) {
        ans = min(ans, removable[q - 1] - Y);
      }
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
int main() {
	string s;
	cin>>s;
	int n=s.length();
//	if(n%2==0){
//		int t=n%2;
	int cnt=0;
	for(int i=0; i<n; i++) {
		if(s[i]==s[n-1-i]) {
			continue;
		} else {
			cnt++;
		}
	}
	cnt/=2;
	printf("%d",cnt);
//	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n+1,0);
    vector<int> ans(n+1,0);
    FOR(i,1,n+1) cin >> v[i];

    vector<int> cnt(100+1,0);

    int count = 0;
    for(auto i = n;i > 0; i--) {
        //cerr << i << endl;
        if (i > n/2) {
            if (v[i] == 1) {
                ans[i] = 1;
                count++;
            }
        } else if (i > 100) {
            int c = 0;
            for(auto j = i;j < n+1;j += i) {
                c += ans[j];
            }
            if (c % 2 != v[i]) {
                ans[i] = 1;
                count++;
            }

        } else {
            if (v[i] != (cnt[i] % 2)) {
                ans[i] = 1;
                count++;
            }
            
        }
        if (ans[i] == 1){
            for(auto j = 1;j <100+1 && i >= j;j++) {
                if (i % j == 0) cnt[j]++;
            }
        }
    }

    cout << count << endl;
    FOR(i,1,n+1) {
        //cerr << cnt[i] << endl;
        if(ans[i] == 1) cout << i << " ";
    }


    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll A[100010];
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  ll sum=0;
  rep(i,N) sum+=A[i];
  rep(i,(N+1)/2){
    sum-=A[i*2]*2;
  }
  ll x=-sum;
  cout<<x<<" ";
  rep(i,N-1){
    x=2*A[i]-x;
    cout<<x<<" ";
  }
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 2048
def a(v1,v2):
    if v1[0]!=v2[0]:
        return (v2[1]-v1[1])/(v2[0]-v1[0])
    else:
        return (v2[1]-v1[1])*(10**10)

def dlt(p,v,sign):
    while len(p)>2:
        if sign*(a(v[p[-3]],v[p[-2]])-a(v[p[-2]],v[p[-1]]))<0:
            del p[-2]
        else:
            break
    return p

def convex(v,n):
    d,u=[],[]
    for i in range(n):
        d=dlt(d+[i],v,1)
        u=dlt(u+[i],v,-1)
    return n-len(set(d+u))

while 1:
    n=int(raw_input())
    if n==0:
        break
    v=[map(float,raw_input().split(',')) for i in range(n)]
    v=sorted(sorted(v,key=lambda x:x[1]))
    print convex(v,n)

Measured memory_bytes: 6476
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define INF 10000000
#define WHITE 0
#define BLACK 1
 
int main(){
  int i,j,n,count=0,v,c,v1,c1,u,mincost;
  int G[N][N],color[N],d[N],pi[N];
 
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      G[i][j] = -1;
    }
  }
    scanf("%d",&n);
 
    for(i = 0;i < n;i++){
      scanf("%d%d",&v,&c);
      for(j = 0;j < c;j++){
    scanf("%d%d",&v1,&c1);
    G[v][v1] = c1;
      }
    }
 
    for(i = 0;i < n;i++){
      color[i] = WHITE;
      pi[i] = -1;
      d[i] = INF;
    }
 
    d[0] = 0;
 
    while(1){
      mincost = INF;
      for(i = 0;i < n;i++){
    if(color[i] != 2 && d[i] < mincost){
      mincost = d[i];
      u = i;
    }
      }
      if(mincost == INF) break;
      color[u] = 2;
 
      for(i = 0;i < n;i++){
    if(G[u][i] != -1 && color[i] != 2 && (G[u][i] + d[u]) < d[i]){
      pi[i]= u;
      d[i] = G[u][i] + d[u];
      color[i] = BLACK;
    }
      }
    }
 
    for(i = 0;i < n;i++){
      printf("%d %d\n",i,d[i]);
    } 
    return 0;
 
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		scan.close();
		long A = Long.parseLong(a);
		long B = Long.parseLong(b);
		long K = Long.parseLong(c);

		if(K == 0) {
		System.out.print(A);
		System.out.print(" ");
		System.out.print(B);
		}
		if(A + B < K) {
		System.out.print(0+" "+0);
		K = 0;
		}
		if(K != 0) {
		if(A < K) {
		System.out.print(0 + " ");
		K = K-A;
		}else{
		System.out.print(A-K+" "+B);
		K = 0;
		}
		}

		if(K > 0) {
		System.out.print(B-K);
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string S;
    cin>>S;

    bool z=false;
    rep(i,S.size()){
        if(S[i]=='C')z=true;
        if(z&&S[i]=='F'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    



}


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

int main(int argc, char *argv[]) {
	int num_of_A_city = 0;
	int num_of_B_city = 0;

	std::cin >> num_of_A_city;
	std::cin >> num_of_B_city;

	int point_A = 0;
	int point_B = 0;

	std::cin >> point_A;
	std::cin >> point_B;

	std::vector<int> a_points;
	std::vector<int> b_points;
	int point = 0;
	for (int i = 0; i < num_of_A_city; i++) {
		std::cin >> point;
		a_points.push_back(point);
	}
	a_points.push_back(point_A);
	for (int j = 0; j < num_of_B_city; j++) {
		std::cin >> point;
		b_points.push_back(point);
	}
	b_points.push_back(point_B);

	std::sort(a_points.begin(), a_points.end());
	std::sort(b_points.begin(), b_points.end());

	int max_a = *(a_points.end() - 1);
	int min_b = *(b_points.begin());
	
	if ((point_B - point_A) >= 1
	 && (min_b - max_a) >= 1) {
		std::cout << "No War" << std::endl;
	} else {
		std::cout << "War" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%3==0 or a[i]%5==0:
      s=0
    else:
      s=-1
      break
if s==-1:
  print('DENIED')
else:
  print('APPROVED')

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

int f(int i, int n, int h[], int dp[]) {
	if(i>=n)
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	
	if(i==n-1)
	{
		dp[i]=0;
		//return dp[i];
	}
	else if(i==n-2)
	{
		dp[i] = abs(h[i]- h[i+1]) + f(i+1, n, h, dp);
	}
	else
	{
		dp[i] = (abs(h[i]- h[i+1]) + f(i+1, n, h, dp)) < (abs(h[i]- h[i+2]) + f(i+2, n, h, dp)) ? (abs(h[i]- h[i+1]) + f(i+1, n, h, dp)) : (abs(h[i]- h[i+2]) + f(i+2, n, h, dp));
	}
	return dp[i];
}

int main() {
	int n;
	cin>>n;
	int h[n], dp[n];
	for(int i=0; i<n; ++i) {
		cin>>h[i];
		dp[i] = -1;
	}
	cout<<f(0, n, h, dp)<<endl;
	return 0;
}

Measured memory_bytes: 13712
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[1] = 1;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--)
	{
		ll n,W;
		cin >> n >> W;
		vector< pll >a(n);
		for(int i=0;i<n;i++)
			cin >> a[i].x >> a[i].y;
		ll dp[n+1][W+1];
		for(int i=0;i<=n;i++)
			dp[i][0] = 0;
		for(int i=0;i<=W;i++)
			dp[0][i] = 0;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=W;j++)
			{
				if(j<a[i-1].x)
					dp[i][j] = dp[i-1][j];
				else
					dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1].x] + a[i-1].y);
			}
		cout << dp[n][W] << "\n";
	}
}


Measured memory_bytes: 79232
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++)
        {
            var array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //2回で元に戻る
            if (array[0] - array[1] - array[2] < 0 || (array[0] - array[1] - array[2]) % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 15404
#include<bits/stdc++.h>
using namespace std;
int stone[100000+5];
int dp[100000+5];

int main(int argc, char const *argv[])
{
	int N, K;
	while(cin >> N >> K) {
		memset(stone, 0, sizeof(stone));
		memset(dp, 0, sizeof(dp));
		for(int i=1; i<=N; i++){
			cin >> stone[i];
		}
		dp[1] = 0;
		dp[2] = abs(stone[2] - stone[1]);
		for(int i=3; i<=N; i++){
			dp[i] = 1e9;
			for(int j=min(i-1,K); j>0; j--){
				int temp = dp[i-j] + abs(stone[i] - stone[i-j]);
				if(dp[i] > temp){
					dp[i] = temp;
				}
			}
			//dp[i] = min(dp[i-2] + abs(stone[i] - stone[i-2]), dp[i-1] + abs(stone[i] - stone[i-1]));
		}
		cout << dp[N] << endl;  	
	}
	return 0;
}

Measured memory_bytes: 4368
from itertools import accumulate
import sys

# 整数Xのときの[高橋くんが上から取る連続枚数]が、k枚以下（k+1以上にはならない）かどうか判定する
def check(X, k):
    # 青木くんがLより先にRを取れれば、条件を満たす
    L, R = As[N-2*k-1], As[N-k-1]
    return abs(L-X) > abs(X-R)

N, Q = map(int, input().split())
As = list(map(int, input().split()))
Xs = [(int(input()), iX) for iX in range(Q)]

if N == 2:
    print('\n'.join(map(str, [As[-1]]*Q)))
    sys.exit()

numT = (N+1) // 2  # 高橋くんが取るカードの枚数
Ascs = As[::2] if N % 2 else As[1::2]
Descs = As[::-1]
accAscs = [0] + list(accumulate(Ascs))
accDescs = [0] + list(accumulate(Descs))

# 高橋くんが上から連続k枚を取る場合のスコア
scores = [0] * (numT+1)
for k in range(1, numT+1):
    scores[k] = accDescs[k] + accAscs[numT - k]

# Xの降順で処理する
anss = [0] * Q
k = 1
for X, iX in sorted(Xs, reverse=True):
    # [k枚以下]になる最小のkを求める
    while not check(X, k):
        k += 1
    anss[iX] = scores[k]

print('\n'.join(map(str, anss)))


Measured memory_bytes: 41204
N = int(input())

map = {}
count = 0
for i in range(0, N):
    strings = list(input())
    strings.sort()
    key = "".join(strings)
    if not key in map:
        map[key] = 1
    else:
        map[key] += 1

count = 0
for v in map.values():
    count += v * (v - 1) // 2
    
print(count)


Measured memory_bytes: 17932
#include<bits/stdc++.h>
using namespace std;
long long a,ans;
int Get(int x)
{
	int re=0;
	for(int s=1;s<sqrt(x);s++)
	{
		if(x%s==0)re+=2;
	}
	if((int)sqrt(x)==sqrt(x))re++;
	return re;
}
int main()
{
	cin>>a;
	for(int s=1;s<=a;s+=2)
	{
		if(Get(s)==8)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
throw = []
blow = 0
cnt = 0
n,h = map(int, input().split())
for _ in range(n):
  a,b = map(int, input().split())
  blow = max(blow,a)
  throw.append(b)
throw.sort()
while h>0 and throw and throw[-1]>blow:
  h -= throw.pop()
  cnt += 1
if h > 0:
  cnt += h//blow + (h%blow>0)
print(cnt)

Measured memory_bytes: 7392
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50;

int n,a[N],win;

int main(int argc,char *argv[]){
	//freopen("dat.in","r",stdin); 
	read(n); 
	rep(i,1,n)read(a[i]); 
	sort(a+1,a+n+1,greater<int>()); 
	rep(i,1,n){
		if(i+1>a[i+1]){
			win|=(a[i]-i)&1;
            if(win)break;
			rep(j,i+1,n)if(a[j]==i)win^=1;else break;
			break;
		}
	}
	puts(win?"First":"Second"); 
}


Measured memory_bytes: 640
# Problem A: ?¬??????????

require 'scanf'

def scanf(format)
  line = gets
  if line
    line.scanf(format)
  else
    []
  end
end

while true
  n, p = scanf('%d %d')
  break if n == 0 && p == 0

  bowl = p
  players = Array.new(n, 0)
  winner = nil

  while true
    finish = false

    players.each_with_index do |nstone, i|
      if bowl >= 1
        bowl -= 1
        players[i] += 1
      else
        players[i] = 0
        bowl += nstone
      end
      
      if bowl == 0 && players[i] == p
        winner = i
        finish = true
        break
      end
    end

    break if finish
  end

  puts winner
end

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

int pow2[13];

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int ans[2];
    ans[0] = ans[1] = 0;
    
    rep(turn, 2){
        int now = 0;
        rep(i,n){
            now += a[i];
            if(i % 2 == turn){
                if(now > 0) continue;
                ans[turn] += 1 - now;
                now = 1;
            }else{
                if(now < 0) continue;
                ans[turn] += 1 + now;
                now = -1;
            }
        }
    }
    
    cout << min(ans[0], ans[1]) << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m, k;std::cin >> n >> m >> k;
  for(int a=0;a<=n;a++){
    for(int b=0;b<=m;b++){
      if(a*m+b*n-2*a*b==k){
        std::cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  std::cout << "No" << '\n';
}


Measured memory_bytes: 384
#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 time;
    cin >> time;
    rep(t,time){
        int base[3], old[3];
        int out = 0, point = 0;
        rep(i,3) base[i] = 0;
        string s;
        while(cin >> s){
            if(s == "HIT"){
                old[0] = base[0];
                old[1] = base[1];
                old[2] = base[2];
                if(old[0]) base[1] = 1;
                if(old[1]) base[2] = 1;
                if(old[2]) point++;
                base[0] = 1;
            }
            if(s == "HOMERUN"){
                point++;
                if(base[0]) point++;
                if(base[1]) point++;
                if(base[2]) point++;
                base[0] = 0;
                base[1] = 0;
                base[2] = 0;
            }
            if(s == "OUT"){
                out++;
                if(out == 3) break;
            }

        }
        cout << point << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int compare(const void *a,const void *b){
  return *(int *)b - *(int *)a;
}

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int x[100000];
  for(int i=0;i<m;i++){
    scanf("%d",&x[i]);
  }
  qsort(x,m,sizeof(int),compare);
  int dx[100000];
  int maxd = x[0] - x[m-1];
  for(int i=0;i<m-1;i++){
    dx[i] = x[i] - x[i+1];
  }
  qsort(dx,m-1,sizeof(int),compare);
  for(int i=0;i<n-1;i++){
    maxd -= dx[i];
  }
  if(maxd < 0) maxd = 0;
  printf("%d",maxd);
  return 0;
}


Measured memory_bytes: 1268
fun main(args: Array<String>) {
    val r = readInputLine().toInt()
    
    if (r < 1200) {
        println("ABC")
    } else if (r < 2800) {
        println("ARC")
    } else {
        println("AGC")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

int main(){
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;

}

Measured memory_bytes: 256
n = int(input())
print(((n - 1) // 1000 + 1) * 1000 - n)
# for ttt in range(int(input())):
# 	#n = int(input())
# 	#l = list(map(int, input().split()))
# 	# a, b, n = map(int, input().split())
# 	# x = 0
# 	# if a > b:
# 	# 	a, b = b, a
# 	# while b <= n:
# 	# 	a, b = b, a + b
# 	# 	x += 1
# 	# print(x)
# 	s = input()
# 	if len(s) <= 10:
# 		print(s)
# 	else:
# 		print(s[0] + str(len(s) - 2) + s[-1])

Measured memory_bytes: 61572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int A[1010], B[1010];
	for (int i = 0; i < N; ++i)cin >> A[i] >> B[i];
	int count = 0;
	for (int i = 0; i < N; ++i) {
		if (H <= A[i] && W <= B[i])count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    int tmp=7400000;
    vector<bool> prime(tmp,false);
    int t=0;
    for(i=n;i<tmp;i++)
      if(prime[i]==false){
	t++;
	if(t==m+1)break;
	for(j=1;i*j<tmp;j++)
	  prime[i*j]=true;
      }
    cout<<i<<endl;
  }
}

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

int main()
{
     int N,sum=0,maxi=0;
    int arr[100000];
    cin>>N;
    for (int i=0; i<N; i++){
        cin>>arr[i];
    }
    int i;
    for ( i=0; i<N-1; i++){
        if (arr[i] >= arr[i+1]){
            sum +=1;
            if (maxi < sum){
                maxi =sum;
            }
        }else{
            sum =0;
            continue;
        }
    }
    cout<<maxi;

}




Measured memory_bytes: 640
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=200005;
int n,m,empty; 
int a[maxn],cnt[maxn];
int tree[maxn*8],leaf[maxn];

void get_leaf(int l,int r,int node){
	tree[node]=0;
	if(l==r){
		leaf[l]=node;
		return;
	}
	int mid=(l+r)>>1;
	get_leaf(l,mid,node*2);
	get_leaf(mid+1,r,node*2+1);
}

void update(int node,int val){
	node=leaf[node];
	tree[node]+=val;
	while(node){
		node>>=1;
//		tree[node]=tree[node*2]+tree[node*2+1]; 
	}
}

int query(int node){
	node=leaf[node];
	int sum=0;
	while(node){
		sum+=tree[node];
		node>>=1;
	}
	return sum;
}

int main(){
	scanf("%d%d",&n,&m);
	empty=n;
	get_leaf(1,n,1);
	REP(i,n){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		int pos=a[i]-cnt[a[i]]+1;
		if(pos>=1){
			if(query(pos)==0)empty--;
			update(pos,1);
		}
	}
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		int pos=a[x]-cnt[a[x]]+1;
		if(pos>=1){
			update(pos,-1);
			if(query(pos)==0)empty++;
		}
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		pos=a[x]-cnt[a[x]]+1;
		if(pos>=1){
			if(query(pos)==0)empty--;
			update(pos,1);
		}
		printf("%d\n",empty);
	} 
	return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	vector<int> as;
	map<int, int> counts;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		counts[a] += 1;
		as.push_back(a);
	}

	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());

	bool ok = false;

	if(as.size() == 3) {
		int x = as[0];
		int y = as[1];
		int z = as[2];
		ok = ((x ^ y) == z) && (n % 3 == 0) && (counts[x] == counts[y]) && (counts[y] == counts[z]);
	}
	if(as.size() == 2) {
		int x = as[0];
		int y = as[1];
		ok = (x == 0) && (n % 3 == 0) && (counts[y] == counts[x] * 2);
	}
	if(as.size() == 1) {
		int x = as[0];
		ok = (x == 0);
	}

	printf("%s\n", ok ? "Yes" : "No");

	return 0;
}

/* waffle */


Measured memory_bytes: 4216
H,W = map(int,input().split())
SS = []
for i in range(H):
    SS.append(list(input()))
    
def seekindices(i,j,H,W):
    seeks = []
    for x in [-1,0,1]:
        for y in [-1,0,1]:
            if i + x >= 0 and i + x < H:
                if j + y >= 0 and j + y < W:
                    seeks.append((i+x,j+y))
    return(seeks)

AS = []

for h in range(H):
    s = SS[h]
    
    a = []
    
    for w in range(W):
        if s[w] == '.':
            seeks = seekindices(h,w,H,W)
            count = 0
            for zahyo in seeks:
#                 print(zahyo)
                if SS[zahyo[0]][zahyo[1]] == '#':
                    count += 1
            a.append(str(count))
        else:
            a.append(s[w])
    AS.append(a)
                    
for a in AS:
    print("".join(a))

        
        
        

Measured memory_bytes: 41196
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = (int) 2e5+99;
int n, a[N];
ll sol;
unordered_map<int, int> mapa;
int main() {
    IOS; cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    for(int i=0; i<n; ++i) {
        sol += (ll)(mapa[i-a[i]]);
        ++mapa[i+a[i]];
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 19280
n = int(input())
num = []
for i in range(n):
    num.append(int(input()))
#ここまで入力
num1 = num.copy()
num1.sort(reverse=True)
mx1 = num1[0]
mx2 = num1[1]
for i in num:
    if i==mx1:
        ans = mx2
        print(ans)
    else:
        ans = mx1
        print(ans)


Measured memory_bytes: 14196
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        sc.close();
        
        for(int i=0; i<s.length();i++){
            if((i < a || i > a) && (s.charAt(i) < '0' || s.charAt(i) > '9') ){
                System.out.print("No");
                return;
            }
            if(i == a && s.charAt(i) != '-'){
                System.out.print("No");
                return;
            }
        }

        System.out.print("Yes");
	}
}

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


int main() {

    int a, b;
    cin >> a >> b;
    if (a*b % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
  if(a == b && b == c) {
    System.out.println(1);
  } else if(a == b || b == c || c == a) {
    System.out.println(2);
  } else {
    System.out.println(3);
  }
  }
}

Measured memory_bytes: 22996
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    a, p = MI()
    return (a * 3 + p) // 2


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5644
/*
 * AtCoder Beginner Contest 161 B - Popular Vote
 *
 * Time: ms
 * Memory: KB
 *
 * Author: DragonLee
 */

#include<iostream>
#include<algorithm>

using namespace std;
typedef long long LL;
const int LEN = 1e2 + 10;
int A[LEN];

int main() {
    int N, M, sum = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A + N, greater<int>());
    cout << (A[M - 1] * 4 * M >= sum ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
 
for s in range(N+1):
  for g in range(N-s+1):
    i = N - s - g
    if 1000*s + 5000*g + i*10000 == Y:
      print(i, g, s, sep=" ")
      exit()
print(-1, -1, -1, sep=" ")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int h,w;
char o,s[1010][1010];
int dp[1010][1010];

int main(){
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++){
		scanf("%c",&o);
		for(int j=1;j<=w;j++){
			scanf("%c",&s[i][j]);
		}
	}
	for(int i=1;i<=h;i++){
		if(s[i][1]=='.') dp[i][1]=1;
		else break;
	}
	for(int i=1;i<=w;i++){
		if(s[1][i]=='.') dp[1][i]=1;
		else break;
	}
	for(int i=2;i<=h;i++){
		for(int j=2;j<=w;j++){
			if(s[i][j]=='#') continue;
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	printf("%d\n",dp[h][w]);
	
	return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
}



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

int main()
{
	int n, x;
	while (cin >> n >> x, n + x)
	{
		int ans = 0;

		for (int i = 1; i <= n; i++)
		{
			for (int j = i + 1; j <= n; j++)
			{
				for (int k = j + 1; k <= n; k++)
				{
					if (i + j + k == x) ans++;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main(){

    int a,b,k;
    cin >> a >> b >> k;
    int count = 0;

    int i;
    if(a > b)i = a+1;
    else i = b+1;

    while(count != k){

        --i;
        if(a%i == 0 && b%i == 0)++count;

    }

    cout << i << endl;

    return 0;

}

Measured memory_bytes: 256
N = int(input())
C = []
for _ in range(N):
    C.append(list(map(int,input().split())))
s = 0
for k in range(N-1):
    for l in range(k+1,N):
        s += ((C[k][0]-C[l][0])**2 + (C[k][1]-C[l][1])**2)**(1/2)

print(s/(N/2))


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

int main() {
    long long N;
    cin >> N;
    string res = "";
    while (N) {
        --N;
        res += (char)('a' + (N % 26));
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>

using namespace std;

int main(int argc, char* argv[])
{
  int a,b,count;
  while(1)
  {
    count = 0;
    cin >> a >> b;
    if(a==0 and b==0) break;
    for(int i=1;i<a-1;i++)
    {
      for(int j=i+1;j<a;j++)
      {
        for(int k=j+1;k<=a;k++)
        {
          if(i+j+k==b) count++;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint par[100500]; //MAX_N
lint ufsize[100050]; //MAX_N

void init(lint x){
  rep(i,x) par[i]=i,ufsize[i]=1;
}

lint root(lint x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(lint x,lint y){
  return root(x)==root(y);
}

void unite(lint x,lint y){
  x=root(x);
  y=root(y);
  if(x==y) return;
  lint s=ufsize[x]+ufsize[y];
  ufsize[x]=s,ufsize[y]=s;
  par[x]=y;
}

lint size(lint x){
  return ufsize[root(x)];
}

//init(N)で準備を行うこと

int main(void){
    lint N,M;
    cin >> N >> M;
    init(N);
    lint H[N];
    bool ok[N];
    rep(i,N) ok[i]=true;
    rep(i,N) cin >> H[i];
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        if(H[a]==H[b]) ok[a]=false,ok[b]=false;
        else if(H[a]>H[b]) ok[b]=false;
        else ok[a]=false;
    }
    int ans=0;
    rep(i,N) if(ok[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 6100
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int H, A;
        cin >> H >> A;
        Int ans = H / A;
        if (H % A) ans++;
        cout << ans << endl;
    }

};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>


int main(int argc, char **argv){
	double r = 0;

	std::cin >> r;

	std::cout << std::fixed << std::setprecision(7)
		<< M_PI * r * r << " "
		<< 2 * r * M_PI << std::endl;

	return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)	
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
int main(){
	int n;
	while(cin>>n,n){
		vi x(n-1),d(n-1);
		rep(i,n-1)cin>>x[i]>>d[i];
		vvi dp(500,vi(500,-1));
		dp[250][250]=0;
		rep(q,n-1){
			rep(i,500)rep(j,500)if(dp[i][j]==x[q]){
				dp[i+dx[d[q]]][j+dy[d[q]]]=q+1;
			}
		}
		int out[4]={-inf,inf,-inf,inf};
		rep(i,500)rep(j,500)if(dp[i][j]+1){
			out[0]=max(out[0],i);
			out[1]=min(out[1],i);
			out[2]=max(out[2],j);
			out[3]=min(out[3],j);
		}
		cout<<(out[2]-out[3]+1)<<" "<<(out[0]-out[1]+1)<<endl;
	}
}











Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a,b,c;
    while(cin>>a>>b>>c){
        int f=-1;
        for(int i=0;i<=1e6;i++){
            if(a%2||b%2||c%2){
                f=i;
                break;
            }
            ll tc=(a+b)/2,ta=(b+c)/2,tb=(a+c)/2;
            a=ta,b=tb,c=tc;
        }
        cout<<f<<endl;
    }
    return 0;
}


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


int main(){
    string S;
    cin >> S;
    bool flag = true;
    int cnt=0;
    int tmp=0;
    if(S[0]!='A') flag = false;
    
    for(int i=2;i<S.size()-1;++i){
        if(S[i]=='C') {
            ++cnt;
            tmp = i;
        }
    }
    if(cnt!=1) flag = false;

    for(int i=1;i<S.size();++i){
        if(tmp==i) continue;
        if(S[i]<'a' || S[i]>'z') flag = false; 
    }
    if(flag) cout << "AC" << endl;
    else cout << "WA" << endl;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

ae=[];ao=[]

for i in range(n):
    if i%2==0:
        ae.append(a[i])
    else:
        ao.append(a[i])

if n%2==0:
    ans=ao[::-1]+ae
else:
    ans=ae[::-1]+ao

print(*ans)

Measured memory_bytes: 107604
from collections import defaultdict

N = int(input())
A = [int(a) for a in input().split()]

d = defaultdict(int)
for a in A:
    d[a] += 1
S = 0
for value in d.values():
    S += value*(value-1)//2
for a in A:
    print(S - (d[a]-1))


Measured memory_bytes: 26780
#include <iostream>

using namespace std;

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

	int count = 0;

	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < n; j++)
		{
			if (i * j >= n)
				break;
			else
				count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
int m,k;
// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);    
    cin>>m>>k;
    int tot=1<<m;
    if(k>=tot)cout<<-1;
    else if(m==0){
        if(k==0)cout<<"0 0";
        else cout<<-1;
    }
    else if(m==1){
        if(k==0)cout<<"0 0 1 1";
        else cout<<-1;
    }
    else{
        vector<int>v;
        for(int i=0;i<tot;i++){
            if(i!=k)v.pb(i);
        }
        v.pb(k);
        for(int i=tot-1;i>=0;i--){
            if(i!=k)v.pb(i);
        }
        v.pb(k);
        for(int u:v){
            cout<<u<<" ";
        }
    }
    
}

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

int main() {
	int n, m, p;
	while (cin >> n >> m >> p, n) {
		int sum = 0, princess;
		for (int i = 0; i < n; ++i) {
			int person; cin >> person;
			sum += person;
			if (i == m - 1)princess = person;
		}
		if (princess)cout << sum * 100 * (100 - p) / 100 / princess << endl;
		else cout << "0" << endl;
	}
}

Measured memory_bytes: 3040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	double A;
	double M = -1;
	double m = 1000001;
	while (cin >> A) {
		M = max(M, A);
		m = min(m, A);
	}
	cout << M - m << endl;
}


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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

set<int> primeFactors(int n) {
    set<int> factorization{ 1 };
    while (n % 2 == 0) {
        factorization.insert(2);
        n /= 2;
    }
    for (int d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            factorization.insert(d);
            n /= d;
        }
    }
    if (n > 1)
        factorization.insert(n);
    return factorization;
}

vector<int> getFactors(int n) {
    vector<int> factors = { 1 };
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            factors.push_back(i);
            if (i * i != n) {
                factors.push_back(n / i);
            }
        }
    }
    factors.push_back(n);
    return factors;
}

int32_t main() { fastio;
    time_t start = now();
    int a, b;
    cin >> a >> b;
    cout << primeFactors(__gcd(a, b)).size() << endl;
    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define debug2(a, b) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<endl
#define debug3(a, b, c) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<endl
#define debug4(a, b, c, d) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<endl
#define debug5(a, b, c, d, e) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<" | "<<#e<<" = "<<e<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll N = 100000 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 2e9;

ll dp[N][33];

ll no_of_ways(ll len, ll alpha) {
	if(len==0) {
		return ((alpha==0)?1:0);
	} else if(dp[len][alpha]!=-1) {
		return dp[len][alpha];
	} else {
		dp[len][alpha] = 0;
		for(ll i=0; i<=alpha; ++i) {
			dp[len][alpha] += no_of_ways(len-1, i);
			dp[len][alpha] %= MOD;
		}
		return dp[len][alpha];
	}
}

int main() {
	ll n, m;
	cin>>n>>m;
	for(ll i=0; i<N; ++i)
		for(ll j=0; j<33; ++j) 
			dp[i][j] = -1;
	vector<ll> alphas;
	for(ll i=2; i*i<=m; ++i) {
		ll cnt = 0;
		while(m%i==0) {
			m /= i;
			++cnt;
		}
		// debug2(i, cnt);
		if(cnt>0) alphas.pb(cnt);
	}
	//if m is prime
	if(m!=1) {
		alphas.pb(1);
	}
	ll ans = 1;
	for(ll alpha: alphas) {
		ans *= no_of_ways(n, alpha);
		// debug3(alpha, no_of_ways(n, alpha), ans);
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 30720
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


int main(int argc, char* argv[]) {

	int N,ans = 0;

	cin >> N;

	vector<int> A(N);
	vector<int> B(N);

	for (int i=0;i<N;i++){
		cin >> A[i];
	}

	B = A;

	sort(A.begin(),A.end());
	sort(B.rbegin(),B.rend());

	cout << B[0]-A[0] << endl;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int	A, B, C, K, i=0;
  int	rem;
  
  scanf("%d %d %d %d", &A, &B, &C, &K);
  
  if( (A+B) < K ){
    i +=  A;
    K -= (A+B);
    while(K > 0){
      i--;
      K--;
    }
    printf("%d",i);
  }

  else if( A > K ){
    printf("%d",K);
  }

  else{
    printf("%d",A);
  }
  return 0;
}

Measured memory_bytes: 1692
H, W = gets.split.map(&:to_i)
N = gets.to_i
as = gets.split.map(&:to_i)

board = Array.new(H) { Array.new(W) }
i, j = 0, 0
dx = 1
as.each.with_index do |a, c|
  c += 1
  a.times do
    board[i][j] = c
    if dx == 1 && j == W - 1
      i += 1
      dx = -1
    elsif dx == -1 && j == 0
      i += 1
      dx = 1
    else
      j += dx
    end
  end
end
puts board.map { |row| row.join(' ') }.join("\n")


Measured memory_bytes: 4604
open System.IO
open System

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false

let _n = stdin.ReadLine() |> int64
let _a = stdin.ReadLine().Split() 

let memoize fn = 
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
    match cache.TryGetValue x with
    | true, v -> v
    | false, _ -> 
        let v = fn (x)
        cache.Add(x,v)
        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
let memC2 = memoize c2

let countByA =  _a |> Array.countBy id |>Map.ofArray

// 全部の答えを出して余分な数を引く方針
let ansWhole = 
    countByA
    |> Seq.map (fun x -> memC2 (int64 x.Value))
    |> Seq.sum

let unNeeded aNum = 
    let x = int64 countByA.[aNum]
    // xC2 - (x-1)C2 = x-1
    x-1L

let memUnNeeded = memoize unNeeded
/// それぞれの答え
let ansEach aNum = ansWhole - memUnNeeded aNum

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine

stdout.Flush()

Measured memory_bytes: 62404