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

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<double, double> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

string debug_show(P a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}



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

	string S;
	cin >> S;
	if (S[0] == 'Y'&&S[1] == 'A'&&S[2] == 'K'&&S[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define outbit(X,n) cout << bitset<n>(X) << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n,m; cin >> n >> m;
	vi a(m),b(m); vvi c(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		c[i] = vi(b[i]);
		rep(j,b[i]) cin >> c[i][j];
	}
	int states = (1<<n);
	vi key(m,0);
	rep(i,m)rep(j,b[i]) key[i] |= (1<<(c[i][j]-1));
	vi dp(states,INF);
	dp[0]=0;
	rep(s,states)rep(i,m){
		dp[s|key[i]] = min(dp[s|key[i]],dp[s]+a[i]);
//		outbit(s|key[i],12);
//		out(dp[s|key[i]]);
	}
	if(dp[states-1]==INF) cout << -1 << endl;
	else cout << dp[states-1] << endl;
	
}




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

using namespace std;

int main(){
    string str;
    cin >> str;
    int left = 0;
    int right = str.size()-1;
    int flag=1;
    while(flag&&left<right){
        if(str[left]!=str[right]){
            flag = 0;
        }
        left++;
        right--;
    }
    
    left = 0;
    right = (str.size()-1)/2-1;
    int flag1=1;
    while(flag1&&left<right){
        if(str[left]!=str[right]){
            flag1 = 0;
        }
        left++;
        right--;
    }

    left = (str.size()+3)/2-1;
    right = str.size()-1;
    int flag2=1;
    while(flag2&&left<right){
        if(str[left]!=str[right]){
            flag2 = 0;
        }
        left++;
        right--;
    }
    if(flag&&flag1&&flag2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
  int n;
  scanf("%d",&n);
  
  int a[n];
  int i;
  int cnt_odd=0,cnt_four=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<n;i++)
  {
    if(a[i]%2==1)
    {
      cnt_odd++;
    }
    if(a[i]%4==0)
    {
      cnt_four++;
    }
  }
  
  if(cnt_odd>(n+1)/2)
  {
    printf("No\n");
  }
  
  else if(1<=cnt_odd&&cnt_odd<=(n+1)/2)
  {
    if(n%2==0)
    {
     if(cnt_four<cnt_odd)
     {
      printf("No\n");
     }
     else if(cnt_four>=cnt_odd)
     {
      printf("Yes\n");
     }
    }
  
   else
   {
    if(cnt_four<cnt_odd/2)
     {
      printf("No\n");
     }
     else if(cnt_four>=cnt_odd/2)
     {
      printf("Yes\n");
     }
   }
  }
  
  else if(cnt_odd==0)
  {
    printf("Yes\n");
  }
  
  return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())
x=list(map(int,input().split()))
"""
2 5
10 12 1 2 14
1 2 10 12 14
->5
3 7
-10 -3 0 9 -100 2 17
-100 -10 -3 0 2 9 17
->19
100 1
-100000
->0
"""
if n >= m:
  print(0)
else:
  x.sort()
  xd=[]
  xp=x[0]
  for xi in x[1:]:
    xd.append(xi-xp)
    xp=xi
  xd.sort(reverse=True)
  print(sum(xd[n-1:]))


Measured memory_bytes: 13968
# Binary Search Tree
class Node:
    def __init__(self, v):
        self.value = v
        self.parent = None
        self.left = None
        self.right = None

# 木の根を引数として受け取り，データを挿入した新しい木の根を返す
def insert_(node, x):
    if node is None:
        return Node(x)
    elif x == node.value:
        return node
    elif x < node.value:
        node.left = insert(node.left, x)
    else:
        node.right = insert(node.right, x)
    return node

# 再帰を使わないパターン
def insert(node):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if node.value < x.value:
            x = x.left
        else:
            x = x.right
    node.parent = y
    if y is None:
        root = node
    elif node.value < y.value:
        y.left = node
    else:
        y.right = node

def preorder_walk(node):
    if node:
        yield node.value
        for x in preorder_walk(node.left):
            yield x
        for x in preorder_walk(node.right):
            yield x

def inorder_walk(node):
    if node:
        for x in inorder_walk(node.left):
            yield x
        yield node.value
        for x in inorder_walk(node.right):
            yield x

root = None
n = int(input())
for i in range(n):
    cmd, *val = input().split()
    if cmd == "insert":
        #root = insert(root, int(val[0]))
        insert(Node(int(val[0])))
    elif cmd == "print":
        print("", *inorder_walk(root))
        print("", *preorder_walk(root))


Measured memory_bytes: 112728
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
int a,b;
int main(){
	a=gi(),b=gi();
	int l=min(b,0);
	if(l<a){
		puts("Positive");
	}
	else if(a<l&&b>=0){
		puts("Zero");
	}else{
		int qwq=l-a+1;
		puts(qwq&1?"Negative":"Positive");
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

ll l[200000];
int n;
void solve() {
  cin >> n;
  for(int i = 0; i <= n; i++) cin >> l[i];
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    ll dec;
    cin >> dec;
    ll take = min(dec, l[i]);
    l[i] -= take;
    dec -= take;
    ret += take;
    take = min(dec, l[i+1]);
    l[i+1] -= take;
    dec -= take;
    ret += take;
  }
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };

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

	string str;
	cin >> str;
	int cnt;
	if (str.size() % 2 == 0)cnt = str.size() / 2;
	else cnt = (str.size() - 1) / 2;
	rep(i, cnt) {
		//cout << str.at(i) << " " << str.at(str.size() - i - 1) << endl;
		if (str.at(i) != str.at(str.size() - i - 1 )) {
			No;
		}
	}
	/*
	cout << endl;
	*/
	int cntr;
	if (str.size() % 2 == 0)cntr = str.size() / 2;
	else cntr = (str.size() - 1) / 2;
	rep(i, cntr) {
		//cout << str.at(i) << " " << str.at(cntr - i - 1) << " " << cntr - i - 1 << endl;
		if (str.at(i) != str.at(cntr - i - 1)) {
			No;
		}
	}
	Yes;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[110][22];
int main()
{

    int n;
    int flag=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf(" %s",a[i]);
        if(i>0&&a[i][0]!=a[i-1][strlen(a[i-1])-1])
            flag=0;
        for(int j=0;j<i;j++)
            if(strcmp(a[i],a[j])==0)
                flag=0;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[0]*5
for i in range(n):
	x=input()
	if x[0]=="M":
		a[0]+=1
	elif x[0]=="A":
		a[1]+=1
	elif x[0]=="R":
		a[2]+=1
	elif x[0]=="C":
		a[3]+=1
	elif x[0]=="H":
		a[4]+=1
a.sort()
a.reverse()
ans=0
for i in range(5):
	for j in range(i):
		for k in range(j):
			ans+=a[i]*a[j]*a[k]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        cnt += s[i] - '0';
        cnt %= 9;
    }
    y_n(cnt == 0);
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

vector <ll> v;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, K;
    cin >> N >> K;

    for(ll i=0; i<K; i++)
    {
        ll a;
        cin >> a;

        v.pb(a);
    }

    ll t = N;
    while(1)
    {
        ll temp = t;

        ll flag = 0;
        while(temp)
        {
            flag = 0;
            ll cur = temp%10;

            for(ll i=0; i<sz(v); i++)
            {
                if(cur==v[i])
                {
                    flag = 1;
                    break;
                }
            }

            if(flag)
            {
                break;
            }

            temp/=10;
        }

        if(flag==0)
        {
            cout << t << endl;
            return 0;
        }

        t++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	bool ch=true;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		if(now%2==0){
			if(now%3!=0&&now%5!=0){
				ch=false;
			}
		}
	}
	cout << (ch?"APPROVED":"DENIED");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[][] D=new int[c][c];
		int[][] C=new int[n][n];
		for(int i = 0; i<c; i++){
			for(int j = 0; j<c; j++){
				D[i][j]=sc.nextInt();
			}
		}
		for(int i = 0; i<n; i++){
			for(int j = 0; j<n; j++){
				C[i][j]=sc.nextInt();
			}
		}
		int[][] q=new int[3][c];
		for(int i = 0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<c; k++){
					q[(i+j)%3][k]+=D[C[i][j]-1][k];
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int i = 0; i<c; i++){
			for(int j = 0; j<c; j++){
				for(int k = 0; k<c; k++){
					if(i!=j && i!=k && j!=k){
						ans=Math.min(ans,q[0][i]+q[1][j]+q[2][k]);
					}
				}
			}
		}
		System.out.println(ans);
	}
}

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




#define INF INT_MAX/2
int N, M, A, B, C;
set<int> dp[101][50];
int dist[50];
// -----------------------------------------------------------
int main()
{
	cin >> N >> M >> A >> B >> C;
	
	rep(i,0,N) dp[0][i].insert(i);
	rep(i,0,M) 
	{
		int u, v; cin >> u >> v;
		u--; v--;
		dp[1][u].insert(v);
	}

    rep(i,2,101) rep(j,0,N)
    {
        for(set<int>::iterator ite = dp[i-1][j].begin();ite != dp[i-1][j].end();ite++) 
        {
            int ii = *ite;
            for(set<int>::iterator ite = dp[1][ii].begin();ite != dp[1][ii].end();ite++) dp[i][j].insert(*ite);
        }
    }
    
    rep(i,0,N) dist[i] = INF;
    dist[N - 1] = 0;
	bool con = true;
	while(con)
	{
        con = false;
        rep(i, 0, N)
        {
            int m = 0, mm;
            bool AA = false;
            mm = INF;
            for(set<int>::iterator ite = dp[A][i].begin();ite != dp[A][i].end();ite++) 
            {
                int j = *ite;
                if(dist[j] < INF)
                {
                    AA = true;
                    mm = min(mm, dist[j]);
                }
            }
            m = max(m,mm);

            bool BB = false;
            mm = INF;
            for(set<int>::iterator ite = dp[B][i].begin();ite != dp[B][i].end();ite++) 
            {
                int j = *ite;
                if(dist[j] < INF)
                {
                    BB = true;
                    mm = min(mm, dist[j]);
                }
            }
            m = max(m, mm);
            
            bool CC = false;
            mm = INF;
            for(set<int>::iterator ite = dp[C][i].begin();ite != dp[C][i].end();ite++) 
            {
                int j = *ite;
                if(dist[j] < INF)
                {
                    CC = true;
                    mm = min(mm, dist[j]);
                }
            }
            m = max(m, mm);
            
            if((AA && (BB && CC)) && m + 1 < dist[i])
            {
                dist[i] = m + 1;
                con = true;
            }
        }
	}
	
	//rep(i,0,N) cout << dist[i] << endl;
	
	if(dist[0] == INF)
	    cout << "IMPOSSIBLE" << endl;
	else
    	cout << dist[0] << endl;	
}

Measured memory_bytes: 14900
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int n, i;
	int input;
	vector<int> price;

	cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> input;
		price.push_back(input);
	}

	int result = *(max_element(price.begin(), price.end()));
	result /= 2;
	price.erase(max_element(price.begin(), price.end()));

    for (i = 0; i < n - 1; i++)
		result += price[i];

	cout << result << endl;
	
	return 0;
}


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

using ll = long long;

int main() {
	int N;
	cin >> N;
	ll ans = 1;
	const ll ma = 1'000'000'000'000'000'000ll;
	vector<ll> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (ans > ma || ans > ma / A[i]) {
			ans = -1;
			break;
		}
		ans *= A[i];
	}
	if (ans > ma) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String[] s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ");
		int k = sc.nextInt();


		System.out.println(s[k-1]);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if((a+b)%3==0)
        {
            cout<<"Possible"<<endl;
        }
        else if(a%3==0)
        {
           cout<<"Possible"<<endl; 
        }
        else if(b%3==0)
        {
             cout<<"Possible"<<endl; 
        }
        else
        {
            cout<<"Impossible"<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool v[1000001];
void solve()
{
    v[0]=false;
    v[1]=false;

    for(int i=2;i<=1000000;i++)
        v[i]=true;
    for(ll i=2;i<=1000000;i++)
    {
        if(v[i]==true)
        {
        for(ll j=i*i;j<=1000000;j+=i)
               v[j]=false;
        }
    }
}
int main()
{
 int n;
 cin>>n;
  solve();

  int i;
  for(i=n;i<=1000000;i++)
  {
    if(v[i]==true)
      break;
  }
  cout<<i<<"\n";
return 0;
}


Measured memory_bytes: 4612
def merge(arr, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = []
  for i in 0...n1
    l << arr[left + i]
  end
  r = []
  for i in 0...n2
    r << arr[mid + i]
  end
  l << Float::INFINITY
  r << Float::INFINITY
  i = 0
  j = 0
  for k in left...right
    if l[i] <= r[j]
      arr[k] = l[i]
      i += 1
    else
      arr[k] = r[j]
      j += 1
      $cnt += n1 - i
    end
  end
end

def merge_sort(arr, left, right)
  if left + 1 < right
    mid = (left + right) / 2
    merge_sort(arr, left, mid)
    merge_sort(arr, mid, right)
    merge(arr, left, mid, right)
  end
end

n = gets.to_i
s = gets.split.map(&:to_i)
$cnt = 0
merge_sort(s, 0, n)
puts $cnt


Measured memory_bytes: 34800
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        vll a(5);
        rep(i, 5) {
            cin >> a[i];
        }
        ll k;
        cin >> k;
        rep(i, 5) {
            rep(j, 5) {
                if (abs(a[i] - a[j]) > k) {
                    cout << ":(" << endl;
                    return 0;
                }
            }
        }
        cout << "Yay!" << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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


int main() {
    ll N, M, X;
    cin >> N >> M >> X; 
    vector<ll> A(M);
    rep(i,M) cin >> A[i];

    ll up = 0;
    ll down = 0;
    rep(i,M) {
        if(A[i] > X) up++;
        else down++;
    }
    cout << min(up, down) << endl;
}




Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(int num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   int ans=0;
   for(int i=0;i<N-1;i++){
      if(a[i]==a[i+1]) {
         ans++;
         a[i+1]=10000-a[i];
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
prv_count=-1#人の見て追加

#flag=True
while count!=prv_count:
    prv_count=count
    for i in range(-1,n-1):
        tonari=B[i-1]+B[i+1]
        tmp=(B[i]-A[i])//tonari
        if tmp>0:
            B[i]-=tonari*tmp
            count+=tmp
            #flag=True
if A==B:
    print(count)
else:
    print(-1)


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

int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<char>> mp(H+10,vector<char>(W+10));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> mp[i][j];
        }
    }
    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(mp[i][j]=='#'){
                bool flag=false;
                for(int l=0;l<4;l++){
                    int tempy=i+dy[l],tempx=j+dx[l];
                    if(tempx<0 || tempx>W || tempy<0 || tempy>H) continue;
                    
                    if(mp[tempy][tempx]=='#'){
                        flag=true;
                    }
                }
                if(flag==false){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max 11
typedef struct {
 int time;
 char name[max];
}process;

int main() {
 int i=0;
 int j;
 int n, q;
 int totaltime =0;
 scanf("%d %d", &n, &q);

 if (n > 100000 || q > 1000) return 0;

 process process[50000];
 for (i = 0; i <n; i++) {
  scanf("%s %d", process[i].name, &process[i].time);
 }


 for(;;){
  for (i = 0; i < n; i++) {
   process[i].time = process[i].time - q;

   if (process[i].time <= 0) {
    totaltime = (totaltime + process[i].time + q);
    printf("%s %d\n", process[i].name, totaltime);
    for (j = i; j < n - 1; j++) {
     process[j] = process[j + 1];
    }
    n--;
    i--;
   }

   else totaltime = totaltime + q;
  }

  if (n == 0) break;
 }

 return 0;
}





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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << min({P+Q, Q+R, P+R}) << endl;
}


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

const int maxn = 1e5;
vector<bool> prime;
vector<int> sumlike2017;

int main() {
  int q;
  cin >> q;
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  prime.resize(maxn + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= maxn + 1; i++) {
    if (!prime[i]) continue;
    for (int j = 2 * i; j < maxn + 1; j += i) {
      prime[j] = false;
    }
  }
  sumlike2017.resize(maxn + 1, 0);
  for (int i = 0; i < maxn; i++) {
    sumlike2017[i + 1] =
        sumlike2017[i] + (i != 2 && prime[i] && prime[(i + 1) / 2]);
  }

  for (int i = 0; i < q; i++) {
    cout << sumlike2017[r[i] + 1] - sumlike2017[l[i]] << endl;
  }
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
using namespace std;

typedef long long ll;
const double INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int arr[MAXN];

int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int ans=0;
        for(int i=0;i<n;i++){
            scanf("%d",&arr[i]);
            if(arr[i]>=k) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

int A, B;

int main() {
    cin >> A >> B;
    if (B % A == 0) cout << B + A << endl;
    else cout << B - A << endl;
    return 0;    
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, T;
    cin >> N >> T;
    ll t[N];
    rep(i, N) cin >> t[i];
    ll X = T;
    rep(i, N - 1) X += min(T, t[i + 1] - t[i]);

    cout << X << endl;


    return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    M=[None]*n
    for i in range(n):
        M[i]=list(map(lambda x:int(x)-1,input().split()))[::-1]

    # i が誰かしらと対戦できるか
    def check(i):
        if(not M[i]): # 既に試合を終えている
            return False
        j=M[i][-1]
        if(not M[j]): # これは起こり得ない
            return False
        return i==M[j][-1]

    # 初日に対戦できる人をピックアップ
    # 重複が起こるが、後で unique を取る
    Q=[]
    for i in range(n):
        if(check(i)):
            j=M[i][-1]
            if(i>j): i,j=j,i # i<j
            Q.append((i,j))

    # 処理を行なっていく
    day=0
    nQ=[] # 次の試合相手
    while(Q):
        # Q には重複があるので unique
        Q=list(set(Q))
        # 先に全ての試合を終わらせる必要がある
        for i,j in Q:
            M[i].pop(); M[j].pop()
        # 試合を終えた人は次の試合を行える可能性がある
        for i,j in Q:
            if(check(i)):
                k=M[i][-1]
                nQ.append((min(i,k),max(i,k)))
            if(check(j)):
                k=M[j][-1]
                nQ.append((min(j,k),max(j,k)))
        Q,nQ=nQ,[]
        day+=1

    print(day if(all(M[i]==[] for i in range(n))) else "-1")
resolve()

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

void solve(int N)
{
    int64_t res = 0;
    for (int k = 1; k <= N; k++)
    {
        int64_t x = N / k;
        res += x * (x + 1) / 2 * k;
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3556
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	while (true) {
		int n, r;
		cin >> n >> r;
		if (n == 0) return 0;
		vector<int> hana;
		REP(i, n) {
			hana.push_back(n - i);
		}
		REP(i, r) {
			int a, b;
			cin >> a >> b;
			vector<int> new_hana;
			for (int q = 0; q < b; ++q) {
				new_hana.push_back(hana[q + (a-1)]);
			}
			for (int q = 0; q < hana.size(); ++q) {
				if (q < a - 1 || a - 1 + b <= q) {
					new_hana.push_back(hana[q]);
				}
			}
			hana = new_hana;
		}
		cout << hana[0] << endl;
	}
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    S = input()
    dic = [chr(i) for i in range(97, 123)]
    j=0
    for i in range(len(dic)):
        if dic[i] not in S:
            j = 1
            print(dic[i])
            break
    if j == 0:
        print('None')

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

const int type[3][2]={{1,2},{0,2},{0,1}};

void reset(int[][3][2],int,int);

int main(void){
	int N,K,B[100]={0},pst[100][3][2],sum=0;

	cin >> N >> K;

	for(int i=0;i<K;i++){
		int day;
		cin >> day;
		cin >> B[day-1];
	}

	for(int i=0;i<3;i++){
		pst[0][i][0]=1;
		pst[0][i][1]=0;
	}
	if(B[0])
		reset(pst,B[0],0);

	for(int i=1;i<N;i++){
		for(int j=0;j<3;j++){
			pst[i][j][0]=0;
			for(int k=0;k<2;k++)
				(pst[i][j][0]+=(pst[i-1][type[j][k]][0]+pst[i-1][type[j][k]][1]))%=10000;
			pst[i][j][1]=pst[i-1][j][0];
		}
		if(B[i])
			reset(pst,B[i],i);
	}

	for(int i=0;i<3;i++)
		sum+=(pst[N-1][i][0]+pst[N-1][i][1]);
	cout << sum%10000 << endl;

	return 0;
}

void reset(int pst[][3][2],int num,int i){
	for(int j=0;j<2;j++)
		for(int k=0;k<2;k++)
			pst[i][type[num-1][j]][k]=0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	ll a,b,n;
	cin >> a>>b>>n;
	if(n >= b){
		cout << (a*(b-1))/b << endl;
	}
	else cout << (a*n)/b<<endl;

	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(){
	int array[10],tmp,i=0,j;
	
	while(i<10)
		scanf("%d",&array[i++]);
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			if(array[i]>array[j]){
				tmp = array[i];
				array[i] = array[j];
				array[j] = tmp;
			}
	for(i=0;i<3;i++)
		printf("%d\n",array[i]);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(std::string s){
    ll N = s.length();
    if(N==2){
        if(s[0]==s[1]) cout<<1<<" "<<2<<endl;
        else cout<<-1<<" "<<-1<<endl;
        return;
    }
    REP(i, N-2){
        string tmp=s.substr(i, 3);
        set<char> r(ALL(tmp));
        if(r.size()<3){
            cout<<i+1<<" "<<i+3<<endl;
            return;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


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

using namespace std;

int n, k;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int i, a;
	
	cin >> n;
	
	for(i=0; i<n; i++){
		cin >> a;
		if(a & 1) k ++;
	}
	
	cout << (~k & 1 ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma once

#include <bits/stdc++.h>

//https://atcoder.jp/contests/abc164/tasks/abc164_e
//https://www.ioi-jp.org/camp/2007/2007-sp-tasks/2007-sp-day3_23.pdf#page=2

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll INF = 1e15;

struct edge {
	ll to;
	ll cost;
	ll time;
};

struct Data {
	ll node;
	ll cost;
	ll time;
	Data(ll node, ll cost, ll time) : node(node), cost(cost), time(time) {}
	bool operator < (const Data& data) const {
		return time > data.time;
	}
	bool operator > (const Data& data) const {
		return time < data.time;
	}
};

int main(void)
{
	ll n, m, s;
	cin >> n >> m >> s;
	s = min(s, 50LL * 100);

	vector<vector<edge>> edges(n + m);
	rep(i, m) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edges[u].push_back({ v, -a, b });
		edges[v].push_back({ u, -a, b });
	}
	rep(i, n) {
		ll c, d;
		cin >> c >> d;
		edges[i].push_back({ i, c, d });
	}
	vector<vector<ll>> dp(n, vector<ll>(50 * 101, INF));
	priority_queue<Data> q;
	q.emplace(0, s, 0);
	dp[0][s] = 0;
	while (q.size()) {
		auto t = q.top(); q.pop();
		for (auto& e : edges[t.node]) {
			auto to = e.to;
			auto cost = t.cost + e.cost;
			cost = min(cost, 50LL * 100);
			auto time = t.time + e.time;
			if (cost < 0) continue;
			if (dp[to][cost] <= time) continue;
			dp[to][cost] = time;
			q.emplace(to, cost, time);
		}
	}
	vector<ll> r(n, INF);
	rep(i, n - 1) {
		rep(j, 50 * 101) {
			r[i + 1] = min(r[i + 1], dp[i + 1][j]);
		}
	}
	rep(i, n - 1) {
		cout << r[i + 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 11504
/**
 *      ABC 79 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-03 01:32:22
**/

#include <bits/stdc++.h>
using namespace std;

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

    if (N[0] == N[1] && N[1] == N[2]){
        cout << "Yes" << endl;
    }    
    else if (N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      k: usize,
      aa: [usize; n],
    }
    let half = n/2 + n%2;
    let mut v_max = 0;
    for dd in (0..41).rev() {
        let v = 1 << dd;
        let mut cnt = 0;
        for i in 0..n {
            if aa[i] & v > 0 {
                cnt += 1;
            }
        }
        if cnt < half {
            v_max += v;
        }
    }

    let mut ans = 0;
    let k = k+1;
    for i in 0..41 {
        let mut v = 0;
        for j in i+1..41 {
            if k & (1 << j) > 0 {
                v += 1 << j;
            }
        }

        if k & (1 << i) == 0 {
            continue;
        }

        for j in 0..i {
            if v_max & (1 << j) > 0 {
                v += 1 << j;
            }
        }
        let mut xor = 0;
        for i in 0..n {
            xor += aa[i] ^ v;
        }
        ans = max(ans, xor);
    }
    println!("{}", ans);
}

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

using namespace std;

int main()
{
	int n;
	int d[110];

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

	set < int >values;
	for (int i = 0; i < n; i++) {
		values.insert(d[i]);
	}

	cout << values.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;
double pi=3.141592653589793238;

using Graph = vector<vector<int>>;



int main() {
  int n,m;
  cin>>n>>m;
  vin a(m),b(m);
  rep(i,m) {
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
  }
  ///////
  bool ans=true;
  Graph G(n);
    for (int i = 0; i < m; ++i) {        
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
  vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
  
   dist[0] = 0;
    que.push(0);
  
   while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
  
  rep(i,n){
    if(dist[i]==-1){
       ans=false;
    }
  }
  
 
  if(ans){
    cout<<"Yes"<<endl;
    for(int i=1;i<=n-1;i++){ //i番目について
     int ew; 
    int f=dist[i];  
     for(auto ni:G[i]){ //iからいける部屋を探す
       if(dist[ni]==f-1){
         ew=ni;
       }
     }
     cout<<ew+1<<endl; 
    }
  }
  else{
   cout<<"No"<<endl; 
  }
}

Measured memory_bytes: 11760
////**********CODED BY :- DURGESH KUMAR***************////
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define test ll t;cin>>t;while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
using namespace std;
int main()
{

ll n,k,q;
cin>>n>>k>>q;
ll j=q;
ll arr[n];
REP(i,n)
arr[i]=0;
ll a;
while(q--)
{
    cin>>a;
    arr[a-1]++;

}
/*REP(i,n)
cout<<arr[i]<<" ";*/
for(int i=0;i<n;i++)
{

    if((k-j+arr[i])<=0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}
    return 0;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    deque<int> dq;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (i % 2 == 0) dq.push_back(a);
        else dq.push_front(a);
    }
    if (n % 2 == 1) {
        auto itr = dq.rbegin();
        cout << *itr;
        ++itr;
        for (; itr != dq.rend(); ++itr) cout << " " << *itr;
    }
    else {
        auto itr = dq.begin();
        cout << *itr;
        ++itr;
        for (; itr != dq.end(); ++itr) cout << " " << *itr;
    }
    cout << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <stack>

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

using namespace std;
using ll = long long;

int main()
{
    ll N;
    cin>>N;
    string alf = "abcdefghijklmnopqrstuvwxyz";
    stack<char> res;

    int v;
    while(N!=0){
        //cout << alf[N%26] << endl;
        v = N%26;
        if(v==0){
            v=26;
            res.push(alf[v-1]);
            N = N/26;
            N--;
        }else{
            res.push(alf[v-1]);
            N = N/26;
        }
    }

    while(!res.empty()){
        cout << res.top();
        res.pop();
    }
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
	int n;
	long long sum = 0;
	scanf("%d", &n);
	
	for(int i = 1; i <= n; i++){
		int flag = 1;
		if(i % 3 == 0 && i % 5 == 0){
			flag = 0;
		}else if(i % 3 == 0){
			flag = 0;
		}else if(i % 5 == 0){
			flag = 0;
		}if(flag == 1){
			sum += i;
		}
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 1728
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  std::cout << (A - 1) * (B - 1) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  long long int N,K,R,S,P;
  char form['t'];
  form['r']='p';
  form['s']='r';
  form['p']='s';
  int points['t'],totalPoints=0;
  cin >> N >> K >>R >> S >> P;
  points['r']= R;
  points['s']= S;
  points['p']= P;
  char handP[N];
  for(int x=0;x<K;x++){
    char c;
    cin >> c;
    totalPoints+=points[form[c]];
    handP[x]=c;
  }
  int aux=N-K;
  for(int x=0;x<aux;x++){
    char c;
    cin >> c;
    handP[x+K]=c;
    if(c!=handP[x])
      totalPoints+=points[form[c]];
    else
      handP[x+K]='a';
  }
  cout << totalPoints << "\n";
}

Measured memory_bytes: 384
// 基本的な構文を使うためのお道具箱のようなものを一括で読み込んでいます。
// とりあえずはおまじないとでも思ってください。
#include <bits/stdc++.h>
// 説明が難しいです。おまじないと思ってください。
using namespace std;

//最初に実行されるmain関数を定義しています。メインなのでmain関数です。
int main() {
  /*
  aとbとcをそれぞれ初期値0で宣言しています。
  宣言すると同時に値を入れることを初期化と呼びます。実は今回はしなくてもいいのですが、慣れないうちは事故防止のためとりあえず初期化しておきましょう。
 */
  int a = 0, b = 0, c = 0;

  // aとbとcそれぞれに値を入力している
  cin >> a >> b >> c;

  // a + bがc以上かどうかを判定している。
  if (a + b >= c) {
    // a + bがc以上だった時の処理
    cout << "Yes" << endl;
  } else {
    // a + bがc以上ではなかった(つまりa + bがc未満だった)時の処理
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) const { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

using mint = modint<1000000007>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int h, w, k;
  cin >> h >> w >> k;
  if (w == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<vector<mint>> dp(h + 1, vector<mint>(w, 0));
  dp[0][0] = 1;
  rep(i, h) {
    for (int j = 0; j < bit(w - 1); j++) {
      bool b = true;
      for (int l = 0; l < w - 2; l++) {
        if ((j & bit(l)) && (j & bit(l + 1))) {
          b = false;
          break;
        }
      }
      if (!b) {
        continue;
      }
      for (int l = 0; l < w; l++) {
        if (j & bit(l)) {
          dp[i + 1][l + 1] += dp[i][l];
          dp[i + 1][l] += dp[i][l + 1];
          l++;
        } else {
          dp[i + 1][l] += dp[i][l];
        }
      }
    }
  }
  cout << dp[h][k - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009

signed main() {
	int n, k;
	cin >> n >> k;
	int now = 1;
	for (int i = 0; i < n; i++) {
		now = min(now * 2, now + k);
	}
	cout << now << endl;
}

Measured memory_bytes: 256