akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

ll N;
vector<ll> A;
vector<ll> B;
vector<ll> C;

int main() {
  cin>>N;
  ll a,b,c;
  for(ll i = 0;i<N;i++){
    cin>>a;
    A.push_back(a);
  }
  for(ll i = 0;i<N;i++){
    cin>>b;
    B.push_back(b);
  }
  for(ll i = 0;i<N;i++){
    cin>>c;
    C.push_back(c);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  vector<ll> d(N+1,0);
  vector<ll> e(N+1,0);

  for(ll i = N-1;i>=0;i--){
    auto j =upper_bound(C.begin(),C.end(),B[i]);
    d[i]= distance(j, C.end());
    d[i]+=d[i+1];
  }

  for( ll i = N-1;i>=0;i--){
    auto j=upper_bound(B.begin(),B.end(),A[i]);
    if(j==B.end())e[i]=0;
    else e[i]=d[distance(B.begin(),j)];
    e[i]+=e[i+1];
  }

  cout<<e[0]<<endl;

  

  return 0;
}


Measured memory_bytes: 4340
/*  -*- coding: utf-8 -*-
 *
 * 2988.cc: Union Ball
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int no = 0, ne = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    if (ai & 1) no++;
    else ne++;
  }
  //printf("no=%d, ne=%d\n", no, ne);

  int cnt = 0;
  if (no > 2 && ne > 0) {
    int d = (no - 1) / 2;
    cnt += d, no -= 2 * d, ne += d;
  }
  if (no > 0 && ne > 0)
    cnt += ne, ne = 0;

  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 3232
A,B,K = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
A_div = make_divisors(A)
B_div = make_divisors(B)
koyakusu = list(set(A_div) & set(B_div))
koyakusu.sort(reverse=True)
#koyakusu = set(A_div) & set(B_div)
print(koyakusu[K-1])
    

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll L(2*N);
    for(ll i=0;i<2*N;i++)cin>>L[i];
    sort(ALL(L));
    ll ans=0;
    for(ll i=0;i<2*N;i++){
        ans+=L[i];
        i++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

dx = (x1-x2)
dy = (y2-y1)

x3 = x2 - dy
y3 = y2 - dx
x4 = x1 - dy
y4 = y1 - dx

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
n = int(input())
lst = list(map(int, input().split()))
lst2 = sorted(lst)
if lst==lst2:
  print("YES")
else:
  tmp = 0

  for i in range(n):
    if lst[i]!=lst2[i]:
      tmp+=1
      
  if tmp != 2:
    print("NO")
  else:
    print("YES")

Measured memory_bytes: 38384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5)cout << 0 << endl;
	else if (a <= 12)cout << b / 2 << endl;
	else cout << b << endl;
	return 0;
}


Measured memory_bytes: 256
first = sorted(list(input('')))
second = sorted(list(input('')), reverse=True)
length = len(first) < len(second)

result = False
check_equal = False
for (f, s) in zip(first, second):
  check_equal = (s == f)
  if f < s:
    result = True
    break
  elif f > s:
    result = False
    break

if (length and check_equal) or result:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    // cin >> tc;
    while (tc--)
    {
        int n;
        cin >> n;
        map<int, int> mp;
        int a[n], f = 0;
        for (int i = 0; i < n;i++){
            cin >> a[i];
            mp[a[i]]++;
            if(mp[a[i]]>1){
                f = 1;
            }
        }
        if(f)
            cout << "NO" << endl;
        else{
            cout << "YES" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 14336
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 && a != c) || (a == c && a != b) || (b == c && a != b)){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <climits>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    
    int N, L;
    int sum = 0;
    int ans;
    int apple_Abs = INT_MAX;
    cin >> N >> L;
    vector<int> apple(N,0);
    
    for(int i = 1; i <= N; i++){
        apple[i-1] = L + i - 1;
        sum += apple[i-1];
    }
    
    for(int i = 0; i < N; i++){
        int apple_Lost = sum - apple[i];
        
        if(apple_Abs > abs(sum - apple_Lost)){
            apple_Abs = abs(sum - apple_Lost);
            ans = apple_Lost;
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int>P;
typedef vector<P>E;
E e[100];
vector<int> v;
int F(int a,int b,int n)
{
	int f[100]={0},c=n,x;
	v.clear();
	v.push_back(0);
	while(!v.empty())
	{
		x=v.back();v.pop_back();
		if(f[x]++)continue;
		if(!--c)return 1;
		E::iterator i=lower_bound(e[x].begin(),e[x].end(),P(a,-1)),
			j=lower_bound(e[x].begin(),e[x].end(),P(b+1,-1));
		for(;i!=j;++i)v.push_back(i->second);
	}
	return 0;
}
int main()
{
	int n,m,a,b,w,i,l,r,f;
	v.reserve(4950);
	while(scanf("%d%d",&n,&m),n)
	{
		for(i=0;i<n;++i)e[i].clear();
		while(m--)
		{
			scanf("%d%d%d",&a,&b,&w);
			--a,--b;
			e[a].push_back(P(w,b));
			e[b].push_back(P(w,a));
		}
		for(i=0;i<n;++i)sort(e[i].begin(),e[i].end());
		for(l=0,a=r=10001;l<r;)
		{
			m=(l+r)/2;
			for(f=i=0;i<10001-m;++i)
			{
				if(F(i,i+m,n)){f=1;break;}
			}
			if(f)
			{
				if(a>m)a=m;
				r=m;
			}
			else
				l=m+1;
		}
		if(a==10001)a=-1;
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int H, W;
    char tmp;
    cin >> H >> W;

    int s[H][W], cost[H][W], v[H][W];

    REP(i, H){
        REP(j, W){
            cin >> tmp;
            if(tmp == '#') s[i][j] = 1;
            else s[i][j] = 0;
            v[i][j] = 0;
        }
    }

    REP(i, H){
        REP(j, W){
            if(i == 0 & j == 0){
                cost[0][0] = s[0][0];
                v[i][j] = s[i][j];
            } else if(i == 0) {
                if(s[i][j] == 0){
                    cost[i][j] = cost[i][j-1];
                } else {
                    if(v[i][j-1] == 0){
                        cost[i][j] = cost[i][j-1] + 1;
                    } else {
                        cost[i][j] = cost[i][j-1];
                    }
                    v[i][j] = 1;
                }
            } else if(j == 0){
                if(s[i][j] == 0){
                    cost[i][j] = cost[i-1][j];
                } else {
                    if(v[i-1][j] == 0){
                        cost[i][j] = cost[i-1][j] + 1;
                    } else {
                        cost[i][j] = cost[i-1][j];
                    }
                    v[i][j] = 1;
                }
            } else {
                if(s[i][j] == 0){
                    cost[i][j] = min(cost[i][j-1], cost[i-1][j]);
                } else {
                    if(v[i][j-1] == 1 & v[i-1][j] == 1){
                        cost[i][j] = min(cost[i][j-1], cost[i-1][j]);
                    } else if(v[i][j-1] == 1){
                        cost[i][j] = min(cost[i][j-1], cost[i-1][j]+1);
                    } else if(v[i-1][j] == 1){
                        cost[i][j] = min(cost[i][j-1]+1, cost[i-1][j]);
                    } else {
                        cost[i][j] = min(cost[i][j-1], cost[i-1][j]) + 1;
                    }
                    v[i][j] = 1;
                }
            }
        }
    }

    cout << cost[H-1][W-1] << endl;

    // REP(i, H){
    //     REP(j, W){
    //         cout << cost[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}


Measured memory_bytes: 384
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sun Oct  1 03:10:11 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b, h;
  cin >> a;
  cin >> b;
  cin >> h;

  cout << (a + b) * h / 2 << endl;

  return 0;
}


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

using namespace std;

#define ll long long int
#define INF 1e5
#define MoD 1e9 + 7
#define all(c) c.begin(), c.end()
#define sz(x) (int)(x).size()

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

	int t;
  	cin >> t;
  cout << (t==0)?1:0 <<'\n';
  return 0;

}


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

int main() {
  int n;
  cin>>n;
  vector<int>t(n);
  for(int i=0;i<n;i++) cin>>t[i];
  int m;
  cin>>m;
  vector<pair<int,int>>d(m);
  for(int i=0;i<m;i++) cin>>d[i].first>>d[i].second;
  int ans=0;
  for(int i=0;i<n;i++) ans+=t[i];
  for(int i=0;i<m;i++) cout<<ans-(t[d[i].first-1]-d[i].second)<<endl;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

// 階乗を利用した順列
ll nPr(ll n, ll r) {
  ll ret = 1;
  for (ll i = n; i > n - r; i--) {
    ret *= i;
    ret %= MOD;
  }
  return ret;
}

// 組合せを素数で割った値を求める
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k || n < 0 || k < 0) return 0;
  return nPr(n, k) * (finv[k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll ans;
  ans = power(2, n, MOD) - 1;
  
  ans += 2 * MOD;
  
  COMinit();
  
  ans -= COM(n, a) + COM(n, b);
  
  cout << ans % MOD << '\n';
}

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



int main(){
    int x, y, z;
    cin >> x >> y >> z;
    rep(i,x){
        if(x - y*i - z*(i+1) >= 0){
            continue;
        }
        else{
            cout << i-1 << endl;
            return 0;
        }
    }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if((A+B)%2 == 0){
  	cout << (A+B)/2 << endl;
  } else {
  	cout << "IMPOSSIBLE" << endl;  	
  }  
  return 0;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s);
    ll n= s.size()-1; 
    ll cnt= 0;
    for(int i=0; i<(1<<n); i++){
        // cout << i << 
        
        ll sum = s[0]-'0';
        string ans{s[0]};
        for(int j=0; j<n; j++){    
            if(i & (1<<j)){ // j が i に入るかどうか
                sum+= (s[j+1]-'0');
                ans+= "+"+to_string(s[j+1]-'0');
            }else{
                sum-= (s[j+1]-'0');
                ans+= "-"+to_string(s[j+1]-'0');
            }
        }
        if(sum==7){
            out(ans+"=7");
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    char c;
    string s;

    cin >> s ;

    for (c='a'; c <= 'z'; c++){
        if(s.find(c) == string::npos){
            cout << c << endl;
            return 0;
            }
        }
    cout << "None" << endl;
    return 0;
 }
 

Measured memory_bytes: 512
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(input())
for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '#':
                    cnt += 1
        if cnt == K:
            rst += 1
print(rst)

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main()
{
    int N,K,a[105],i=0;
    cin>>N>>K;
    while (N--)
    {
        cin>>a[i++];
    }
    a[i]='\0';
    int sum=0;
    for (int j=0;a[j]!='\0';j++)
    {
        if (a[j]<=K-a[j])
            sum+=a[j]*2;
        else sum+=(K-a[j])*2;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
mod=10**9+7
def independent_set(n,graph):

	ways=[[0]*2 for _ in  range(n)]
	# ways[i][0]---->white node
	# ways[i][1]---->black node

	def dfs(node,parent):
		# if len(graph[node])==1:
		# 	ways[node][0]=1
		# 	ways[node][1]=1

		w_w=b_w=1

		for i in graph[node]:
			if i!=parent:
				dfs(i,node)	
				w_w=w_w*sum(ways[i])%mod
				b_w=b_w*ways[i][0]%mod
		ways[node][0]=w_w
		ways[node][1]=b_w

	dfs(0,-1)
	# print(ways)
	return (ways[0][0]+ways[0][1])%mod


n=int(input())
graph={i:[] for i in range(n)}

for i in range(n-1):
	u,v=map(lambda x:int(x)-1,input().split())
	graph[u].append(v)
	graph[v].append(u)
# res=independent_set(n,graph)

res=independent_set(n,graph)

# res=ways(100,10**5,[randint(0,10**5) for _ in range(100)])
print(res%(10**9+7))







Measured memory_bytes: 142048
#include <iostream>

struct Bingo {
    int no;
    bool check;
};

int main() {
    Bingo bingo[3][3];
    int N;

    for(int i=0;i < 3;i++){
       std::cin >> bingo[i][0].no >> bingo[i][1].no >> bingo[i][2].no;
    }

    std::cin >> N;
    for(int i = 0;i < N; i++){
        int card;
        std::cin >> card;
        for(int i=0;i < 3;i++){
            for(int j=0;j < 3; j++){
                if(bingo[i][j].no == card) {
                    bingo[i][j].check = true;
                }
            }
        }
    }

    //search
    bool isbingo = false;
    // row & column
    for(int i = 0; i < 3;i++){
        if((bingo[i][0].check & bingo[i][1].check & bingo[i][2].check) || (bingo[0][i].check & bingo[1][i].check & bingo[2][i].check)) {
            isbingo = true;
        }
    }
    if(bingo[0][0].check & bingo[1][1].check & bingo[2][2].check || bingo[2][0].check & bingo[1][1].check & bingo[0][2].check) {
        isbingo = true;
    }

    if(isbingo) std::cout << "Yes";
    else std::cout << "No";
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    k = min(len(s),I())

    ans = 1

    for i in range(k):
        if s[i] != "1":
            ans = s[i]
            break

    print(ans)
main()


Measured memory_bytes: 74612
n = int(input()); a = list(map(int, input().split())); b = list(map(int, input().split()))
c = [0]*n; d = [0]*n; g = 0
for i in range(n): c[a[i]-1] += 1; d[b[i]-1] += 1
for i in range(n): g = max(g, c[i]+d[i])
e = [c[0]]; f = [d[0]]; h = e[0]
for i in range(1, n): e.append(c[i]+e[-1]); f.append(d[i]+f[-1])
for i in range(n-1): h = max(h, e[i+1]-f[i])
if g > n: print("No")
else: print("Yes"); print(*(b[n-h:]+b[:n-h]))

Measured memory_bytes: 51200
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int mod = 1000000007;
int binpow(int a, int b) {
	int ans = 1;
	while (b) {
		if (b & 1) ans = 1LL * ans * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	long long ra = binpow(10, N);
	long long rb = binpow(9, N);
	long long rc = binpow(8, N);
	cout << (ra - 2 * rb + rc + mod * 2) % mod << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l),i##end=(int)r;i<=i##end;i++)
#define Fordown(i,r,l) for(int i=(r),i##end=(int)l;i>=i##end;i--)
using namespace std;
typedef long long ll;
const int INF=1e9;
const int N=2e5+10;
struct node{
	int cnt0,cnt1,id;
	bool operator < (const node &rhs) const {
		return 1ll*cnt1*rhs.cnt0>1ll*cnt0*rhs.cnt1;
	}
};
priority_queue <node> q;
int fa[N],f[N];
int cnt0[N],cnt1[N];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int find(int x){
	return f[x] == x ? x : f[x] = find(f[x]);
}
int main(){
	int n;
	n=read();
	For(i,2,n)fa[i]=read();
	int w;
	For(i,1,n){
		w=read();
		cnt0[i]=(w==0),cnt1[i]=(w==1);
		q.push((node){cnt0[i],cnt1[i],i});
	}
	For(i,1,n)f[i]=i;
	ll ans=0;
	For(i,1,n){
		node u=q.top();q.pop();
		int x=find(u.id),y=find(fa[u.id]);
		if(x==y){
			i--;continue;
		}
		f[x]=y;
		ans+=1ll*cnt1[y]*cnt0[x];cnt0[y]+=cnt0[x],cnt1[y]+=cnt1[x];
		q.push((node){cnt0[y],cnt1[y],y});
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6772
from collections import defaultdict

N, K, Q = map(int, input().split())

# 耐えた回数
G = defaultdict(int)
for i in range(Q):
    G[int(input())] += 1

for n in range(1, N+1):
    point = K - Q + G[n]
    if point > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 16188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string dp[10002] = {};
std::map<int, int> S;

bool cmp(string a, string b) {
  if (a.size() > b.size())
    return true;
  else if (a.size() < b.size())
    return false;
  ll size = a.size();
  REP(i, size) {
    if (a[i] > b[i])
      return true;
    else if (a[i] < b[i])
      return false;
  }
  return true;
}

int main() {
  ll N, M;
  S[1] = 2;
  S[2] = 5;
  S[3] = 5;
  S[4] = 4;
  S[5] = 5;
  S[6] = 6;
  S[7] = 3;
  S[8] = 7;
  S[9] = 6;
  vector<int> A;
  cin >> N >> M;
  REP(i, M) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  REP(i, N) {
    if (i != 0 && dp[i] == "")
      continue;
    AUTO(a, A) {
      if (N < i + S[a])
        continue;
      if (cmp(dp[i] + to_string(a), dp[i + S[a]])) {
        dp[i + S[a]] = dp[i] + to_string(a);
      }
      if (cmp(to_string(a) + dp[i], dp[i + S[a]])) {
        dp[i + S[a]] = to_string(a) + dp[i];
      }
    }
  }
  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 34432
# -*- coding: utf-8 -*-
"""
E - 1 or 2
https://atcoder.jp/contests/abc126/tasks/abc126_e

"""
import sys


class DisjointSet:
    def __init__(self, n):
        self.p = list(range(n))

    def root(self, i):
        if self.p[i] == i:
            return i
        else:
            self.p[i] = self.root(self.p[i])
            return self.p[i]

    def find(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)
        if j >= i:
            self.p[j] = i
        else:
            self.p[i] = j


def solve(N, M, hints):
    d = DisjointSet(N+1)
    for x, y, z in hints:
        d.unite(x, y)
    for i in range(1, N+1):
        d.root(i)

    ans = set(d.p)
    ans.discard(d.p[0])
    return len(ans)


def main(args):
    N, M = map(int, input().split())
    hints = [[int(i) for i in input().split()] for _ in range(M)]
    ans = solve(N, M, hints)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 31328
#include<iostream>
#include<string>
#include<iomanip>
#include<sstream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

ll H, W, K;
ll P[111][10];
ll hoge[10];

int main()
{
	cin >> H >> W >> K;
	hoge[0] = 0;
	hoge[1] = 1;
	hoge[2] = 1;
	hoge[3] = 2;
	hoge[4] = 3;
	hoge[5] = 5;
	hoge[6] = 8;
	hoge[7] = 13;
	hoge[8] = 21;

	P[1][1] = 1;
	for (ll i = 2; i <= H+1; i++) {
		for (ll j = 1; j <= W; j++) {
			P[i][j] = (P[i - 1][j] * hoge[j] * hoge[W - j + 1]) % 1000000007;
			P[i][j] += (P[i-1][j-1] * hoge[j-1]*hoge[W-j+1]) % 1000000007;
			P[i][j] += (P[i - 1][j + 1] * hoge[j] * hoge[W - j]) % 1000000007;
			P[i][j] = P[i][j] % 1000000007;
		}
	}
	cout << P[H+1][K] << endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,d;
cin>>n>>d;
d=d*d;
int count =0;
long long int x,y;
for(int i=0;i<n;i++)
{cin>>x>>y;
x=x*x+y*y;
if(x<=d)
count++;
}
  cout<<count;
}

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



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

    ll ans = 0;
    int n;
    cin >> n;
    vector<ll> arr(n);
    for(int i=0; i<n; ++i){
        cin >> arr[i];           
    }
    ll curr_height = arr[0];
    for(int i=1; i<n; ++i){
        if( arr[i] >= curr_height ){ 
            curr_height = arr[i];
            continue; 
        }else{
            ans += (curr_height - arr[i]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4708
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    ll x;
    cin >> x;
    ll now = 100;

    REP(i, 1, 3760){
        now *= 1.01;
        if(now >= x){
            cout << i << endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3196
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
std::pair<int, int> *w;
std::vector<std::pair<int, int>*> *p;
int N, K;
long long res = 1;
void C(int n, int b = -1) {
	if (n == 0) {
		res = K;
		for (int i = 0; i < p[0].size(); i++) {
			res *= (K - i - 1);
			res %= mod;
		}
		for (int i = 0; i < p[0].size(); i++) {
			if (p[0][i]->first == 0) {
				C(p[0][i]->second, 0);
			}
			else {
				C(p[0][i]->first, 0);
			}
		}
	}
	else {
		for (int i = 0; i < p[n].size() - 1; i++) {
			res *= (K - i - 2);
			res %= mod;
		}
		for (int i = 0; i < p[n].size(); i++) {
			if (p[n][i]->first == b || p[n][i]->second == b)continue;
			if (p[n][i]->first == n) {
				C(p[n][i]->second,n);
			}
			else {
				C(p[n][i]->first,n);
			}
		}
	}
}
int main() {
	scanf("%d %d", &N, &K);
	w = new std::pair<int, int>[N - 1];
	p = new std::vector<std::pair<int, int>*>[N];
	for (int i = 0; i < N-1; i++) {
		scanf("%d %d", &w[i].first, &w[i].second);
		w[i].first--;
		w[i].second--;
		p[w[i].first].push_back(&w[i]);
		p[w[i].second].push_back(&w[i]);
	}
	C(0);
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 9984
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let n: usize = read();
    let s: String = read();
    let chars = s.chars().collect::<Vec<_>>();
    let mut r = 0;
    let mut g = 0;
    let mut b = 0;
    for i in 0..n {
        if chars[i] == 'R' {
            r += 1;
        } else if chars[i] == 'G' {
            g += 1;
        } else {
            b += 1;
        }
    }
    let total: u64 = r * g * b;
    let mut removal: u64 = 0;
    for i in 0..n {
        for j in 0..n {
            if i < j && chars[i] != chars[j] {
                let k = j as isize * 2 - i as isize;
                if k > j as isize && k >= 0 && k < n as isize {
                    if chars[i] != chars[k as usize] && chars[j] != chars[k as usize] {
                        removal += 1;
                    }
                }
            }
        }
    }
    println!("{}", total - removal);
}


Measured memory_bytes: 2144
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

ll limit = 1ll * 1e18;

int main(){
  int n;
  ll ans = 1;
  fastScan(n);
  for(int i = 1; i <= n; i++){
    ll x;
    fastScan(x);
    if(x == 0){
      ans = 0;
      continue;
    }
    if(ans == -1 || ans == 0) continue;
    if((limit / ans) < x){
      ans = -1;
    } else {
      ans *= x;
    }
  }
  if(ans > limit) ans = -1;
  printf("%lld\n", ans);
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    ll p = round((long double) n / k);
    cout << abs(n - p*k);
}

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

int main()
{
    int d[200000];
    int alphabet_max = 26;
    long long N;
    const long long MOD = 1000000007;
    cin >> N;
    string S;
    cin >> S;
    long long kosuu[26];
    for (int i = 0; i < alphabet_max; i++)
    {
        kosuu[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (S.at(j) == 'a' + i)
            {
                kosuu[i]++;
            }
        }
        kosuu[i]++;
    }
    long long ans = 1;
    for (int i = 0; i < alphabet_max; i++)
    {
        ans *= kosuu[i];
        ans %= MOD;
    }
    if (ans == 0)
    {
        cout << MOD - 1 << endl;
        return 0;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

int main(){
	int n,c;
	cin >> n >> c;
	vector<vector<ll>> cost(3,vector<ll>(c+1,0));

	map<P,ll> mp;
	for(int i = 1;i <= c;i++){
		for(int j = 1;j <= c;j++){
			ll d;
			cin >> d;
			mp[P(i,j)] = d;
		}
	}

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

	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			for(int k = 1;k <= c;k++){
				cost[(i+j+2)%3][k] += mp[P(grid[i][j],k)];
			}
		}
	}

	ll ans = 1e10;
	for(int i = 1;i <= c;i++){
		for(int j = 1;j <= c;j++){
			for(int k = 1;k <= c;k++){
				if(i != j && j != k && i != k){
					ans = min(ans,cost[0][i] + cost[1][j] + cost[2][k]);
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1280
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 110

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, m, s, g1, g2;

int main(void) {
    while (1) {
        cin >> n >> m >> s >> g1 >> g2;
        if (n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) break;
        int dist[MAXN][MAXN];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                dist[i][j] = INF;
            }
            dist[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            dist[a][b] = c;
        }
        for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        int ans = INF;
        for (int i = 1; i <= n; i++) {
            ans = min(ans, dist[s][i] + dist[i][g1] + dist[i][g2]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
   ll N,K,Q,a,b;
   cin>>N>>K>>Q;
   vector<ll>v;
   v.assign(N,0);
   rep(i,Q){
   cin>>a;
   v[a-1]=v[a-1]+1;
   }
   rep(i,N){if(K+v[i]-Q>0){cout<<"Yes"<<endl;}
           else{cout<<"No"<<endl;}
           }
}



Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int H,W;
		
		Scanner scan = new Scanner(System.in);
		while(true)
		{
			H=scan.nextInt();
			W=scan.nextInt();
			if(H==0&&W==0)
				break;
			
			for(int i=0;i<H;i++) {
				
				for(int j=0;j<W-1&&(i==0||i+1==H)||j==0;j++) {
					System.out.printf("#");
				}
				for(int k=0;k<W-2&&i!=0&&i+1!=H;k++) {
					System.out.printf(".");
				}
				System.out.printf("#\n");
				
			}
			System.out.printf("\n");
			
		}

	}

}

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

#define lint long long
#define P pair<int, int>


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

    lint dp[N + 1][N + 1][N * 50 + 1];

    memset(dp, 0, sizeof dp);

    dp[0][0][0] = 1;
    for(int i = 0; i < N; ++i){
        for(int j = N; j >= 0; --j){
            for(int k = 0; k <= N * 50; ++k){
                if(dp[i][j][k] > 0){
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                    dp[i + 1][j][k] += dp[i][j][k];
                }
            }
        }
    }

    lint ans = 0;
    for(int i = 1; i <= N; ++i){
        ans += dp[N][i][i * A];
    }

    cout << ans << endl;


}


Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
int prim[100100],ilem;
bool vis[100100];
void get_prim(){
	for(int i=2;i<=100000;i++){
		if(!vis[i])
			prim[++ilem]=i;
		for(int j=1;j<=ilem;j++){
			if(i*(long long)prim[j]>100000) break;
			vis[i*prim[j]]=1;
			if(i%prim[j]==0) continue;
		}
	}
}
long long a[510][510];
map<long long,int> mp;
int main(){
	int n;
	scanf("%d",&n);
	if(n==2){
		printf("4 7\n");
		printf("23 10\n");
		return 0;
	}
	get_prim();
	int mxc=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=1+(i&1);j<=n;j+=2){
			cnt++;
			a[i][j]=cnt+1;
		}
	}
	while(prim[mxc]<=260) mxc++;
	for(int i=1;i<=n;i+=2){
		
		mxc++;
		for(int j=1+(i&1);j<=n;j+=2)
			a[i][j]=a[i][j]*prim[mxc];
	}
	for(int i=(n&1)?n-1:n;i>0;i-=2){
		mxc++;
		for(int j=1+(i&1);j<=n;j+=2)
			a[i][j]=a[i][j]*prim[mxc];
	}
	long long x,y;
	for(int i=1;i<=n;i++){
		for(int j=1+(!(i&1));j<=n;j+=2){
			if(i==1) x=a[i+1][j];
			else if(i==n) x=a[i-1][j];
			else x=a[i+1][j]*a[i-1][j]/__gcd(a[i+1][j],a[i-1][j]);
			if(j==1) y=a[i][j+1];
			else if(j==n) y=a[i][j-1];
			else y=a[i][j+1]*a[i][j-1]/__gcd(a[i][j+1],a[i][j-1]);
			a[i][j]=x/__gcd(x,y)*y+1;
//			if(i==n-1&&j==n-1)
//				cerr<<x<<" "<<y<<" "<<__gcd(a[i][j+1],a[i][j-1])<<endl;
//			if(a[i][j]>1e15) cerr<<"fuck"<<endl;
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
//			if(mp[a[i][j]]) cerr<<i<<" "<<j<<endl;
//			mp[a[i][j]]=1;
			printf("%lld ",a[i][j]);
		}
		printf("\n");
	}

	return 0;
}

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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long num = X;
		int count = 0;
		while(num <= Y) {
			num *= 2;
			count++;
		}
		System.out.println(count);
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844
import static java.math.BigInteger.valueOf;
import java.math.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		long a=gInt(),b=gInt(),c=gInt();
		BigInteger d=valueOf(a*b);
		BigInteger e=valueOf(c-a-b);

		if(c-a-b<0) {
			System.out.println("No");
			return;
		}

		//a+b+/ab<c

		System.out.println(d.multiply(valueOf(4)).compareTo(e.multiply(e))<0?"Yes":"No");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return (cur+d==to)||(d<0^cur+d<to);
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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


namespace Lcs
{

	int exec()
	{
		string S, T; cin >> S >> T;
		vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1, 0));
		for (int s = 0; s < S.size(); ++s) {
			for (int t = 0; t < T.size(); ++t) {
				if (S[s] == T[t]) dp[s + 1][t + 1] = dp[s][t] + 1;
				chmax(dp[s + 1][t + 1], dp[s + 1][t]);
				chmax(dp[s + 1][t + 1], dp[s][t + 1]);
			}
		}
		return dp[S.size()][T.size()];
	}
}

int main()
{
	int Q; cin >> Q;
	vector<int> anss(Q);
	for (int i = 0; i < Q; ++i) {
		anss[i] = Lcs::exec();
	}
	for (int i = 0; i < Q; ++i) {
		cout << anss[i] << endl;;
	}
}



Measured memory_bytes: 6752
#include <iostream>
#include <string>

using namespace std;

#define ll long long

int main() {

   string s, ans;
   int k;

   cin >> k;
   cin >> s;

    if(s.length() > k){
        for(int count = 0; count < k; count++){
            ans += s[count];
        }
        ans += "...";
    }
    else{
        ans = s;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
k, x = map(int, input().split())
lst = list(range(x - (k - 1), x + k))
str1 = ''
for i in range(len(lst)):
  if -1000000 <= lst[i] <= 1000000:
    str1 = str1 + str(lst[i]) + ' '
print(str1[:-1])

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define int long long
#define N 41
using namespace std;
typedef pair<int,int> P;


int Max(int &a,int b){return a=max(a,b);}

P calc(int bit,int a,int v[],int w[]){
  int rv=0,rw=0;
  for(int i=0;i<a;i++) if(bit>>i&1) rv+=v[i],rw+=w[i];
  return P(rw,rv); 
}

signed main(){
  int n,W;
  int v[N],w[N];
  cin>>n>>W;

  for(int i=0;i<n;i++) cin>>v[i]>>w[i];
  
  int a = n/2;
  int b = n - a;
  map<int,int> A;
  A[0] = 0;

  for(int i=0;i<(1<<a);i++){
    P p = calc(i,a,v,w);
    Max(A[p.first],p.second);
  }

  int mxv = 0;
  for(auto &p:A) p.second = Max(mxv,p.second);

  int ans = 0;
  for(int i=0;i<(1<<b);i++){
    P p = calc(i,b,v+a,w+a);
    int w=p.first,v = p.second;
    if(w>W)continue;
    auto it = --A.upper_bound(W-w);
    int av = it->second;
    Max(ans,v+av);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char bottom = s[s.length() - 1];
    unordered_set<string> used;
    used.insert(s);
    for (int i = 1; i < n; i++) {
        cin >> s;
        if (used.find(s) != used.end() || s[0] != bottom) {
            cout << "No" << endl;
            return 0;
        }

        bottom = s[s.length() - 1];
        used.insert(s);

    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256