akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int n, q;
string s;
char t[200005], d[200005];

bool lcheck(int x)
{
	if(x == 0) return true;
	int p = x;
	for(int i = 1; i <= q; i++){
		if(s[p] == t[i]){
			if(d[i] == 'L') p--;
			else p++;
		}
		if(p <= 0) return true;
		if(p > n) return false;
	}
	return false;
}

bool rcheck(int x)
{
	if(x > n) return true;
	int p = x;
	for(int i = 1; i <= q; i++){
		if(s[p] == t[i]){
			if(d[i] == 'L') p--;
			else p++;
		}
		if(p <= 0) return false;
		if(p > n) return true;
	}
	return false;
}

int main(void)
{
	cin >> n >> q;
	cin >> s;
	s = "#" + s;
	for(int i = 1; i <= q; i++) cin >> t[i] >> d[i];
	
	int ub = n+1, lb = 0, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(lcheck(mid)) lb = mid;
		else ub = mid;
	}
	int lans = lb+1;
	
	ub = n+1, lb = 0;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(rcheck(mid)) ub = mid;
		else lb = mid;
	}
	int rans = ub-1;
	
	//cout << lans << " " << rans << endl;
	
	int ans = max(rans-lans+1, 0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int k;
    queue<ll> num;
    cin >> k;
    for (int i = 1; i <= 9; i++) {
        num.push(i);
    }
    int count = 1;
    while (1) {
        if (count == k)break;
        ll t = num.front();
        num.pop();
        count++;
        int mod = t % 10;
        if (mod == 0) {
            num.push(t * 10);
            num.push(t * 10 + 1);
        }
        else if (mod == 9) {
            num.push(t * 10 + mod - 1);
            num.push(t * 10 + mod);
        }
        else {
            num.push(t * 10 + mod - 1);
            num.push(t * 10 + mod);
            num.push(t * 10 + mod + 1);
        }
    }
    cout << num.front();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	string s, t;
	cin >> s;
	t = s;
	reverse(all(s));
	if(s == t) cout << "Yes";
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.*;

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

       
        int a = scan_A.nextInt();

        int ans_a;
        int b = scan_A.nextInt();
        int ans_b;
        if(x-a<0){
            ans_a= a-x;
        }else{
            ans_a = x-a;
        }

        if(x-b<0){
            ans_b = b-x;
        }else{
            ans_b = x-b;
        }
        
        if(ans_a < ans_b){
            System.out.println("A");
        }else{
            System.out.println("B");
        }
               
        
    }

}

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

int main(){
        int digit;
        cin>>digit;
        int n=digit%10;
        if(n==2||n==4||n==5||n==7||n==9)
        {
                cout<<"hon";
        }
        if(n==0||n==1||n==6||n==8){
                cout<<"pon";
        }
        if(n==3){
                cout<<"bon";
        }
}


Measured memory_bytes: 3556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n + 1];
            long[] b = new long[n];
            for (int i = 0; i <= n; i++)
                a[i] = in.nextInt();
            for (int i = 0; i < n; i++)
                b[i] = in.nextInt();
            long ans, rest;
            if (b[0] >= a[0]) {
                ans = a[0];
                rest = b[0] - a[0];
            } else {
                ans = b[0];
                rest = 0;
            }
            for (int i = 1; i < n; i++) {
                long can = rest + b[i];
                if (can >= a[i]) {
                    ans += a[i];
                    rest = Math.min(can - a[i], b[i]);
                } else {
                    ans += can;
                    rest = 0;
                }
            }
            if (rest > 0) {
                if (rest >= a[n])
                    ans += a[n];
                else
                    ans += rest;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 43644
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;
   
    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3104
#include<stdio.h>
#define N 100

int min(int x,int y){
	if(x<y){
		return x;
	}else{
		return y;
	}
}

int main( void ){
	int n , p[N+1],m[N+1][N+1];
	scanf("%d" , &n);
	
	for(int i = 1;i<= n;i++ ){
		scanf("%d",&p[i-1]);
		scanf("%d",&p[i]);
	}
	
	for(int i = 1; i <= n; i++) m[i][i] = 0;
	
	for(int l=2;l<= n;l++){
		for( int i = 1; i <= n-l+1; i++ ){
			int j = i+l-1;
			m[i][j] = (1<<21);
			for( int k = i; k <= j-1; k++ ){
				m[i][j] = min( m[i][j] , m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
			}
		}
	}
	
	printf("%d\n",m[1][n]);
	
	return 0;
}
	


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

int  main()
{
	long a,v; cin >> a >> v;
	long b,w; cin >> b >> w;
	long t; cin >> t;
	long d = labs(a - b);
	if (v > w)
	{
		if ((v-w) * t >= d)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	else
		cout << "NO\n";
	return (0);
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 101

int main(){
  int n, i, j, k, u, v, a[N][N];

  scanf("%d", &n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++) a[i][j]=0;
  }

  for(i=1;i<=n;i++){
    scanf("%d %d", &u, &k);
    for(j=1;j<=k;j++){
      scanf("%d", &v);
      a[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1) printf(" ");
      printf("%d", a[i][j]);
    }printf("\n");
  }

  return 0;
}	 



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

int main(){
    //入力
    string A,B,C;
    cin >> A >> B >> C;


    //出力
    if(A.at(A.size()-1)==B.at(0)&&B.at(B.size()-1)==C.at(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int Xplayer = 0;
const int Yplyaer = 1;
int n, z, w;
ll a[2050];

ll cache[2050][2];
ll solve(int pos, int player) {
	if(pos == n-1) {
		return abs(a[n-1] - a[n-2]);
	}

	ll& ret = cache[pos][player];
	if(ret != -1) return ret;
	ret = (pos > 0 ? abs(a[n-1] - a[pos-1]) : abs(a[n-1] - w));

	if(player == Xplayer) {
		rep(i,pos+1,n) {
			ret = max(ret, solve(i,Yplyaer));
		}
	} else {
		rep(i,pos+1,n) {
			ret = min(ret, solve(i,Xplayer));
		}
	}
	return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> z >> w;
	rep(i,0,n) {
		cin >> a[i];
	}
	if(n == 1) {
		cout << abs(a[0] - w) << '\n';
		return 0;
	}
	memset(cache, -1, sizeof(cache));
	cout << solve(0,Xplayer) << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int card[4][13]={{}};
    for(int v=0;v<n;v++)
    {
        int b,d;
        char c;
        cin>>c>>b;
        if(c=='S') d=0;
        if(c=='H') d=1;
        if(c=='C') d=2;
        if(c=='D') d=3;
        card[d][b-1]=1;
    }
    for(int i=0;i<4;i++)
    {
        for(int u=0;u<13;u++)
        {
            if(card[i][u]==1)continue;
            else
            
            {
                if(i==0)cout<<"S"<<" "<<u+1<<endl;
                else if(i==1)cout<<"H"<<" "<<u+1<<endl;
                else if(i==2)cout<<"C"<<" "<<u+1<<endl;
                else if(i==3)cout<<"D"<<" "<<u+1<<endl;
                else continue;
            }
        }
    }
    return 0;
}


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

int main() {
	uint64_t n;
	cin >> n;
	string s;
	while(n > 0){
		int rem = (n % 26);
		if(rem == 0){
			s.push_back('z');
			n = (n / 26) - 1;
		}
		else{
			s.push_back('a' + rem  - 1);
			n = n / 26;
		}
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans = Gcd(a[0], a[1]);
        for (int i = 2; i < n; i++)
            ans = Gcd(ans, a[i]);
        Console.WriteLine(ans);
    }
    public static int Gcd(int a, int b)
    {
        return a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
    }

    private static int GcdRecursive(int a, int b)
    {
        return b == 0 ? a : GcdRecursive(b, a % b);
    }
}

Measured memory_bytes: 21728
N = int(input())
AB = [[int(_) for _ in input().split()] for i in range(N)]

from math import gcd

def normalize(x, y):
    if x == 0 and y == 0:
        return (0, 0)
    if x == 0:
        return (0, 1)
    if y == 0:
        return (1, 0)
    if x < 0:
        x, y = -x, -y
    d = gcd(x, y)
    return (x // d, y // d)

def rev(x, y):
    x, y = -y, x
    if x < 0:
        x, y = -x, -y
    return x, y

xs = {}
xszero = 0

for a, b in AB:
    if a == 0 and b == 0:
        xszero += 1
        continue
    nab = normalize(a, b)
    rab = rev(*nab)
    if nab in xs:
        xs[nab][0] += 1
    elif rab in xs:
        xs[rab][1] += 1
    else:
        xs[nab] = [1, 0]

M = 1000000007

result = 1
for ab, nm in xs.items():
    k = (pow(2, nm[0], M) + pow(2, nm[1], M) - 1) % M
    result = (result * k) % M

print((result - 1 + xszero) % M)


Measured memory_bytes: 93692
#include<stdio.h>
int main(void){
  int N,flag=0;
   scanf("%d\n",&N);
  for(int n=1;n<=9;n++){
    for(int j=n;j<=9;j++){
      if(n*j==N){
        flag=1;
        break;
      }
    }
  }
  if(flag==1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000000000LL
priority_queue<ll>l;
priority_queue<ll,vector<ll>,greater<ll> >r;

int main(){
  ll q;
  ll sum=0,lsum=0,rsum=0;
  cin>>q;
  
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1){
      ll a,b;
      cin>>a>>b;
      sum+=b;

      ll max_l=INF;
      if(!l.empty())max_l=l.top();
      if(a<=max_l){
	l.push(a);
	lsum+=a;
      }
      else{
	r.push(a);
	rsum+=a;
      }
      
      if(!l.empty()&&(int)l.size()-(int)r.size()>1){
    	ll temp=l.top();l.pop();
    	r.push(temp);
    	lsum-=temp;
    	rsum+=temp;
      }
      else if(!r.empty()&&(int)r.size()-(int)l.size()>0){
	ll temp=r.top();r.pop();
	l.push(temp);
	rsum-=temp;
	lsum+=temp;
      }
    }
    else{
      if((int)l.size()-(int)r.size()==1){
    	ll x=l.top();
    	cout<<x<<' '<<x-lsum+rsum+sum<<endl;
      }
      else{
    	ll x=l.top();
    	cout<<x<<' '<<-lsum+rsum+sum<<endl;
      }
    }
  }
  
  return(0);
}


Measured memory_bytes: 3828
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    rep(i, 1, 10) {
        if (n%i==0 && (n/i)<10) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


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

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(1){
        
        c = c- b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }

        a = a- d;
        if(a <= 0){
            cout <<  "No" << endl;
            break;
        }

    }

    return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
//#define endl '\n' 

vector<pair<int,int>> ans;
int n,m;
int val[100001];
int par[100001];
int find(int no){
	if(par[no]==no){
		return no;
	}
	par[no]=find(par[no]);
	return par[no];
}
vector<int> adj[100001];
void dfs(int no,int par=-1){

	for(auto j:adj[no]){
		if(j!=par){
			dfs(j,no);
			if(val[j]==0){
				ans.pb({no,j});
			}
			else{
				ans.pb({j,no});
			}
			val[ans.back().a]^=1;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;

	for(int i=0;i<n;i++){
		par[i]=i;
	}
	for(int i=0;i<m;i++){
		int aa,bb;
		cin>>aa>>bb;
		aa--;
		bb--;
		int x=find(aa);
		int y=find(bb);
		if(x!=y){
			par[x]=y;
			adj[aa].pb(bb);
			adj[bb].pb(aa);
		}
		else{
			val[aa]^=1;
			ans.pb({aa,bb});
		}
	}
	if(m%2==1){
		cout<<-1<<endl;
		return 0;
	}
	dfs(0);
	for(auto j:ans){
		cout<<j.a+1<<" "<<j.b+1<<endl;
	}



	return 0;
}

Measured memory_bytes: 17028
#include<stdio.h>
int main(){
int price,val=0;
while(1){
scanf("%d\n",&price);
if(price==0)break;
price = 1000 - price;
if(price/500 == 1){
val++;
price-=500;
}
if(price/100 > 0){
val += price/100;
price-=(price/100)*100;
}
if(price/50 == 1){
val++;
price-=50;
}
if(price/10 > 0){
val += price/10;
price-=(price/10)*10;
}
if(price/5 == 1){
val++;
price-=5;
}
if(price/1 > 0){
val += price/1;
price-=(price/1);
}
printf("%d\n",val);
val = 0;
}
return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll nop(ll m, ll n) 
{ 
   
    ll path = 1; 
    for (ll i = n; i < (m + n - 1); i++) { 
        path *= i; 
        path /= (i - n + 1); 
    } 
    return path; 
} 
  
int main()
 {  fast();
	ll t;
    ll x1,y1,x2,y2;

    char op;
    cin>>x1;
    cin>>op;
    cin>>x2;
    if(op=='+')cout<<x1+x2<<endl;
    else cout<<x1-x2<<endl;
	    
	}

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

int main () {
    int N, s=0;
    cin >> N;
    int m=N;

    for (int i=0; i < 8; i++){
        s += N%10;
        N /= 10;
    }

    if (m % s == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    ll a, b;
    cin >> a >> b;
    ll sum = 0;
    ll elem = a;
    while(elem <= b){
        elem *= 2;
        sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[2001];
int main(){
    int n,z,w;
    cin>>n>>z>>w;
    rep(i,n){
        cin>>a[i];
    }
    if(n>1) cout<<max(abs(a[n-1]-a[n-2]),abs(a[n-1]-w))<<endl;
    else cout<<abs(a[n-1]-w)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int, vector<int>> adj;
void dfs(int curr, bool *vis, int *dis)
{
	vis[curr] = true;
	for (int n : adj[curr])
	{
		if (!vis[n])
			dfs(n, vis, dis);

		dis[curr] = max(dis[curr], 1 + dis[n]);
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	int m;
	cin >> n >> m;
	int s, d;
	adj.clear();
	for (int i = 0; i < m; i++)
	{
		cin >> s >> d;
		adj[s].push_back(d);
	}
	int dis[n + 1];
	bool vis[n + 1];
	memset(dis, 0, sizeof(dis));
	memset(vis, false, sizeof(vis));

	for (int i = 1; i <= n; i++)
	{
		dfs(i, vis, dis);
	}

	cout << *max_element(dis + 1, dis + n + 1);
	return 0;
}

Measured memory_bytes: 12708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
ll A[105];
ll pow(ll n, ll k) {
  ll ret = 1;

  while(k) {
    if (k & 1) {
      ret *= n;
    }
    k /= 2;
    n *= n;
  }
  return ret;
}
int main () {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  ll total = pow(3, N);

  ll odd = 1;
  for(int i = 0; i < N; ++i) {
    if ((A[i] & 1) == 0) {
      odd *= 2;
    }
  }

  cout << total - odd << endl;

}

Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
temp = list(input().split())
S=temp[0]
T=temp[1]

output = []
for s,t in zip(S,T):
    output.append(s)
    output.append(t)    

print("".join(output))

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

const ll maxs = 1e6+5;
const ll lmaxs = 22;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'


void pre(){

}

vector<ll> v;

void go(ll k,ll x){
    v.pb(x);
    if(k>10)
        return;
    int d = x%10;
    if(d){
        go(k+1,x*10+d-1);
    }
    go(k+1,x*10+d);
    if(d < 9){
        go(k+1,x*10+d+1);
    }
}

void solve(){
    for(ll i=1;i<=9;i++)go(0,i);
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    ll k;
    cin>>k;
    cout << v[k-1];
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int n,a,b;
vector<int> V[100005];
const ll MOD=1000000007;
int bio[100005];
ll dpW[100005];
ll dpB[100005];


pair<ll,ll> dfs (int a) {
    dpW[a]=1;
    dpB[a]=1;
    for (int b : V[a]) {
        if (bio[b]==1) {continue;}
        bio[b]=1;
        pair<ll,ll> ans=dfs(b);
        dpW[a]*=(ans.first+ans.second);
        dpB[a]*=ans.first;
        dpW[a]%=MOD;
        dpB[a]%=MOD;
    }
    if (dpW[a]==0) {dpW[a]++;}
    return {dpW[a],dpB[a]};

}

int main() {
    cin >> n;
    for (int i=0;i<n-1;i++) {
        cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
    }

    bio[1]=1;
    dfs(1);
    cout << (dpW[1]+dpB[1])%MOD << endl;

}


Measured memory_bytes: 16480
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<double,int> p;

int main(){
    vector<p> v,th;
    int n = 3,num;
    double data;
    
    while(n--){
        v.clear();
        for(int i = 0 ; i < 8 ; i++){
            cin >> num >> data;
            v.push_back(p(data,num));
        }
        sort(v.begin(),v.end());
        printf("%d %.2f\n" ,v[0].second,v[0].first);
        printf("%d %.2f\n" ,v[1].second,v[1].first);
        for(int i = 2 ; i < v.size() ; i++) th.push_back(v[i]);
    }
    sort(th.begin(),th.end());
    printf("%d %.2f\n" ,th[0].second,th[0].first);
    printf("%d %.2f\n" ,th[1].second,th[1].first);
    return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    string s1,s2; cin >> s1 >> s2;
    if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << ednl;
    else cout << "NO" << ednl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int c[500], s[500], f[500];

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
        cin >> c[i] >> s[i] >> f[i];

    for (int j = 0; j < n; ++j)
    {
        int t = 0;
        for (int i = j; i < n - 1; ++i)
        {
            t = max(t, s[i]);
            int k = dc(t - s[i], f[i]);
            t = s[i] + k * f[i] + c[i];
        }
        cout << t << '\n';
    }
}


Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
vec=[]
vec.append(v[0])
for i in range(0,n-2):
  vec.append(min(v[i],v[i+1]))
vec.append(v[n-2])
sum=0
for i in range(n):
  sum+=vec[i]
print(sum)

Measured memory_bytes: 3064
x1,y1,x2,y2=map( int, raw_input().split() ) 

dx=x2-x1
dy=y2-y1

dx,dy=dy,dx
dx*=-1

x3=x2+dx
y3=y2+dy

dx,dy=dy,dx
dx*=-1

x4=x3+dx
y4=y3+dy

print x3,y3,x4,y4


Measured memory_bytes: 27756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	ll N;
	cin >> N;
	ll ans = 1LL << 60;
	for (ll i = 1; i*i <= N; i++) {
		if (N%i != 0) continue;
		ans = min(ans, i + (N / i) - 2);
	}
	cout << ans << endl;
}

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

typedef long long ll;

int main()
{
    int x;
    cin >> x;
    vector<int> a(4);
    rep(i, 4){
        a[i] = x % 10;//0,1,2,3 =d,c,b,a
        x /= 10;
    }
    forx (b,0,(1<<4)){
        int n=a[3];
        rep(i,3){
            if(b>>i&1)
                n += a[2 - i];
            else
                n -= a[2 - i];
        }
        if(n==7){
            cout <<a[3];
            rep(i, 3)
            {
                if (b >> i & 1)
                    cout<<'+'<<a[2-i];
                else
                    cout << '-' << a[2 - i];
            }
            cout << "=7" << endl;
            break;
        }
    }
        return 0;
}


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


//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int count(string *s){
  int count = 0;
  /*
  REP(i,h){
    REP(j,w){
      if( s[i][j] == '#') count++;
    }
  }*/
  return count;
}

int main(void){

  ll l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i<=r; i++ ){
    if(i%d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int N;
    cin >> N;
    int res = ceil(N * 1.0 / 1000) * 1000 - N;
    cout << res << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3652
'use strict'

function main(s) {

  const n = s.split('\n')[0].split('');

  const pattern1 = n[0] === n[1] && n[1] === n[2] && n[2] !== n[3];
  const pattern2 = n[0] !== n[1] && n[1] === n[2] && n[2] === n[3];
  const pattern3 = n[0] === n[1] && n[1] === n[2] && n[2] === n[3];

  const ans = pattern1 || pattern2 || pattern3;
  console.log(ans ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#![allow(non_snake_case,unused_imports,dead_code)]

use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};
use std::io::Read;
use std::time::{Duration, Instant};
use rand::Rng;
 
use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn main() {
    input!{
        N:usize,
        M:usize,
        AB:[(Usize1,Usize1);M],
    }

    let mut T = UnionFind::new(N);
    
    for &(a,b) in &AB{
        T.merge(a,b);
    }

    let mut P = HashSet::new();
    for i in 0..N{
        let p = T.get_parent(i);
        P.insert(p);
    }

    println!("{}",P.len()-1);

}


// #region UnionFind
// 最小構成UnionFind木
struct UnionFind{
    P: Vec<usize>,
}

impl UnionFind {
    fn new(n:usize) -> UnionFind{
        UnionFind {P:(0..n).collect()}
    }
    fn get_parent(&mut self,n:usize) -> usize{
        if self.P[n] == n{ return n;}
        let p = self.P[n];
        self.P[n] = self.get_parent(p);
        self.P[n]
    }
    fn is_united(&mut self,x:usize,y:usize) -> bool{
        self.get_parent(x)==self.get_parent(y)
    }
    fn merge(&mut self,x:usize,y:usize){
        if self.is_united(x,y) {return;}
        let i = self.get_parent(x);
        let j = self.get_parent(y);
        self.P[j] = i;
    }
}
// #endregion UnionFind


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

int main() {
  int x;
  cin >> x ;
  int sen , syaku, ju, ichi;
  sen = x / 1000;
  x = x % 1000;
  syaku = x / 100;
  x = x % 100;
  ju = x / 10;
  x = x % 10;
  ichi = x / 1;
if (sen == syaku && syaku == ju){
  cout << "Yes" << endl;
}
  else if ( ju == syaku && syaku == ichi ){
    cout << "Yes"<< endl;
  }
  else  cout << "No" <<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<pair<ll, ll>> p(n);
  rep(i, n) {
    p[i] = {abs(a[i]), (a[i] < 0 ? 1 : 0)};
    if (p[i].first == 0) p[i].second = -1;
  }
  sort(p.begin(), p.end(), greater<pair<ll, ll>>());
  ll cnt = 0;
  vector<bool> used(2, false);
  vector<ll> minv(2, INF), idx(2, -1);
  rep(i, k) {
    if (p[i].first == 0) {
      cout << 0 << '\n';
      return 0;
    }
    cnt += p[i].second;
    used[p[i].second] = true;
    if (chmin(minv[p[i].second], p[i].first)) idx[p[i].second] = i;
  }
  if (cnt % 2 == 0) {
    ll ans = 1;
    rep(i, k) ans = (ans * p[i].first) % mod;
    cout << ans << '\n';
    return 0;
  }
  vector<ll> b(2, -INF), c(2, -INF);
  if (used[0]) {
    b[0] = p[idx[0]].first;
    FOR(i, k, n) {
      if (p[i].second == 1) {
        c[0] = p[i].first;
        break;
      }
    }
  }
  if (used[1]) {
    b[1] = p[idx[1]].first;
    FOR(i, k, n) {
      if (p[i].second == 0) {
        c[1] = p[i].first;
        break;
      }
    }
  }
  if (c[0] != -INF && c[1] != -INF) {
    ll t = (c[0] * b[1] < c[1] * b[0] ? 1 : 0);
    ll ans = c[t];
    rep(i, k) {
      if (i == idx[t]) continue;
      ans = (ans * p[i].first) % mod;
    }
    cout << ans << '\n';
    return 0;
  }
  else if (c[0] != -INF) {
    ll t = 0;
    ll ans = c[t];
    rep(i, k) {
      if (i == idx[t]) continue;
      ans = (ans * p[i].first) % mod;
    }
    cout << ans << '\n';
    return 0;
  }
  else if (c[1] != -INF) {
    ll t = 1;
    ll ans = c[t];
    rep(i, k) {
      if (i == idx[t]) continue;
      ans = (ans * p[i].first) % mod;
    }
    cout << ans << '\n';
    return 0;
  }
  ll ans = 1;
  rep(i, k) ans = (ans * p[n - 1 - i].first) % mod;
  ans = (mod - ans) % mod;
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 7952
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let r: usize = itr.next().unwrap().parse().unwrap();
    let g: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    for i in 0..n + 1 {
        if n < r * i {
            break;
        }
        for j in 0..n + 1 {
            if n < r * i + g * j {
                break;
            }
            let k = n - r * i - g * j;
            if k % b == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string a,b; int ans=0;
  cin>>a; b="CODEFESTIVAL2016";
    rep(i,16) if(a[i]!=b[i]) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;


#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll mod = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    cin>>a>>b>>c>>d;
    ll ans=max({a*c,a*d,b*c,b*d});
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc112_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, M;
  cin >> N >> M;

  ll ans = 1;
  for (ll i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (M / i >= N) ans = max(ans, i);
      if (i >= N) ans = max(ans, M / i);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> X;
    int input;
    for(int i = 0; i < N; i++){
        cin >> input;
        X.push_back(input);
    }
    std::sort(X.begin(), X.end());
    long int minSum = 2147483647;
    for(int i = 0; i <= X[N-1]; i ++){
        long int sum = 0;
        for(int j = 0; j < N; j++){
            sum += (X[j] - i)*(X[j] - i);
        }
        minSum = min(minSum, sum);
    }
    cout << minSum;
}

Measured memory_bytes: 256
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define all(x) x.begin(),x.end()


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vi v(n);
	For(i, 0, n) {cin >> v[i];}
	sort(all(v));
	int sum = 0;
	For(i, 0, k) {
		sum += v[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int a, l;
    cin >> a >> l;
    if(a == 0 && l == 0) break;
    vector<int> ss(l);
    vector<int> done(2000000, -1);
    for(int k = 0; ; k++) {
      if(done[a] >= 0) {
        cout << done[a] << " " << a << " " << k - done[a] << endl;
        break;
      }
      done[a] = k;
      for(int i = 0; i < l; i++) {
        ss[i] = a%10;
        a /= 10;
      }
      sort(ss.begin(), ss.end());
      int x = 0, y = 0;
      for(int i = 0; i < l; i++) {
        x = x * 10 + ss[i];
        y = y * 10 + ss[l-1-i];
      }
      a = y - x;
    }
  }
  return 0;
}

Measured memory_bytes: 10924
g = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = map(int, input().split())
for i in range(len(g)):
    if x in g[i]:
        xg = i
    if y in g[i]:
        yg = i
if xg == yg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>> n;
    
    string a="AC", w="WA",t="TLE",r="RE";
    int count_a=0,count_w=0,count_t=0,count_r=0;
    
    string s;
    
    for(int i=0 ; i<n ; i++)
    {
        cin>> s;
        
        if(s==a)  count_a++;
        if(s==w)  count_w++;
        if(s==t)  count_t++;
        if(s==r)  count_r++;
    }
    
    cout<<"AC x"<<" "<<count_a<<endl;
    cout<<"WA x"<<" "<<count_w<<endl;
    cout<<"TLE x"<<" "<<count_t<<endl;
    cout<<"RE x"<<" "<<count_r<<endl;
  return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
C = [int(a) for a in input().split()]
s = 0
for i in range(N):
  s += B[A[i]-1]
  if i > 0:
    if A[i] - A[i-1] == 1:
      s += C[A[i-1]-1]
print(s)

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

const int MAXN = 100010;
int n, M, ansl[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> M;
	for (int i = 1, L, R; i <= n; ++i) {
		std::cin >> L >> R; --L;
		int t1, t2, l = 1, r;
		for (; l <= L; l = r + 1) {
			t1 = L / l, t2 = R / l;
			r = std::min(L / t1, R / t2);
			if (t2 > t1) ++ansl[l], --ansl[r + 1];
		}
		++ansl[L + 1], --ansl[R + 1];
	}
	for (int i = 1; i <= M; ++i)
		std::cout << (ansl[i] += ansl[i - 1]) << '\n';
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

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

// 1653~

map< P, int > edges_pair;
vector< vector<int> > edge(200005, vector<int>());
bool visited[200005];
vector<int> ans(200005, 0);
int max_color = 0;

void dfs(int now, int parent_color)
{
	if (visited[now]) return;
	visited[now] = true;

	int color = (parent_color + 1) % max_color;

	for(const auto& next : edge[now])
	{
		if (visited[next]) continue;

		P p = ((now < next) ? P(now, next) : P(next, now));
		ans[edges_pair[p]] = color + 1;
		dfs(next, color);
		color = (color + 1) % max_color;
	}
}

void solve()
{
	fill(visited, visited + 200005, false);
	int n, a ,b;
	cin >> n;

	for(int i = 0; i < n - 1; ++i)
	{
		cin >> a >> b;
		a--; b--;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
		if (a > b) swap(a, b);
		edges_pair[P(a, b)] = i;
	}

	for(const auto& e : edge)
	{
		max_color = max(max_color, (int)e.size());
	}
	cout << max_color << endl;

	dfs(0, max_color - 1);
	for(int i = 0; i < n - 1; ++i)
	{
		cout << ans[i] << endl;
	}



}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 19736
<?php

function main($lines) {
  $sary = [];
  foreach ($lines as $index=>$value) {
    $sary[] = str_split($value);
  }
  $snew = array_reduce($sary, 'array_merge', array());
    $keys = range('a','z');
    $alfa= array_fill_keys($keys, 0);
    foreach($alfa as $k=>$v){
        for($i=0; $i<count($snew); $i++){
            if(strcasecmp($snew[$i], $k) == 0){
                $alfa[$k] += 1;
            }
        }
    }
    
    foreach($alfa as $k => $v){
        echo $k,' : ',$v,PHP_EOL;
    }
}

$array = array();
while (true) {
  $stdin = fgets(STDIN);
  if ($stdin == "") {
    break;
  }
  $array[] = rtrim($stdin);
}
main($array) . PHP_EOL;


Measured memory_bytes: 9668
package main

import (
  "fmt"
)

func main() {
  var A, N int
  fmt.Scan(&N)
  fmt.Scan(&A)

  // 500円を出すには
  coins := N % 500
  if coins <= A {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
ans = 0
check = 0
l = []

for i in range(N):
    if i == 0:
        ans += 1
        check = 0
        l.append(A[i])
    else:
        if len(l) == 0:
            ans += 1
            check = 0
            l.append(A[i])
        elif len(l) == 1:
            l.append(A[i])
            if A[i] - A[i-1] > 0:
                check = 1
            elif A[i] - A[i-1] < 0:
                check = -1
            else :
                check = 0
        else:
            if A[i] - A[i-1] == 0:
                l.append(A[i])
                pass
            elif A[i] - A[i-1] > 0 and check >= 0:
                check = 1
                l.append(A[i])
            elif A[i] - A[i-1] > 0 and check < 0:
                check = 1
                l = [A[i]]
                ans += 1
            elif A[i] - A[i-1] < 0 and check <= 0:
                check = -1
                l.append(A[i])
            elif A[i] - A[i-1] < 0 and check > 0:
                check = -1
                l = [A[i]]
                ans += 1
#    print(i)
#    print(l)
#    print(check)
#    print(ans)
#    print('--------------')

print(ans)


Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

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

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
T = input()
t = list(T)
h = 0
for i in range(len(t)):
    if t[i] == 'r':
        h += p
    elif t[i] == 's':
        h += r
    elif t[i] == 'p':
        h += s
for i in range(k,len(t)):
    if t[i] == t[i-k]:
        if t[i] == 'r':
            h -= p
            t[i] = 'g'
        elif t[i] == 's':
            h -= r
            t[i] = 'g'
        elif t[i] == 'p':
            h -= s
            t[i] = 'g'
    else:
        continue
print(h)

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 1e9

int main(int argc, char const *argv[])
{
    string a, b;
    cin >> a >> b;
    float n = stof(a + b);
    int m = (int)sqrt(n);
    if (m * m == (int)n)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << c << ' ' << a << ' ' << b<< endl;
  
}



Measured memory_bytes: 256