akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> w(n);
    int tot = 0;
    rep(i, n)
    {
        cin >> w[i];
        tot += w[i];
    }

    int mini = MOD;
    int a = 0;
    rep(i, n)
    {
        a += w[i];
        tot -= w[i];
        mini = min(abs(a - tot), mini);
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int x;cin>>x;
  int cur=100;
  int res=0;
  while(cur<x){
    cur+=cur/100;
    ++res;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <assert.h>
#include <vector>

int main(){
    int32_t N;
    std::cin >> N;
    assert(1 <= N && N <= 100);
    std::vector<float> A(N);
    for(auto& i : A){
        std::cin >> i;
    }

    float res = 0;
    float divider = 0;
    for(auto& a : A){
        divider += (1 / a);
    }
    res = 1 / divider;
    std::cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int b[100][100], n, m;
int xx[4] = {-1, 0, 0, 1}, yy[4] = {0, -1, 1, 0};

int solv(int g[100][100], int y, int x, char c){
	if(y < 0 || x < 0 || n <= y || m <= x)return 0;
	if(c == 'a')c = g[y][x];
	if(b[y][x] || g[y][x] != c)return 0;
	b[y][x] = 1;
	for(int i = 0;i < 4;i++)solv(g, y + yy[i], x + xx[i], c);
	return 1;
}

int main(){
	int g[100][100];
	string s;
	while(cin >> n >> m, n){
		fill((int*)b, (int*)(b+100), 0);
		for(int i = 0;i < n;i++){
			cin >> s;
			for(int j = 0;j < m;j++)g[i][j] = s[j];
		}
		int ans = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				ans += solv(g, i, j, 'a');
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>  
#include <cstring> 
#include <cmath> 
#include <vector>  
#include <algorithm>      
#define ll long long   
#define N 1000003 
#define MAX 200005       
#define mod 924844033
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std;  
int n,edges; 
int hd[N],to[N],nex[N],bu[N],fac[N],inv[N],t[N],g[N],size[N],Ans[N];   
void add(int u,int v) 
{
    nex[++edges]=hd[u],hd[u]=edges,to[edges]=v;    
}
int qpow(int x,int y) 
{ 
    int tmp=1; 
    for(;y;y>>=1,x=(ll)x*x%mod) 
        if(y&1) tmp=(ll)tmp*x%mod; 
    return tmp;   
}
int INV(int x) { return qpow(x,mod-2); }      
void NTT(int *a,int len,int flag) 
{
    int i,j,k,mid;     
    for(i=k=0;i<len;++i) 
    {
        if(i>k) swap(a[i],a[k]); 
        for(j=len>>1;(k^=j)<j;j>>=1);    
    }
    for(mid=1;mid<len;mid<<=1) 
    {
        int wn=qpow(5,(mod-1)/(mid<<1));     
        if(flag==-1) wn=INV(wn);      
        for(i=0;i<len;i+=mid<<1) 
        { 
            int w=1;      
            for(j=0;j<mid;++j) 
            {
                int x=a[i+j],y=(ll)w*a[i+j+mid]%mod;         
                a[i+j]=(ll)(x+y)%mod;    
                a[i+j+mid]=(ll)(x-y+mod)%mod;    
                w=(ll)w*wn%mod;    
            }
        }
    }
    if(flag==-1) 
    {
        int in=INV(len); 
        for(i=0;i<len;++i) a[i]=(ll)a[i]*in%mod;    
    }
} 
int C(int x,int y) 
{
    if(x<y||x<0||y<0) return 0;   
    return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod;    
}
void init() 
{
    int i,j;     
    fac[0]=inv[0]=1;     
    for(i=1;i<MAX;++i) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=INV(fac[i]);       
}
void dfs(int u,int ff) 
{
    size[u]=1; 
    for(int i=hd[u];i;i=nex[i]) 
    {
        int v=to[i]; 
        if(v==ff) continue;    
        dfs(v,u); 
        size[u]+=size[v];    
        bu[size[v]]++;   
    }  
    bu[n-size[u]]++;     
}
int main() 
{     
    // setIO("input");   
    int i,j;    
    init();           
    scanf("%d",&n);   
    for(i=1;i<n;++i) 
    {
        int x,y;  
        scanf("%d%d",&x,&y),add(x,y),add(y,x);  
    }      
    dfs(1,0);  
    int ans=0;         
    for(i=0;i<=n;++i) g[i]=(ll)bu[i]*fac[i]%mod,t[n-i]=inv[i];          
    int lim=1;   
    while(lim<=2*n) lim<<=1;   
    NTT(g,lim,1),NTT(t,lim,1); 
    for(i=0;i<lim;++i) g[i]=(ll)g[i]*t[i]%mod;   
    NTT(g,lim,-1);      
    for(i=0;i<=n;++i)  Ans[i]=(ll)g[i+n]*inv[i]%mod;       
    for(i=1;i<=n;++i) 
    {
        int tmp=(ll)n*C(n,i)%mod;      
        printf("%d\n",(ll)(tmp-Ans[i]+mod)%mod);   
    }        
    return 0;   
}

Measured memory_bytes: 41600
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <sstream>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define pb(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


void bubbleSort(vector<pair<char,int> > &A, int n) {
	REP(i, n) {
		RFOR(j, n, i + 1) {
			if (A[j].second < A[j - 1].second) {
				A[j].swap(A[j-1]);
			}
		}
	}
	return;
}

void selectionSort(vector<pair<char,int> > &A, int n) {
	REP(i, n) {
		int mini = i;
		FOR(j, i, n) {
			if (A[j].second < A[mini].second) {
				mini = j;
			}
		}
		A[i].swap(A[mini]);
	}
}

int main() {
	vector<pair<char,int> > v,t;
	int n;
	cin >> n;
	REP(i, n) {
		char c;
		cin >> c;
		int a;
		cin >> a;
		v.pb(make_pair(c, a));
	}
	REP(i, n) {
		t.pb(v[i]);
	}
	bubbleSort(t, n);
	REP(i, n) {
		cout << t[i].first<< t[i].second;
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	cout << "Stable" << endl;
	selectionSort(v, n);
	REP(i, n) {
		cout << v[i].first << v[i].second;
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	int flag = 1;
	REP(i, n) {
		if (t[i] != v[i]) {
			flag = 0;
		}
	}
	if (flag) cout << "Stable" << endl;
	else cout << "Not stable" << endl;


	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    string n;
    int nsize;
    int k,Max = 9,Min = 0;
    vector<bool> d(10,true);
    cin >> n >> k;
    nsize = (int)n.size();
    rep0(i, k){
        int D;
        cin >> D;
        d[D] = false;
    }
    rep0(i, 10)if(d[i]){
        Min = i;
        break;
    }
    rrep0(i, 10)if(d[i]){
        Max = i;
        break;
    }
    
    rep0(i, nsize){
        if(!d[n[i] - 48]){
            if(n[i] - 48 < Max){
                nfor(j, n[i] - 48, 10){
                    if(d[j]){
                        n[i] = (char)j + 48;
                        nfor(k, i + 1, nsize)n[k] = (char)Min + 48;
                        break;
                    }
                }
            }else{
                rfor(j, i - 1, -2){
                    if(j == -1){
                        if(Min == 0){
                            rep1(k, 9)if(d[k]){
                                n = (char)k + 48;
                            }
                        }else{
                            n = (char)Min + 48;
                        }
                        rep0(k, nsize)n += (char)Min + 48;
                        break;
                    }
                    
                    if(n[j] < Max){
                        nfor(k, n[j] - 47, 10){
                            if(d[k]){
                                n[j] = (char)j + 48;
                                nfor(k, i + 1, nsize)n[k] = (char)Min + 48;
                                break;
                            }
                        }
                        break;
                    }
                }
            }
            
            break;
        }
    }
    pf(n)
    return 0;
}


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

int main(){
    string s; cin >> s;
    int n = s.size();
    int left = 0, right = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'A'){
            left =  i;
            break;
        }
    }
    for(int i = n-1; i >= 0; --i){
        if(s[i] == 'Z'){
            right = i;
            break;
        }
    }
    cout << right - left + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);

const int MAX=200010;


ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return k*k;
    else return k*k*a;
}


int main() {
    ios_base::sync_with_stdio(false); 

    int n,p;
    cin >> n >> p;
    int odd=0,even=0;
    rep(i,n) {
        int a;
        cin >> a;
        if (a%2==0) ++even;
        else ++odd;
    }
    ll ans;
    if (odd==0) {
        if (p==0) ans=binary_power(2,n);
        else ans=0;
    } else {
        ans=binary_power(2,n-1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		int h = sc.nextInt(), w = sc.nextInt();
		int sum = 0;
		sum = (H - h) * (W - w);
		System.out.println(sum);
	}
}

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



int main(){
	unsigned long int dp[40];
	dp[0]=1;
	dp[1]=1;
	dp[2]=2;
	for(int i=3;i<40;i++){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(cin>>n,n){
		int ans=dp[n]/10/365 +1;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

class TaskC {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a, b, c, x, y; in>>a>>b>>c>>x>>y;
		int mi = min(x, y);
		int cost = 0;
		cost += (mi*min(a+b, 2*c));
		x-=mi, y-=mi;
		if(x){
			cost += x*min(a, 2*c);
		}
		if(y){
			cost += y*min(b, 2*c);
		}
		out<<cost;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    vi luca(100);
    luca[0]=2; luca[1]=1;
    FOR(i, 2, 100) {
        luca[i] = luca[i-1]+luca[i-2];
    }

    cout << luca[N] << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
num = len(S)
count = 0
step = list(S)
for i in range(num):
  if i % 2 == 0:
    if step[i] == 'R' or step[i] == 'U' or step[i] == 'D':
      count = count + 1
    else:
      print("No")
      break
  else:
    if step[i] == 'L' or step[i] == 'U' or step[i] == 'D':
      count = count + 1
    else:
      print("No")
      break
if count == num:
  print("Yes")

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

int main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  for(int i =0; i < n; i++){
    cin >> h[i];
  }
  int num = 0;
  for(int i = 0; i < n; i++){
    if(h[i] >= k){
      num++;
    }
  }
  cout << num;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;


std::string str;
int a=0,b=0,c=0;
int length;

bool istrue(int target){
    if(length/3==target||length/3+1==target){
        return true;
    }
    else return false;
}

int main(void){
	
    cin>>str;
    length=(int)str.length();
    for(int i=0;i<length;i++){
        if(str[i]=='a')a++;
        else if(str[i]=='b')b++;
        else c++;
    }
    if(istrue(a)&&istrue(b)&&istrue(c)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N;
    cin >> N;
    if (N % 10 == 3) {
        cout << "bon" << endl;
    }else if( (N%10 == 0 || N%10 == 1) || (N%10 == 6 || N%10 == 8)){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3632
def selectionSort(a, n):
    count = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj: count += 1
    printArray(a)
    print(count)


#配列の出力
def printArray(array):
    print(' '.join(map(str, array)))

###----------mainここから---------------

#配列の要素数と要素の入力
n = int(input())
a = list(map(int, input().split()))

selectionSort(a, n)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long int n;
        cin>>n;
        long long int a,f=0;
        for(long long int i=0;i<n;i++)
        {
            cin>>a;
            if(a%2!=0)
            {
                f++;
                break;
            }
        }
        if(f==1)
            cout<<"first"<<endl;
        else
            cout<<"second"<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int h[N];
int dp[N];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    dp[n-1]=0;
    dp[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--)
        dp[i] = min(dp[i+1] + abs(h[i] - h[i+1]), dp[i + 2]+abs(h[i] - h[i + 2]));
    cout<<dp[0]; 

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d, e;
	cin>> a>>b>>c>>d;
	e = abs(a-b);
	b = abs(b-c);
	c = abs(a - c);

	if(e<=d && b<=d || c<=d){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";

		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n, k);
	vector<vector<int>> g(n);
	vector<bool> ok(n);
	int ans = 0;
	inc(i, n) {
		IN(int, a);
		a--;
		if(i == 0 && a != 0) { ans++; a = 0; }
		if(a == 0) { ok[i] = true; }
		if(i >  0) { g[a].PB(i); }
	}
	
	function<int(int)> dfs = [&](int v) {
		int h = 0;
		RF(e, g[v]) { setmax(h, dfs(e)); }
		h++;
		if(ok[v] || h < k) { return h; } else { ans++; return 0; }
	};
	dfs(0);
	OUT(ans);
}


Measured memory_bytes: 13568
from math import *
N, M = map(int, input().split())
special_value = M//N
divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
divisor_set = divisor_set.union(M//j for j in divisor_set)
print(int(max([i for i in divisor_set if special_value >= i])))


Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
template<class T> using V=vector<T>; 
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   ll n,m;
   cin>>n>>m;
   V<V<int>> graph(n-1);
   ll ma=(n-1)*(n-2)/2;
   if(ma<m){
       cout<<-1<<endl;
       return 0;
   }
   for(int i=0;i<n-1;i++){
       graph[i].push_back(n-1);
   }
   int need=ma-m;
   int cnt=n-1;
   for(int i=0;i<n-1;i++){
       for(int j=i+1;j<n-1;j++){
           if(!need)break;
            graph[i].push_back(j);
            cnt++;
            need--;
       }
   }
   cout<<cnt<<endl;
   for(int i=0;i<n-1;i++){
       for(int v:graph[i])cout<<i+1<<" "<<v+1<<endl;
   }
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    long x,a,b;
    scanf("%ld%ld%ld",&x,&a,&b);
    if(a>=b) printf("delicious");
    else if(a<b && (b-a)<=x) printf("safe");
    else printf("dangerous");
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int max_n = 100007;
vector<int> primes;

void fill_primes(){
	primes.push_back(2);
	for(int i = 3; i <= max_n ; i += 2){
		bool flg = true;
		rep(j,primes.size()){
			int p = primes[j];
			if(p*p > i) break;
			if(i % p == 0){
				flg = false;
				break;
			}
		}
		if(flg) primes.push_back(i);
	}
}

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

	fill_primes();

	bool isprime[max_n] = {};
	rep(i,primes.size()) isprime[primes[i]] = true;

	bool like2017[max_n] = {};
	for(int i = 1; i<= max_n; i += 2){
		if(isprime[i] && isprime[(i+1)/2]) like2017[i] = true;
	}

	int a[max_n] = {};
	rep(i,max_n) if(like2017[i]) a[i] = 1;

	int s[max_n] = {};
	rep(i,max_n-1) s[i+1] = s[i] + a[i+1]; 

	int q;
	cin >> q;

	rep(i,q){
		int l,r;
		cin >> l >> r;

		cout << (s[r] - s[l-1]) << endl;
	} 		
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b,c; cin >> a>>b>>c;

  if (a <= c && c <= b) {
    Yes()
  } else {
    No()
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


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

int main()
{
    long gcd(long x, long y);
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long ac, ad, bc, bd;
    if(a%c == 0) ac = a/c - 1;
    else ac = a/c;

    if(a%d == 0) ad = a/d - 1;
    else ad = a/d;

    bc = b/c;
    bd = b/d;

    long lcm = c*d/gcd(c,d);

    long alcm, blcm;
    if(a%lcm == 0) alcm = a/lcm - 1;
    else alcm = a/lcm;
    
    blcm = b/lcm;

    long ans = (b-a+1) - (bc-ac) - (bd-ad) + (blcm-alcm);

     cout << ans << endl;
    return 0; 
    

}

long gcd(long x, long y){
    if(x%y == 0){
        return y;
    }
    else{
        return gcd(y,x%y);
    }
}

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

const ll INF = 1e15;

// input
int N;
vector<int> A, B, C;
int Q, K;
vector<int> X, Y;

vv link;
vector<bool> vis;
vector<ll> w;


void input() {
    cin >> N;
    A = B = C = vector<int>(N - 1);
    rep(i, N - 1) cin >> A[i] >> B[i] >> C[i];
    cin >> Q >> K;
    X = Y = vector<int>(Q);
    rep(i, Q) cin >> X[i] >> Y[i];
}


void dfs(int u) {
    vis[u] = true;
    for (P x : link[u]) {
        if (vis[x.first]) continue;
        w[x.first] = w[u] + x.second;
        dfs(x.first);
    }
}


int main() {
    input();
    link = vv(N);
    rep(i, N - 1) {
        int a = A[i] - 1;
        int b = B[i] - 1;
        int c = C[i];
        link[a].push_back(P(b, c));
        link[b].push_back(P(a, c));
    }
    vis = vector<bool>(N, false);
    w = vector<ll>(N, INF);
    w[K - 1] = 0;
    dfs(K - 1);
    rep(i, Q) {
        ll ans = w[X[i] - 1] + w[Y[i] - 1];
        cout << ans << endl;
    }
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int h,w,k;
    cin>>h>>w>>k;
    char a[h][w];
    char dust;
    f1(i,0,h)
    {
    	f1(j,0,w)
    	cin>>a[i][j];
    }
// f1(i,0,h)
//     {
//     	f1(j,0,w)
//     	cout<<a[i][j];
//     	cout<<endl;
//     }
    int ans[h][w];
    f1(i,0,h)
    {
    	f1(j,0,w)
    	ans[i][j]=0;
    }
    int lala=-1;
    int temp=1;
    int flag=0;
    f1(i,0,h)
    {
    	f1(j,0,w)
    	{
    		if(a[i][j]=='#')
    		{
    			ans[i][j]=temp;
    			lala=i;
    			f1(l,j+1,w)
    			{
    				if(a[i][l]=='#'||ans[i][l]!=0)
    					break;
    				ans[i][l]=temp;
    			}
    			f2(l,j-1,0)
    			{
    				if(a[i][l]=='#'||ans[i][l]!=0)
    					break;
    				ans[i][l]=temp;
    			}
    			temp++;
    		}
    		//cout<<temp-1<<endl;
    		// f1(p,0,h)
    		// {
    		// 	f1(q,0,w)
    		// 	cout<<ans[p][q]<<gp;
    		// 	cout<<endl;
    		// }
    	}
    }
    // f1(i,0,h)
    // {
    // 	f1(j,0,w)
    // 	cout<<ans[i][j]<<gp;
    // 	cout<<endl;
    // }
    f1(i,lala,h)
    {
    	f1(j,0,w)
    	{
    		if(ans[i][j]==0)
    		{
    			ans[i][j]=ans[i-1][j];
    		}
    	}
    }
    f2(i,lala,0)
    {
    	f1(j,0,w)
    	{
    		if(ans[i][j]==0)
    		{
    			ans[i][j]=ans[i+1][j];
    		}
    	}
    }
    f1(i,0,h)
    {
    	f1(j,0,w)
    	cout<<ans[i][j]<<gp;
    	cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1536
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a[3];
  int k;

  cin >> a[0] >> a[1] >> a[2];
  cin >> k;
  sort(a, a+3);
  reverse(a, a+3);
  for(int i = 0; i < k; i++){
  	a[0] *= 2;
  }
  cout << a[0] + a[1] + a[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 200001
int n;
int a[MAX_NUM];

void Main() {
  //自動整形防止用コメント
  cin >> n;
  rep(i, n) {cin >> a[i];}

  int index = 0;
  int count = 0;
  rep(i, n){
    count++;
    if (a[index] == 2)
    {
      std::cout << count << std::endl;
      return;
    }

    index = a[index] - 1;
  }

  std::cout << -1 << std::endl;
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 640
S = input()
max_len = 0
temp = 0

for s in S:
	if (s == 'A') | (s == 'C') | (s == 'G') | (s == 'T'):
		temp += 1
	else:
		if temp > max_len:
			max_len = temp
		temp = 0
if temp > max_len:
    max_len = temp
print(max_len)

Measured memory_bytes: 3060
N,M=map(int, input().split()) 
A = list(map(int, input().split()))
A.sort(reverse=True)
count = 0
sumA = 0
for i in range(len(A)):
    sumA += A[i]
for i in range(len(A)):
    if A[i] >= sumA*(1/(4*M)):
        count += 1
if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> p(26);
    for(int i = 0; i < n; ++i){
        p[s[i] - 'A'].emplace_back(i);
    }
    int ans = p[25].back() - p[0][0] + 1;
    cout << ans << endl;
}

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

typedef long long LL;
const int N = 100005, M = 2154;

int n, a[N], pr[M], pt, md[M], ans;
std::map<LL, std::pair<int, int>> s;
LL x;

void sieve(int n) {
	for (int i = 2; i <= n; ++i) {
		if (!md[i]) pr[++pt] = i, md[i] = i;
		for (int j = 1, t; j <= pt && (t = i * pr[j]) <= n; ++j) {
			md[t] = pr[j];
			if (pr[j] == md[i]) break;
		}
	}
}

void factor(LL x) {
	__int128 norm = 1, pair = 1;
	for (int i = 1; i <= pt && (LL) pr[i] * pr[i] * pr[i] <= x; ++i)
		if (x % pr[i] == 0) {
			int cnt = 0;
			do ++cnt, x /= pr[i]; while (x % pr[i] == 0);
			cnt %= 3;
			if (cnt) {
				for (int j = 0; j < cnt; ++j) norm *= pr[i];
				for (int j = cnt; j < 3; ++j) pair *= pr[i];
			}
		}
	int t = std::sqrt(x);
	if ((LL) t * t == x) norm *= (LL) t * t, pair *= t;
	else norm *= x, pair *= (__int128) x * x;
	if (norm == pair) ans = 1;
	else if (norm < pair) ++s[norm].first;
	else ++s[pair].second;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, sieve(M - 1);
	for (int i = 1; i <= n; ++i) std::cin >> x, factor(x);
	for (auto i : s) ans += std::max(i.second.first, i.second.second);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6528
/*
*  Author: windystreet
*  Date  : 2019-04-13 11:07:49
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;



void solve(){
	char c;
	cin>>c;
	if(c=='A'){
		cout<<"T\n";
	}else if(c == 'T'){
		cout<<"A\n";
	}else if(c == 'G'){
		cout<<"C\n";
	}else{
		cout<<"G\n";
	}
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().split(' ')]

res = 0.0
for dice in range(1, n+1):
    tmp = dice
    cnt = 0
    while k > tmp:
        tmp *= 2
        cnt += 1
    res += (1 / n) * (0.5 ** cnt)

print(res)

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

int main() {
  int h, n;
  cin >> h >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  bool ans = false;
  for (int i = 0; i < n; i++) {
    if (a.at(i) >= h) {
      ans = true;
      break;
     }
    else  h -= a.at(i);
  }
  
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)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 arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  int tmp=0, ans=0;
  rep(i,n){
    if(s[i]=='S') tmp++;
    if(s[i]=='T'){
      if(tmp>0) ans++, tmp--;
    }
  }
  prt(n-2*ans);
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int X;
  cin >> X;
  vector<bool> exp(X+1);
  exp[1] = 1;
  for (int i = 2; i <= X; i++) {
    int B = i*i;
    while (B <= X) {
      exp[B] = true;
      B = B*i;
    }
  }
  for (int i = X; i>= 1; i--) {
    if (exp[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#define NDEBUG
#include<deque>
#include<functional>
#include<utility>
#include<cstddef>
#include<cassert>

template<class T,class Container=std::deque<std::pair<T,std::size_t>>, class Compare = std::less<T>>
class SlidingMinimum{
public:
	using container_type = Container;
	using value_compare = Compare;
	using value_type = T;
	using size_type = typename container_type::size_type;
	using const_reference = const T&;
private:
	container_type c;
	value_compare comp;
	size_type s;
public:
	SlidingMinimum(const value_compare &x = value_compare()) :comp(x),s(1){}
	bool empty()const{
		return c.empty();
	}
	value_type top()const{
		assert(!empty());
		return c.front().first;
	}
	size_type top_index()const{
		assert(!empty());
		return c.front().second - s;
	}
	void push(const value_type &x){
		size_type cnt = 1;
		while (!empty() && comp(x, c.back().first)){
			cnt += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<value_type, size_type>(x, cnt));
	}
	void push(value_type &&x){
		size_type cnt = 1;
		while (!empty() && comp(x, c.back().first)){
			cnt += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<value_type, size_type>(std::move(x), s));
	}
	void pop(){
		assert(!empty());
		if (c.front().second == s){
			c.pop_front();
			s = 0;
		}
		++s;
	}
	void clear(){
		c.clear();
		s = 1;
	}
};


using uint = unsigned int;
class mydeque{
	static constexpr uint SIZ = 1000000;
//#define SIZ 1000
	using value_type = std::pair < uint, std::size_t >;
	value_type a[SIZ];
	std::size_t l, r;
	
public:
	using size_type = std::size_t;
	mydeque():l(0),r(0){ --r; }
     value_type front()const{ return a[l]; }
	 std::pair<uint, size_type> back()const{ return a[r]; }
	 bool empty()const{ return r + 1 == l; }
	 void push_front(value_type x){
		 a[--l] = x;
	 }
	 void push_back(value_type x){
		 a[++r] = x;
	 }
	 void pop_front(){
		 ++l;
	 }
	 void pop_back(){
		 --r;
	 }
	 void clear(){
		 l = r = 0;
		 --r;
	 }
};


#include<cstdio>
#include<utility>

int main(){
	using uint = unsigned int;
	uint n, l;
	scanf("%u%u", &n, &l);
	SlidingMinimum<uint,mydeque> S;
	uint a;
	n -= l;
	while (l--){
		scanf("%u", &a);
		S.push(a);
	}
	printf("%u", S.top());
	while (n--){
		S.pop();
		scanf("%u", &a);
		S.push(a);
		printf(" %u", S.top());
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 18380
n,k = map(int,input().split())
mod = 10**9 + 7
a = sorted(list(map(int,input().split())))

def factorial(N,MOD,r=True):
    fact = [1]*(N+1)
    rfact = [1]*(N+1)
    r = 1
    for i in range(1,N+1):
        fact[i] = r = r * i % MOD
    rfact[N] = r = pow(fact[N],MOD-2,MOD)
    for i in range(N, 0, -1):
        rfact[i-1] = r = r * i % MOD
    if r:
        return fact,rfact
    else:
        return fact
fact,rfact = factorial(n,mod)


def comb(n,k): #上のfactorialと併用
    return fact[n]*rfact[k]*rfact[n-k]%mod

ans = 0
for i in range(k,n+1):
    ans += comb(i-1,k-1)*a[i-1]
    ans %= mod

for i in range(1,n-k+2):
    ans -= comb(n-i,k-1)*a[i-1]
    ans %= mod


print(ans)

Measured memory_bytes: 63344
def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = None
                    break
    for i in range(3):
        for j in range(3):
            if A[i][j] is not None:
                break
        else:
            print("Yes")
            return
    for i in range(3):
        for j in range(3):
            if A[j][i] is not None:
                break
        else:
            print("Yes")
            return
    if all(map(lambda x: x is None, [A[0][0], A[1][1], A[2][2]])) or all(map(lambda x: x is None, [A[0][2], A[1][1], A[2][0]])):
        print("Yes")
        return
    print("No")


if '__main__' == __name__:
    resolve()

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

typedef long long ll;

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main() {
    scanf("%d %d ", &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%d %d ", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) sort(yd[i + 1].begin(), yd[i + 1].end());

    for (int i = 0; i < M; i++) {
        auto lb  = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]);
        int rank = lb - yd[P[i]].begin() + 1;
        printf("%06d%06d\n", P[i], rank);
    }
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 a,b;
  cin >>a >> b;
  cout << a * b;
  hinata;
}

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

bool isPrime(int x) {
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;

    for(int i=3; i<=sqrt(x); i=i+2) {
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    int X; cin >> X;
    while(!isPrime(X)) ++X;
    cout << X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    string S;
    int ans=0;
    cin >> S;
    int N=S.size();
    for(int i=0; i<N; i++){
        int count=0;
        for(int j=i; j<N; j++){
            if(S.at(j)=='A' || S.at(j)=='T' || S.at(j)=='G' || S.at(j)=='C') {
                count++;
                continue;

            }
            else{
                break;
            }

        }
        chmax(ans,count);
        
    }

    cout << ans << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int main(){
    int n, x, y, k;
    cin >> n >> x >> y;
    vector<int> v(n, 0);
    for (int i=1; i<n; i++){
        for (int j=i+1; j<=n; j++){
            k = min(j-i,abs(i-x)+abs(y-j)+1);
            v[k]++;
        }
    }    
    for (int i=1; i<n; i++){
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    priority_queue<int> que;
    rep(i, N){
        if(B[(i+1)%N] + B[(i+N-1)%N] < B[i]) que.push(i);
    }
    ll count = 0;
    while(!que.empty()){
        int i = que.top();
        que.pop();
        if(A[i] > B[i]) break;
        elif(A[i] == B[i]) continue;
        int j = (i+1)%N;
        int k = (i+N-1)%N;
        ll sum = B[j] + B[k];
        if(A[i] % sum == B[i] % sum){
            count += (B[i]-A[i])/sum;
            B[i] = A[i];
        }
        else{
            if(B[i] % sum == 0){
                count += (B[i]/sum)-1;
                B[i] = sum;
            }
            else{
                count += B[i]/sum;                
                B[i] %= sum;
            }
        }
        if(B[j] > B[(j+1)%N] + B[i]) que.push(j);
        if(B[k] > B[i] + B[(k+N-1)%N]) que.push(k);
    }
    bool able = true;
    rep(i, N){
        if(A[i] != B[i]) able = false;
    }
    if(able) cout << count << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 4092
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in(), c = in();
	cout << (a * b * c % 2 == 0 ? 0 : min({ a * b,b * c,c * a })) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

// 最大公約数を求める
template<typename T> T gcd(T a, T b)
{
	return b ? gcd(b, a % b) : a;
}


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

	ll a, b;
	cin >> a >> b;

	ll c = gcd(a, b);
	ll res = 1;

	for (ll i = 2; i * i <= c; i++)
	{
		if (c % i == 0)
		{
			res++;
			while (c % i == 0)
			{
				c /= i;
			}
		}
	}

	if (c != 1)
	{
		res++;
	}

	cout << res << endl;
}


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

int main(){
  int n, yen; cin >> n >> yen;
  int ans = 0;
  int amount = 0;
  for(int x=0; x<=n; x++){
    for(int y=0; y<=n-x; y++){
      int z = n - x - y;
      if(z>=0){
        amount = 10000*x + 5000*y + 1000*z;
      	if(amount == yen){
        printf("%d %d %d", x, y, z);
        return 0;
        }
      }
      else{amount = 0;}
    }
  }
  printf("%d %d %d", -1, -1, -1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,K;
const int MOD = 1e9+7;

int DP[101][100001], prefix[101][100001];
int A[101];

int solve(){
	for(int i=0;i<=N;i++) DP[i][0]=prefix[i][0]=1;
	for(int i=0;i<=K;i++) prefix[0][i]=1;
	
	for(int i=1;i<=N;i++){
		for(int j=1;j<=K;j++){
			int first=0;
			if(j>A[i]){
				first=prefix[i-1][j-A[i]-1];
			}
			int last=prefix[i-1][j];
			DP[i][j]=((last%MOD-first%MOD)%MOD+MOD)%MOD;
			prefix[i][j]=((DP[i][j]+prefix[i][j-1])%MOD+MOD)%MOD;
		}
	}
	return DP[N][K];
}

int main(){
	cin>>N>>K;
	for(int i=1;i<=N;i++){
		cin>>A[i];	
	}
	cout<<solve()<<"\n";
	return 0;
}


Measured memory_bytes: 79104