akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }
  int count = 0;
  cin >> count;
  for (int i = 0; i < N; ++i) {
    if (A[i] * 4 * M >= sum) count++;
  }
  if (count >= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
X = int(input())

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)

Measured memory_bytes: 9152
n, m = map(int, input().split())
MOD = 10**9+7

class Facts():
   def __init__(self, max_num=10**5, p=10**9+7):
      self.p = p
      self.max_num = max_num
      self.fact = [1] * (self.max_num + 1)
      self.rev = [1] * (self.max_num + 1)
      for i in range(1, self.max_num + 1):
         self.fact[i] = (self.fact[i-1] * i) % self.p
      self.rev[self.max_num] = self.mod_pow(self.fact[self.max_num], self.p-2)
      for i in range(self.max_num-1, 0, -1):
         self.rev[i] = self.rev[i+1] * (i + 1) % self.p

   def get_fact(self, n):
      return self.fact[n]

   def comb(self, n, k):
      if n < 0 or k < 0 or n < k:
         return 0
      if n == 0 or k == 0:
         return 1
      res = ((self.fact[n] * self.rev[k] % self.p) * self.rev[n - k]) % self.p
      return res

   def perm(self, n, k):
      if n < 0 or k < 0 or n < k:
         return 0
      if n == 0 or k == 0:
         return 1
      a = self.fact[n]
      b = self.fact[n-k]
      return (a * self.mod_pow(b, self.p-2)) % self.p

   def mod_pow(self, a, b):
      ans = 1
      while b > 0:
         if b & 1:
            ans = ans * a % self.p
         a = a * a % self.p; b >>= 1
      return ans

facts = Facts(max_num=5*10**5)

ans = 0
for k in range(n+1):
   tmp = (-1) ** k 
   tmp *= facts.comb(n, k) * facts.perm(m, k)
   tmp %= MOD
   tmp *= (facts.perm(m-k, n-k)) ** 2
   tmp %= MOD
   ans += tmp
   ans %= MOD
print(ans)

Measured memory_bytes: 96796
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_L 8001

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    int len = (int)s.size();
    
    int count = 0;
    int is_x = true;
    vector<int> x_list, y_list;
    for (int i = 0; i < len; ++i) {
        char c = s[i];
        if (c == 'F') {
            count++;
        } else {
            if (is_x) {
                x_list.push_back(count);
            } else {
                y_list.push_back(count);
            }
            count = 0;
            is_x = !is_x;
        }
    }
    if (is_x) {
        x_list.push_back(count);
    } else {
        y_list.push_back(count);
    }
    
    int x_size = (int)x_list.size();
    int y_size = (int)y_list.size();
    bool x_dp[2][2 * MAX_L];
    bool y_dp[2][2 * MAX_L];
    for (int i = 0; i < 2; ++i) {
        fill(x_dp[i], x_dp[i] + 2 * MAX_L, false);
        fill(y_dp[i], y_dp[i] + 2 * MAX_L, false);
    }
    x_dp[0][MAX_L + x_list[0]] = true;
    y_dp[1][MAX_L] = true;
    
    for (int i = 1; i < x_size; ++i) {
        fill(x_dp[i % 2], x_dp[i % 2] + 2 * MAX_L, false);
        for (int j = 0; j < 2 * MAX_L; ++j) {
            if (x_dp[(i + 1) % 2][j]) {
                x_dp[i % 2][j + x_list[i]] = true;
                x_dp[i % 2][j - x_list[i]] = true;
            }
        }
    }
    for (int i = 0; i < y_size; ++i) {
        fill(y_dp[i % 2], y_dp[i % 2] + 2 * MAX_L, false);
        for (int j = 0; j < 2 * MAX_L; ++j) {
            if (y_dp[(i + 1) % 2][j]) {
                y_dp[i % 2][j + y_list[i]] = true;
                y_dp[i % 2][j - y_list[i]] = true;
            }
        }
    }
    
    if (x_dp[(x_size + 1) % 2][MAX_L + x] && y_dp[(y_size + 1) % 2][MAX_L + y]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int h[2], m[2], k;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	for (int i : {0, 1})
		cin >> h[i] >> m[i];
	cin >> k;
	int a = h[0] * 60 + m[0], b = h[1] * 60 + m[1];
	cout << max(0, b-a-k) << '\n';
}



Measured memory_bytes: 3636
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    list<int>r;
    int n;cin>>n;
    bool a=true;
    for(int i=0;i<n;++i)
    {
       int x;cin>>x;
       if(a)
           r.push_back(x);
       else r.push_front(x);
       a=!a;
    }
    vector<int> rec(r.begin(),r.end());
    int s=rec.size();
    for(int i=0;i<s;++i)
    {
        if(a)
        {
            cout<<rec[i]<<' ';
        }
        else cout<<rec[n-1-i]<<' ';
    }
    cout<<'\n';


}




Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  map<char,int> m;
  rep(i,s.size()){
      m[s[i]]++;
  }
  bool t=true;
  for(auto it=m.begin();it!=m.end();it++){
      if (it->second%2==1) t=false;
  }
  if (t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	int pre,end;
	pre=(s[0]-'0')*10+s[1]-'0';
	end=(s[2]-'0')*10+s[3]-'0';
	if((end>=1&&end<=12)&&(pre>=1&&pre<=12))
		cout<<"AMBIGUOUS"<<endl;
	else if(end>=1&&end<=12)
		cout<<"YYMM"<<endl;
	else if(pre>=1&&pre<=12)
		cout<<"MMYY"<<endl;
	else
		cout<<"NA"<<endl;
    return 0;
}



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

using namespace std;

#define pb push_back
#define pp pop_back
#define F first
#define S second
#define endl "\n"
#define m_p make_pair

typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main() {
	INeedIt();
	int n, k, x, y;
	cin>>n>>k>>x>>y;
	cout<<min(n, k)*x+max(n-k, 0)*y;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int h,w,n;
 cin>>h>>w>>n;
 int x,y;
 cin>>x>>y;
 string s,t;
 cin>>s>>t;
 int l1=0,l2=0,r1=0,r2=0,u1=0,u2=0,d1=0,d2=0;
 bool pos=0;
 for(int i=0;i<n;i++){
  if(s[i]=='L') l1++;
  if(s[i]=='R') r1++;
  if(s[i]=='U') u1++;
  if(s[i]=='D') d1++;
  if(y-l1+r2<=0){
   pos=1;
   break;
  }
  if(y+r1-l2>w){
   pos=1;
   break;
  }
  if(x+d1-u2>h){
   pos=1;
   break;
  }
  if(x-u1+d2<=0){
   pos=1;
   break;
  }
  if(t[i]=='L') l2++;
  if(t[i]=='R') r2++;
  if(t[i]=='U') u2++;
  if(t[i]=='D') d2++;
  if(y-l1+r2>w){
   r2--;
  }
  if(y+r1-l2<=0){
   l2--;
  }
  if(x+d1-u2<=0){
   u2--;
  }
  if(x-u1+d2>h){
   d2--;
  }
 } 
 if(pos){
  cout<<"NO"<<endl;
 }
 else cout<<"YES"<<endl;
 return 0;
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector< int > a(n);
	for (auto& e:a)cin >> e;
	ll curr = 1000;
	for (int i=0;i+1<n;i++) {
		ll s = 0;
		if (a[i] < a[i+1]) s=curr/a[i];
		curr += ((ll)a[i+1]-a[i])*s;
	}
	cout << curr << '\n';
	
	return 0;
}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,mp_max=1;cin>>n;
  string a;
  map<string,int> mp;
  rep(i,n){
    cin>>a;
    mp[a]++;
    if(mp_max<mp[a])mp_max=mp[a];
  }
  for (auto p : mp) {
    if (p.second != mp_max) continue;
    cout << p.first << endl;
  }
}

Measured memory_bytes: 23808
n,w=[int(x) for x in input().split()]

lw=w
totval=0
wei=[]
val=[]
for test in range(n):
    cw, v = [int(x) for x in input().split()]
    wei.append(cw)
    val.append(v)
    totval+=v

dp=[float('inf')]*(totval+1)
dp[0]=0
for item in range(n):
    for j in range(totval,val[item]-1,-1):
        dp[j]=min(dp[j-val[item]]+wei[item],dp[j])
    #print(dp)
ans=0
for i in range(totval+1):
    if dp[i] <=w:
        ans=i
print(ans)


Measured memory_bytes: 92372
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int count(int b) {
		return b == 0 ? 0 : count(b & b - 1) + 1;
	}
	byte[][] aa, bb;
	void compress(int n, int m, int b) {
		for (int j = 0; j < m; j++)
			bb[0][j] = aa[0][j];
		for (int i = 0, h = 0; h < n - 1; h++)
			if ((b & 1 << h) == 0)
				for (int j = 0; j < m; j++)
					bb[i][j] += aa[h + 1][j];
			else {
				i++;
				for (int j = 0; j < m; j++)
					bb[i][j] = aa[h + 1][j];
			}
	}
	int[] kk;
	int cut(int n, int m, int k) {
		Arrays.fill(kk, 0, n, 0);
		int c = 0;
		for (int j = 0; j < m; j++) {
			boolean yes = true;
			for (int i = 0; i < n; i++) {
				if (bb[i][j] > k)
					return -1;
				if (kk[i] + bb[i][j] > k) {
					yes = false;
					break;
				}
			}
			if (yes)
				for (int i = 0; i < n; i++)
					kk[i] += bb[i][j];
			else {
				c++;
				for (int i = 0; i < n; i++)
					kk[i] = bb[i][j];
			}
		}
		return c;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		aa = new byte[n][];
		for (int i = 0; i < n; i++) {
			aa[i] = sc.next().getBytes();
			for (int j = 0; j < m; j++)
				aa[i][j] -= '0';
		}
		bb = new byte[n][m];
		kk = new int[n];
		int ans = n - 1 + m - 1;
		for (int b = 0; b < 1 << n - 1; b++) {
			int h = count(b);
			compress(n, m, b);
			int v = cut(h + 1, m, k);
			if (v >= 0)
				ans = Math.min(ans, h + v);
		}
		println(ans);
	}
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int a[300000], b[300000], d[300000];

int main() {
    int n;
    ll k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    int s = 0;
    ll cnt = 0;
    while (1) {
        d[cnt] = s;
        if (cnt == k) {
            cout << s + 1 << endl;
            return 0;
        }
        if (b[s]) {
            break;
        }
        b[s] = 1;
        s = a[s];
        cnt++;
    }
    k -= cnt;
    for (int i = 0; i < n; ++i) {
        if (d[i] == s) {
            for (int j = i + 1; j < n; ++j) {
                if (d[j] == s) {
                    cout << d[i + k % (j - i)] + 1 << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 5708
#include<iostream>
#include<algorithm>

using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define MOD 1000000007
typedef long long ll;

/* 2017 01/19 問題 ----- ABC 050 C /Link http://abc050.contest.atcoder.jp/tasks/arc066_a */
/* -----解説等-----
問題: 1~N までの番号がついた、N 人の人がいます。
彼らは昨日、ある順番で左右一列に並んでいましたが、今日になってその並び方が分からなくなってしまいました。
しかし、彼らは全員、「自分の左に並んでいた人数と自分の右に並んでいた人数の差の絶対値」を覚えています。
彼らの報告によると、人 i の、「自分の左に並んでいた人数と自分の右に並んでいた人数の差の絶対値」は Ai です。

彼らの報告を元に、元の並び方が何通りあり得るかを求めてください。 ただし、答えは非常に大きくなることがあるので、109+7 で割った余りを出力してください。
また、彼らの報告が間違っており、ありうる並び方がないこともありえます。 その際は 0 を出力してください。

制約
1≦N≦10^5
0≦A_i≦N−1

元の並び順としてありうるものが何通りあるか求め、109+7 で割った余りを出力せよ。

正確な順番を復元した際、区別をしない置き方は一意に定まる。
以下の条件を満たさねばならない
N:奇数のとき　正の偶数が N/2 種類(2こ) + 0
N:偶数のとき　正の奇数が N/2 種類(2こ) +
組み合わせは2^(2/N).

*/

int N;
ll ans = 1;
bool flag = true;
int cnt[100000 / 2];

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

    cin >> N;

    if (N % 2 == 0) {
        FOR(i, 0, N) {
            int a; cin >> a;

            if (a % 2 == 0 || a > N)flag = false;

            cnt[a / 2]++;
        }
        
        FOR(i, 0, N / 2) {
            if (cnt[i] != 2)flag = false;
        }
        FOR(i, 0, N / 2) {
            ans = (ans * 2) % MOD;
        }

    }
    else {
        int zero = 0;
        FOR(i, 0, N) {
            int a; cin >> a;

            if (a % 2 == 1 || a > N)flag = false;
            if (a != 0) {
                cnt[a / 2]++;
            }
            else zero++;
        }
        FOR(i, 1, N / 2+1) {
            if (cnt[i] != 2)flag = false;
        }
        if (zero != 1)flag = false;
        FOR(i, 0, N / 2) {
            ans = (ans * 2) % MOD;
        }

    }


    if (flag == false)ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
struct item{
    int v,w;
};
int N,W;


int solve(item items[]){
    int ans=0;
    int v,w;
    int C[101][10001];
    for(int i=0;i<=W;i++) C[0][i]=0;
    for(int i=0;i<=N+1;i++) C[i][0]=0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            if(items[i-1].w-j<=0){
                v=items[i-1].v;
                w=items[i-1].w;
                C[i][j]=max(C[i-1][j],C[i-1][j-w]+v);
            }
            else C[i][j]=C[i-1][j];
            if(C[i][j]>ans) ans=C[i][j];
        }
    }
   
    return ans;
}

int main(){
    int ans;
    cin>>N>>W;
    item items[101];
    int v,w;
    for(int i=0;i<N;i++){
        cin>>v>>w;
        items[i].v=v;
        items[i].w=w;
    }
    ans=solve(items);
    cout<<ans<<endl;

}


Measured memory_bytes: 7048
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int a,b,count;
    double ans,ave;
    char g;
    ans = ave = count = 0;
    while(cin >> a >> g >> b){
        count++;
        ans+= a * b;
        ave+= b;
    }
    ave /= count;
    cout << ans << endl << static_cast<int>(ave + 0.5) << endl;
}

Measured memory_bytes: 1236
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] L = new int [N];
        for(int i=0; i<N; i++){
            L[i] = sc.nextInt();
        }
        Arrays.sort(L);
        int ans=0;
        for(int i=1; i<=K; i++){
            ans+=L[N-i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,k:i64,
        mut a:[i64;n],
    }
    let mut ng = 0;
    let mut ok = INF;

    while (ok - ng).abs() > 1 {
        let mid = (ng + ok) >> 1;

        let check = |mid: i64| -> bool {
            let mut cnt = 0;
            for &x in a.iter() {
                cnt += (x + mid - 1) / mid - 1;
            }
            cnt <= k
        };
        if check(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}
const INF: i64 = 1 << 60;


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

//諸機能
#pragma region MACRO 
#define putans(x)  cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define input ifs >>
#else //いい感じにやる
#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

int main() {
	ll a, b; input a >> b;
	ll ab = a*b;
	if (ab > 0) {
		if (a > 0) {
			putans("Positive");
		}
		else {
			ll k = abs(a - b);
			putans(k % 2 != 0 ? "Positive" : "Negative");
		}
	}
	else {
		putans("Zero");
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    string res;
    for(int q; cin >> q;){
        pair<ll, ll> sum;
        rep(i, q){
            int p, n;
            char c;
            cin >> p >> c >> n;

            if(c == '(') sum.first += n;
            else sum.second += n;

            if(sum.first == sum.second) res = "Yes";
            else res = "No";
            cout << res << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

using namespace std;

int X; //Aの枚数
int Y; //B
int Z; //AB

int get_max(int *X, int *Y) {
	int max = 0;
	if (*X > *Y) {
		max = *X;
	}
	else {
		max = *Y;
	}
	return max;
}

int main() {
	int a, b, c = 0; //ピッツァの価格
	int ans = 0;

	cin >> a >> b >> c >> X >> Y;
	//ハーフを入れて買うのがお得な時(ABの値段の2倍がA,Bの和を超えないとき)
	if ((a + b) > c * 2) {
		int max;
		max = get_max(&X, &Y);

		int tmp = max * 2 * c;
		while (X>0 && Y>0) {
			X = X - 1;
			Y = Y - 1;
			Z = Z + 2;
		}
		ans = c * Z + a * X + b * Y;
		if (ans > tmp) {
			ans = tmp;
		}
	}
	//ハーフを入れて買わない時
	else {
		ans = a * X + b * Y;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
typedef long long ll;
ll res,dp[2][55][3],mod=1e9+7;
int n,vis[2][55];
char mp[2][55];
int main()
{
    scanf("%d",&n);
    scanf("%s",mp[0]);
    scanf("%s",mp[1]);
    int pan=0;
    ff(i,0,n-1)
    {
        if(mp[0][i]==mp[1][i]&&pan==0)
        {
            pan=1;
            res=3;
            continue;
        }
        else if(pan==0)
        {
            pan=2;
            res=6;
            i++;
            continue;
        }
        if(pan==1&&mp[0][i]==mp[1][i])
            res=(res*2)%mod;
        else if(pan==1)
        {
            i++;
            res=(res*2)%mod;
            pan=2;
        }
        else if(pan==2&&mp[0][i]==mp[1][i])
        pan=1;
        else
        {
            i++;
            res=(res*3)%mod;
        }
    }
    cout<<res<<endl;
	return 0;
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n);

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        long long num_c = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        long long num_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ans += num_a * num_c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = 0;
  rep(i, 0, n) {
    ll a, b;
    cin >> a >> b;
    if(a >= h and b >= w) ans++;
  }
  
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

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

using namespace std;

#define MAXN 100000
#define MAXS ((MAXN<<1)+1)

int N, M;
int p[MAXN+1];
int f[MAXS];

/* 1 <= x <= N */
#define P(x)    (x)
#define V(x)    (MAXS-(x))

int root(int x)
{
    return (x == f[x]) ? x : (f[x] = root(f[x]));
}
void uni(int x, int y)
{
    int fx = root(x), fy = root(y);
    f[fx] = fy;
}
void myinit(void)
{
    for(int i = 0;i < MAXS;i++)
    {
        f[i] = i;
    }
}

int main(void)
{
    int i;
    scanf("%d%d", &N, &M);
    myinit();
    for(i = 1;i <= N;++i)
    {
        scanf("%d", p+i);
        uni(P(i), V(p[i]));
    }
    while(M--)
    {
        int xi, yi;
        scanf("%d%d", &xi, &yi);
        uni(P(xi), P(yi));
    }
    int ans = 0;
    for(i = 1;i <= N;++i)
        if(root(P(i)) == root(V(i)))
            ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
n,x=map(int,input().split())

sumx=[1]
pathi=[1]
for i in range(n):
  sumx+=[sumx[-1]*2+3]
  pathi+=[pathi[-1]*2+1]
  
if n==0:
  if x==1:
    print(1)
    exit()
    
elif x==1:
  print(0)
  exit()
  

elif x==sumx[-1] or x==sumx[-1]-1:
  print(pathi[-1])
  exit()
  
ans=0

for i in range(n-1,0,-1):
  x-=1
  if x>=sumx[i]:
    ans+=pathi[i]
    x-=sumx[i]
    if x>=1:
      x-=1
      ans+=1
    if x>=sumx[i]:
      ans+=pathi[i]
      x-=sumx[i]
      if x>=2:
        x-=2
        ans+=1


ans+=max(x-1,0)
print(ans)


Measured memory_bytes: 61932
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
def sub(x):
    val = 0
    for aa,ff in zip(a,f):
        val += max(0, aa - (x//ff))
    return val<=k
if sub(0):
    ans = 0
else:
    l = 0
    r = sum(aa*ff for aa,ff in zip(a,f))
    while l+1<r:
        m = (l+r)//2
        if sub(m):
            r = m
        else:
            l = m
    ans = r
print(ans)

Measured memory_bytes: 113748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Op = pair<char, char>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int n,q;
string s;

vector< Op > ops;

bool check(int pos, char d, int step) {
  if(pos == 0) {
    return d == 'L';
  }
  if(pos == n+1) {
    return d == 'R';
  }
  if(step == q) {
    return false;
  }
  
  if(s[pos-1] != ops[step].first) {
    return check(pos, d, step+1);
  } else {
    if(ops[step].second == 'L') {
      return check(pos-1, d, step+1);
    } else {
      return check(pos+1, d, step+1);
    }
  }
}

int main(void) {
  cin >> n >> q;
  cin >> s;
  ops = vector<Op>();
  for(int i = 0;i < q;++i) {
    char t,d;
    cin >> t >> d;
    ops.push_back(Op(t,d));
  }

  int resl,resr;
  int ok,ng;

  ok = 0,ng = n+1;
  while((int)abs(ok - ng) > 1) {
    int md = (ok + ng)/2;
    if(check(md,'L',0)) {
      ok = md;
    } else {
      ng = md;
    }
  }
  resl = ok;
  //cout << resl << endl;

  ok = n+1,ng = 0;
  while((int)abs(ok - ng) > 1) {
    int md = (ok + ng)/2;
    if(check(md,'R',0)) {
      ok = md;
    } else {
      ng = md;
    }
  }
  resr = ok;
  //cout << resr << endl;

  cout << n - resl - (n - resr + 1) << endl;
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
fir=0
sec=0
a=[]
for _ in range(n):
    ak=int(input())
    a.append(ak)
    if ak>fir:
        fir=ak
    elif ak>sec:
        sec=ak
for ak in a:
    if ak==fir:
        print(sec)
    else:
        print(fir)

Measured memory_bytes: 12520
#include <stdio.h>

int main() {
    int x;
    scanf("%d", &x);
    
    if (400 <= x && x < 600)
        printf("8\n");
    else if (600 <= x && x < 800)
        printf("7\n");
    else if (800 <= x && x < 1000)
        printf("6\n");
    else if (1000 <= x && x < 1200)
        printf("5\n");
    else if (1200 <= x && x < 1400)
        printf("4\n");
    else if (1400 <= x && x < 1600)
        printf("3\n");
    else if (1600 <= x && x < 1800)
        printf("2\n");
    else
        printf("1\n");






    return 0;
}


Measured memory_bytes: 1620
N,K = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(2*K)]
menber = [i for i in range(1,N+1)]
l = []
set0 = set(l)
for i in range(K):
    set1 = set(data[2*i+1])
    set0 = set0.union(set1)
print(N-len(set0))

Measured memory_bytes: 9144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int Q = sc.nextInt();
		long lim = K - Q;
		int[] winCon = new int[N + 1];

		for (int i = 0; i < Q; i++) {
			winCon[sc.nextInt()]++;
		}

		for (int i = 1; i < winCon.length; i++) {
			if (winCon[i]+lim > 0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 60628
#include<cmath>
#include<cstdio>

using namespace std;

const double EPS=1e-9;

int a,n;
double p,q;

int dfs(int i,int cnt,double sum,int prod){
	if(abs(sum-p/q)<EPS) return 1;
	if(sum+(n-cnt)*1.0/i+EPS<p/q || p/q<sum-EPS || cnt+1>n || prod*i>a) return 0;
	return dfs(i,cnt+1,sum+1.0/i,prod*i)+dfs(i+1,cnt,sum,prod);
}

int main(){
	for(;scanf("%lf%lf%d%d",&p,&q,&a,&n),p;) printf("%d\n",dfs(1,0,0,1));
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argv,char* argc[]){
    long long x,d,k;
    scanf("%lld%lld%lld",&x,&k,&d);
    //double c=(double)d*(double)k;
    x=llabs(x);
    long long now=x;
    if(x/d<=k){
        now-=d*(x/d);
        k-=x/d;
        if(k%2){
            now-=d;
        }
    }else{
        now-=d*k;
    }
    printf("%lld",llabs(now));
    return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int n,a[100001],mtp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int j=n-1;j>=1;j--){
			if(a[j]>=a[n]/2&&a[j-1]<=a[n]/2)
			{
				mtp=(a[j]-a[n]/2)<=(a[n]/2-a[j-1])?a[j]:a[j-1];
			}
		}
	printf("%d %d",a[n],mtp);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even";
  } else {
    cout << "Odd";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	static const int DATA_VOLUME_MAX = 10000;
	int case_cnt = 1;
	int input_num = 0;

    /* Output "Case x: input" */
	do{
		cin >> input_num;

		if(input_num == 0){
			break;
		}
		else{
			cout << "Case " << case_cnt << ": " << input_num << endl;
		}
		case_cnt++;
	}while(case_cnt <= DATA_VOLUME_MAX);
	return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
 
using namespace std;
 
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((a*b > c*d) ? a*b : c*d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=3e5+10;
int n;
ll a[66];
int main(){
    //ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll x;
        scanf("%lld",&x);
        for(int j=0;j<=60;j++){
            if(x>>j&1) ++a[j];
        }
    }
    ll ans=0;
    for(int i=0;i<=60;i++){
        ll ret=(1ll<<i)%mod;
        ans=(ans+a[i]*(n-a[i])%mod*ret%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int a[][] = new int[n][m];
        int b[][] = new int[m][l];
        long c[][] = new long[n][l];

        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                a[i][j] = sc.nextInt();
            }
        }
        for(int i = 0;i < m;i++){
            for(int j = 0;j < l;j++){
                b[i][j] = sc.nextInt();
            }
        }

        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                c[i][j] = 0;
                for(int k = 0;k < m;k++){
                    c[i][j] += (a[i][k] * b[k][j]);
                }
            }
        }

        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                if(j == l - 1){
                    System.out.print(c[i][j]);
                }else{
                    System.out.print(c[i][j] + " ");
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 54316
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			BigInteger a = new BigInteger(sc.next());
			BigInteger b = new BigInteger(sc.next());
			BigInteger c = a.add(b);
			if (c.toString().length() > 80) {
				System.out.println("overflow");
			}else{
				System.out.println(c);
			}
		}
	}

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 105;

int a[N], n, cache[N], k = 2;

int dp(int i){
    int &ans = cache[i];
    if(ans != -1)
    return ans;
    ans = 1e18;
    bool flag = 0;
    for(int j = 1; j <= k; ++j){
        if(i + j < n){
            ans = min(ans, abs(a[i] - a[i + j]) + dp(i + j));
            flag = 1;
        }
    }
    if(!flag)
    ans = 0;
    return cache[i] = ans;
}

void solve(){
    cin >> n;
    for(int i = 0; i < n; ++i)
    cin >> a[i];
    memset(cache, -1, sizeof cache);
    cout << dp(0);
}

int32_t main(){
    IOS;
    int t = 1;
    bool test = 0;
    if(test) cin >> t;
    for(int i = 1; i <= t; ++i)
    solve();
    return 0;
}

/*

  
*/
  

Measured memory_bytes: 11372
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0)cout<<"Alice";
    else cout<<"Borys";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;
  vpair cond(m);
  rep(i,m){
    int v1, v2;
    cin >> v1 >> v2;
    cond[i]=make_pair(v1,v2);
  }

  rep(i,pow(10,n)){
    string s=to_string(i);
    bool ok=true;
    //prt(i);
    if(to_string(i).size()!=n){
      continue;
    }
    rep(j,m){
      //prt2("-->",s[cond[j].first-1]);
      //prt2("-->",cond[j].second);
      if((s[cond[j].first-1]-'0')!=cond[j].second){
        ok=false;
        //prt("false");
      }
    }
    if(ok){
      prt(i); return 0;
    }
  }
  prt(-1);
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

s = list(input())
cnt1=0
for i in range(len(s)):
        if int(s[i]) == i%2:
                cnt1 += 1

cnt2=0
for i in range(len(s)):
        if int(s[i]) == (i+1)%2:
                cnt2 += 1

print(min(cnt1,cnt2))

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int ans = 111;
	while (n > ans) {
		ans += 111;
	}
	if (ans > 999)cout << 1111 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B){
        cout << C << endl;
    }
    else if(B == C){
        cout << A << endl;
    }
    else{
        cout << B << endl;
    }
}

Measured memory_bytes: 256
card = [input().split() for _ in range(3)]
n = int(input())

hit = set()
for _ in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if b == card[i][j]:
                hit.add(i * 3 + j + 1)

bingo = [
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9},
    {1, 4, 7},
    {2, 5, 8},
    {3, 6, 9},
    {1, 5, 9},
    {3, 5, 7}
]

for b in bingo:
    if b.issubset(hit):
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 38416
#include <stdio.h>

int main()
{
    int x, kyu;

    scanf("%d", &x);

    if (x >= 400 && x <= 599)
        kyu = 8;
    else if (x >= 600 && x <= 799)
        kyu = 7;
    else if (x >= 800 && x <= 999)
        kyu = 6;
    else if (x >= 1000 && x <= 1199)
        kyu = 5;
    else if (x >= 1200 && x <= 1399)
        kyu = 4;
    else if (x >= 1400 && x <= 1599)
        kyu = 3;
    else if (x >= 1600 && x <= 1799)
        kyu = 2;
    else if (x >= 1800 && x <= 1999)
        kyu = 1;
    
    printf("%d\n", kyu);

    return 0;
}

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

int main(){
	long long n;
	long long tmp;
	long long cnt;
	long long ans=0;
	long long a;
	vector<long long> cnt1(60);
	cin >> n;
	
	for(long long i=0; i<n; i++){
		cin >> a;
		for(long long d=0; d<60; d++){
			if(a & (1ull <<d)){
				//cout << a << ", " << d << endl;
				cnt1[d]++;
			}
		}
	}
	//print
	//for(long long i=0; i<60; i++){
	//	cout << i << "," <<  cnt1[i] << endl;
	//}


	for(long long i=0; i<60; i++){
		cnt1[i] = (cnt1[i]*(n-cnt1[i]))%1000000007;
	}

	tmp = 1;
	for(long long i=0; i<60; i++){
		ans += (tmp*cnt1[i])%1000000007;
		tmp = (tmp*2)%1000000007;
	}
	ans = ans%1000000007;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    tmp1 = dp[i-1] + abs(H[i]-H[i-1])
    tmp2 = dp[i-2] + abs(H[i]-H[i-2])
    dp[i] = min(tmp1, tmp2)
print(dp[N-1])

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

strings = []
for _ in range(N):
    strings.append(input())

cnt = 0
cnt_A = cnt_B = 0
flag = False
for s in strings:
    for c1, c2 in zip(s, s[1:]):
        if c1 == 'A' and c2 == 'B':
            cnt += 1

    if s[0] == 'B':
        cnt_B += 1
        if s[-1] != 'A':
            flag = True
    if s[-1] == 'A':
        cnt_A += 1
        if s[0] != 'B':
            flag = True

cnt += min(cnt_A, cnt_B)
if cnt_A == 0 and cnt_B == 0:
    flag = True
print(cnt if flag else cnt - 1)


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

struct square{
	int x;
	int y;
};

int dx[] = {
	-1, 0, 1, 0
};

int dy[] = {
	0, 1, 0, -1
};

square squares[200];

int main(){
	int N;
	while(cin >> N){
		if(N == 0) break;
		squares[0].x = squares[0].y = 0;
		for(int i = 1; i < N; i++){
			int n, d;
			cin >> n >> d;
			squares[i].x = squares[n].x + dx[d];
			squares[i].y = squares[n].y + dy[d];
		}
		int minx = 0, miny = 0;
		int maxx = 0, maxy = 0;
		for(int i = 0; i < N; i++){
			minx = min(minx, squares[i].x);
			miny = min(miny, squares[i].y);
			maxx = max(maxx, squares[i].x);
			maxy = max(maxy, squares[i].y);
		}
		int width = maxx - minx + 1;
		int height = maxy - miny + 1;
		cout << width << " " << height << endl;
	}
	return 0;
}

Measured memory_bytes: 0
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let n=tn()
  let sa=tss(n)
  for(let i=0;i<n-1;i++){
    for(let j=i+1;j<n;j++){
      if(sa[i]==sa[j]){
        to('No')
        return
      }
    }
    if(sa[i][sa[i].length-1]!=sa[i+1][0]){
      to('No')
      return
    }
  }
  to('Yes')
}
main()


Measured memory_bytes: 7372
#include <cstdio>
#include <algorithm>
#define INF 1<<30
using namespace std;
int n,a[50],b[50],c[50];
int ma,mb,ans;
int dp[2][43][403][403];
// dp[i][j][ak][bk]: in the first i items choose j items
//					 and the sum of a is ak, the sum of b is bk
//					 the minimum cost
int main() {
	scanf("%d %d %d",&n,&ma,&mb);
	for (int i=1;i<=n;i++)
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for (int j=0;j<=n;j++)
		for (int ak=0;ak<=n*10;ak++)
			for (int bk=0;bk<=n*10;bk++) {
				dp[1][j][ak][bk]=INF;
			}
	dp[1][0][0][0]=0;
	dp[1][1][a[1]][b[1]]=c[1];
	for (int i=2;i<=n;i++)
		for (int j=0;j<=n;j++)
			for (int ak=0;ak<=n*10;ak++)
				for (int bk=0;bk<=n*10;bk++) {
					dp[i&1][j][ak][bk]=dp[1-i&1][j][ak][bk];
					if (ak>=a[i]&&bk>=b[i]&&j>=1)
						dp[i&1][j][ak][bk]=min(dp[i&1][j][ak][bk],dp[1-i&1][j-1][ak-a[i]][bk-b[i]]+c[i]);
				}
	ans=INF;
	for (int i=1;i*ma<=n*10&&i*mb<=n*10;i++)
		for (int j=0;j<=n;j++)
			ans=min(ans,dp[n&1][j][i*ma][i*mb]);
	if (ans==INF)
		ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 53504
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

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

   long long sum = 0;
   for(int i = 0;i<N-1;i++)
   {
       for(int j = i+1;j<N;j++)
       {
           sum+=d[i]*d[j];
       }
   }

    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    for(int i=0; i<N; i++) {
        cin >> s[i] >> t[i];
    }
    string X;
    cin >> X;

    partial_sum(t.begin(), t.end(), t.begin());
    cout << t[N-1] - t[distance(s.begin(), find(s.begin(), s.end(), X))] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String w = in.next();
		int count = 0;
		while (true) {
			String t = in.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			String text = t.toLowerCase();
			if (text.equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26224
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long int llint;

int N;

int main() {
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != (i + 1 - ans)) {
			ans++;
		}
	}
	if (ans == N) { ans = -1; }
	cout << ans << endl;
}

Measured memory_bytes: 1024