akhauriyash/Code-Regression huggingface dataset:
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int dsum(int b , int n){
    if(n == 0) return 0 ;
    return dsum(b , n / b) + n % b ; 
}
bool chck(int b , int n , int s){
    if(b < 2) return false; 
    //cout << b << ' ' << dsum(b , n) << " " << s << '\n';
    return dsum(b , n) == s; 
}

void solve()
{
    int n , s; 
    cin >> n >> s ;
    if(s == n){
        cout << n + 1 ;
        return ;
    }
    
    int lst = 0 ;
    for(int i = 2 ; i * i <= n ; ++i){
        lst = i ; 
        if(chck(i , n , s)){
            cout << i ;
            return ;
        }
    }
    int ans = inf ; 
    for(int p = 1 ; p * p <= n ; ++p){
        if( (n - s) % p ) continue ;
        int b = (n - s) / p + 1;
        if(chck(b , n , s)) ans = min(ans , b) ;
    } 
    //rep(j , 2)
    //if(chck(n + j , n , s)) ans = min(ans , n + j); 
    cout << (ans == inf ? -1 : ans) ; 
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,Q,K;
  cin >> N;

  vector<long long> d(N,0);
  vector<bool> seen(N,true);
  vector<vector<pair<int,long long>>> ab(N,vector<pair<int,long long>>(0)); 

  for(int i = 0;i < N-1;i++) {
    int a,b;
    long long c;
    cin >> a >> b >> c;
    a--; b--;
    ab.at(a).push_back(make_pair(b,c));
    ab.at(b).push_back(make_pair(a,c));
  }

  cin >> Q >> K;
  queue<int> q;
  q.push(--K);

  d.at(K) = 0; seen.at(K) = false;
  while(!q.empty()) {
    int from = q.front();
    q.pop();
    for(int i = 0;i < ab.at(from).size();i++) {
      int to = ab.at(from).at(i).first;
      if(!seen.at(to)) continue;
      d.at(to) = d.at(from) + ab.at(from).at(i).second;
      seen.at(to) = false;
      q.push(to);
    }
  }
  

  for(int i = 0;i < Q;i++) {
    int x,y;
    cin >> x >> y;
    cout << d.at(--x)+d.at(--y) << endl;
  }

}






Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
typedef long long LL;
int val[maxn],First[maxn],cnt,N,M,deg[maxn];
int tot,pre[maxn],rdeg[maxn];
int ans = 0;
struct node{
    int to,Next;
}Tree[maxn*2];
void init(){
    memset(First,-1,sizeof(First));
    cnt = 0;
}
void addedge(int from,int to){
    Tree[cnt].to = to;
    Tree[cnt].Next = First[from];
    First[from] = cnt++;
}
int dfs(int u,int fa){
    if(deg[u]==0)return 0;
    int shoud = deg[u] - 1;
    int bouns = 0;
    for(int i = First[u];i!=-1;i=Tree[i].Next){
        int to = Tree[i].to;
        if(to==fa)continue;
        deg[to]--;
        bouns+=dfs(to,u);
    }
    ans+=max(0,shoud-bouns);
    return bouns||(shoud-bouns);
}
int main(){
    init();
    scanf("%d",&N);
    for(int i = 0;i<N-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        addedge(a,b);
        addedge(b,a);
        deg[a]++;
        deg[b]++;
    }
    int now = 0,max1 = 0;
    for(int i = 0;i<=N-1;i++){
            rdeg[i] = deg[i];
            if(deg[i]>max1){
                now = i;
                max1 = deg[i];
            }
    }
    dfs(now,-1);
    printf("%d\n",max(1,ans));
    return 0;
}
/*
7
0 1
0 2
1 3
1 4
1 5
2 6

*/


Measured memory_bytes: 7680
def main():
    S = input()
    N = len(S)
    ans = "keyence"
    for i in range(N):
        for j in range(N+1):
            T = S[:i] + S[i+j:]  # S[i:i+j]を取り除く
            if T == ans:
                return print("YES")

    print("NO")


if __name__ == '__main__':
    main()


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

int main(){
  int N,K,mi=1100000000;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end());
  for(int i=0;i<=N-K;i++){
    mi=min(mi,h.at(i+K-1)-h.at(i));
  }
  cout<<mi<<endl;
  
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h.at(i);
    }

    vector<ll> cost(n);
    cost.at(n - 1) = 0;
    for(int i = n - 2; i >= 0; --i){
        cost.at(i) = abs(h.at(i) - h.at(i + 1)) + cost.at(i + 1);
        for(int j = 2; j <= k && i + j < n; ++j){
            cost.at(i) = min(
                cost.at(i),
                abs(h.at(i) - h.at(i + j)) + cost.at(i + j)
            );
        }
    }
    cout << cost.at(0) << endl;
    return 0;
}

Measured memory_bytes: 1792
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef pair<int,int> pii;
bool ok(string s){
	string t=s;
	reverse(s.begin(),s.end());
	return s==t;
}
int main(){
	string s;
	cin>>s;
	int n=(int)s.length();
	string a,b;
	rep(i,0,(n-1)/2-1) a+=s[i];
	rep(i,(n+3)/2-1,n-1) b+=s[i];
	if(ok(s)&&ok(a)&&ok(b)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <iterator>
#include<math.h>
#include <bits/stdc++.h> 
#include<vector>
using namespace std;
int main()
{
  	long A,temp;
  	cin>>A;
  vector<long> N;
  for(long i=0;i<A;i++)
  {
    cin>>temp;
    N.push_back(temp);
  }
  if(std::is_sorted(std::begin(N), std::end(N))==true)
  {
    cout<<"YES";
    return 0;
  }
  else
  {
      for(long i=0;i<A;i++)
      {
          for(long j=i+1;j<A;j++)
          {
              swap(N[i],N[j]);
              if(std::is_sorted(std::begin(N), std::end(N))==true)
                {
                    cout<<"YES";
                    return 0;
                }
                else{
                    swap(N[i],N[j]);
                }
          }
    }
}
cout<<"NO";
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  vector<array<ll,2>> A(n);
  for (auto& _a : A) cin >> _a[0] >> _a[1];
  for (int i = 2; i < n; ++i) {
    if (A[i][0]==A[i][1] && A[i-1][0]==A[i-1][1] && A[i-2][0]==A[i-2][1]) {
      cout << "Yes" << endl;
      return 0;
    }
    
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
ans = {}
flag = 0

for i in A:
    if (ans.get(i) != None):
        flag = 1
        break
    else:
        ans[i] = 1

if (flag == 0):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 32844
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def fb(i):
    if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
        return True
    else:
        return False


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = 0
    for n in range(1, N + 1):
        if not fb(n):
            ret += n
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9296
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  vector<vector<int>> c(3,vector<int>(3));
  vector<int> a(3,0);
  vector<int> b(3);
  rep(i,3){
    rep(j,3){
      cin>>c[i][j];
      if(i==0)
      b[j]=c[i][j];
      if(j==0)
      a[i]=c[i][j]-b[j];
    }
  }
  bool ans=1;
  // rep(i,3){
  //   cout<<a[i]<<" "<<b[i]<<endl;
  // }
  rep(i,3){
    rep(j,3){
      if(a[i]+b[j]!=c[i][j])
      ans=0;
    }
  }

  if(ans)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;
const int mod = 1e9+7;
const int maxn = 2e6+5;
int add(int x,int y) { x+=y; return x>=mod?x-mod:x; }
int sub(int x,int y) { x-=y; return x<0?x+mod:x; }
int mul(int x,int y) { return 1ll*x*y%mod; }
int ksm(int a,int b) {
	int ans = 1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
int X[10],Y[10];
int fac[maxn],inv[maxn];
int GC(int x,int y) {
	if(x<y) return 0;
	return mul(fac[x],mul(inv[x-y],inv[y]));
}
int JZ(int xa,int ya,int xb,int yb) {
	int ans = GC(yb+1+xb+1,yb+1);
	ans = add(ans,GC(xa+ya,xa));
	ans = sub(ans,GC(xa+yb+1,xa));
	ans = sub(ans,GC(xb+ya+1,ya));
	return ans;
}
int TO1(int xx,int yy) {
	return JZ(xx-X[2],yy-Y[2],xx-X[1],yy-Y[1]);
}
int TO2(int xx,int yy) {
	return JZ(X[5]-xx,Y[5]-yy,X[6]-xx,Y[6]-yy);
}
int main() {
	fac[0] = fac[1] = inv[1] = inv[0] = 1;
	for(int i=2;i<=maxn-5;i++) fac[i] = mul(fac[i-1],i),inv[i] = mul(inv[mod%i],mod-mod/i);
	for(int i=2;i<=maxn-5;i++) inv[i] = mul(inv[i-1],inv[i]);
//	cerr<<JZ(0,0,2,2);
	
	for(int i=1;i<=6;i++) scanf("%d",&X[i]);
	for(int i=1;i<=6;i++) scanf("%d",&Y[i]);
	int ANS = 0;
	for(int i=X[3];i<=X[4];i++) {
		ANS = sub(ANS,mul(mul(i+Y[3],TO1(i,Y[3]-1)),TO2(i,Y[3])));
		ANS = add(ANS,mul(mul(i+Y[4]+1,TO1(i,Y[4])),TO2(i,Y[4]+1)));
	}
	for(int i=Y[3];i<=Y[4];i++) {
		ANS = sub(ANS,mul(i+X[3],mul(TO1(X[3]-1,i),TO2(X[3],i))));
		ANS = add(ANS,mul(i+X[4]+1,mul(TO1(X[4],i),TO2(X[4]+1,i))));
	}
	printf("%d",ANS);
	
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

const static int SIZE = 11;
const static int H_LEN = 4;
const static int V_LEN = 5;
int main() {
  int field [ SIZE  ][ SIZE ] = { 0 };
  for( int i = 0; i < SIZE; i++ ) {
    if( i == 0 || i == SIZE - 1 ) { continue; }
    string line;
    cin >> line;
    if( i % 2 ) {
      for( int j = 0; j < H_LEN; j++ ) {
        field[ i ][ 2 + j * 2 ] = line[ j ] - '0';
      }
    } else {
      for( int j = 0; j < V_LEN; j++ ) {
        field[ i ][ 1 + j * 2 ] = line[ j ] - '0';
      }
 
    }
  }
/*
  for( int i = 0; i < SIZE; i++ ) {
    for( int j = 0; j < SIZE; j++ ) {
      if( i % 2 ) {
        cout << ( field[ i ][ j ] ? string("-") : string(".") ) << " " << flush;
      } else {
        cout << ( field[ i ][ j ] ? string("|") : string(".") ) << " " << flush;
      }
    }
    cout << endl;
  }
*/
  int counter = 0;
  int dir = 0;
  int x = 1, y = 1;
  int vx[ 4 ] = { 2, 0, -2, 0 };
  int vy[ 4 ] = { 0, 2, 0, -2 };
  int ax[ 4 ] = { 2, 1, -2, -1 };
  int ay[ 4 ] = { -1, 2, 1, -2 };
  int bx[ 4 ] = { 3, 0, -3, 0 };
  int by[ 4 ] = { 0, 3, 0, -3 };
  int cx[ 4 ] = { 2, -1, -2, 1 };
  int cy[ 4 ] = { 1, 2, -1, -2 };
  do {
    if( field[ y + ay[ dir ] ][ x + ax[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir - 1 + 4 ) % 4;
    } else if( field[ y + by[ dir ] ][ x + bx[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
    } else if( field[ y + cy[ dir ] ][ x + cx[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir + 1 ) % 4;
    } else {
      x += vx[ dir ];
      y += vy[ dir ];
       cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir + 2 ) % 4;
    }
  } while( x != 1 || y != 1 );
  cout << endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1184
import java.util.LinkedList;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;

class Graph {
	
	
	
	//arraylist for dijkstras
	ArrayList<Integer> S = new ArrayList<Integer>();
	
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	
	
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	
	
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		LinkedList<Integer> neighbors = new LinkedList<Integer>();
		int[] dist = new int[totalVertex];
		
		dist[s] = 0;
		
		for(int i = 0; i < totalVertex; i++) {
			if(i != s) {
				dist[i] = 999999999;
			}
		}
		while(S.size() < totalVertex) {
			int v = getUnsettledNearest(dist);
			neighbors = getNeighbors(v);
			
			for(int i = 0; i < neighbors.size(); i++) {
				int x = neighbors.get(i);
				dist[x] = Math.min(dist[v]+getWeight(v, x), dist[x]);
			}
			S.add(v);
			ifSettled[v] = true;
			
		}
		return dist;
		
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40072
#coding:UTF-8

def Partition(A,n):
    x=A[n-1]
    i=0
    ans=""
    for j in range(n-1):
        if A[j]<=x:
            swap=A[j]
            A[j]=A[i]
            A[i]=swap
            i+=1
    swap=A[n-1]
    A[n-1]=A[i]
    A[i]=swap
    for j in range(n):
        if j>0:
            ans+=" "
        if j==i:
            ans+="["+str(A[j])+"]"
        else:
            ans+=str(A[j])
    print(ans)
            
 
    
if __name__=="__main__":
    n=int(input())
    A=input().split(" ")
    for i in range(n):
        A[i]=int(A[i])
    Partition(A,n)

Measured memory_bytes: 14728
#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 push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<int> vi[8];
bool used[8];
int n,m;
int dfs(int s,int cnt){
    int res=0;
    if(cnt==n) return 1;
    rep(i,vi[s].size()){
        if(!used[vi[s][i]]){
            used[vi[s][i]]=true;
            res+=dfs(vi[s][i],cnt+1);
            used[vi[s][i]]=false;
        }
    }
    return res;
}
int main(){
    int sr,ds;
    cin>>n>>m;
    rep(i,m){
        cin>>sr>>ds;
        vi[sr-1].pb(ds-1);
        vi[ds-1].pb(sr-1);
    }
    int ans=0;
    used[0]=true;
    cout<<dfs(0,1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v;
  rep(i, n) {
    ll m, l;
    cin >> m;
    if (m == 0) {
      cin >> l;
      v.push_back(l);
    } else if (m == 1) {
      cin >> l;
      cout << v.at(l) << endl;
    } else {
      v.pop_back();
    }
  }
}


Measured memory_bytes: 4980
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[])
{
	int i, n;
	int hh, mm;	// 時刻
	double angle_longhand, angle_shorthand; // 長針短針の角度
	double angle; // 差を入れる変数
	scanf("%d", &n);
	// 判定する時刻の個数を入力

	if(n >= 1 && n <= 10000) {
		for(i = 0; i < n; i++) {
			scanf("%d:%d", &hh, &mm);
			// 時刻を入力

			if (hh >= 0 && mm >= 0 && hh <= 11 && mm <= 59) {
				angle_shorthand = hh * 30 + mm * 0.5;
				angle_longhand = mm * 6;
				angle = fabs(angle_longhand - angle_shorthand);
				if (angle > 180)
					angle = fabs(angle - 360);
				// printf("angle_shorthand %f\n", angle_shorthand);
				// printf("angle_longhand %f\n", angle_longhand);
				// printf("angle %f\n", angle);
				if (angle >= 0 && angle < 30) {
					printf("alert\n");
				}
				else if (angle >= 90 && angle <= 180) {
					printf("safe\n");
				}
				else {
					printf("warning\n");
				}
			}
		}
	}
	return 0;
}

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

int main()
{
  string s;
  cin>>s;
  int a = stoi(s.substr(0,2));
  int b = stoi(s.substr(2,2));
  if(a>0&&a<=12)
  {
    if(b>0&&b<=12)
      cout<<"AMBIGUOUS\n";
    else
      cout<<"MMYY\n";
  }
  else if(b>0&&b<=12)
  {
    if(a>0&&a<=12)
      cout<<"AMBIGUOUS\n";
    else
      cout<<"YYMM\n";
  }
  else
    cout<<"NA\n";
  
  return 0;
}


Measured memory_bytes: 256
/*
const {stdin} = require('process');
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [d, n] = input.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    if (n === 100) {
        console.log(101 * Math.pow(100, d));
    }
    else {
        console.log(n * Math.pow(100, d));
    }
});
*/

var stdin = require('process').stdin;
var input = "";
stdin.on('data', function (x) { input += x; });
stdin.on('end', function () {
    var _a = input.split(' ')
        .map(function (x) { return x.trim(); }).map(function (x) { return parseInt(x); }), d = _a[0], n = _a[1];
    if (n === 100) {
        console.log(101 * Math.pow(100, d));
    }
    else {
        console.log(n * Math.pow(100, d));
    }
});


Measured memory_bytes: 7500
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        //int N = int.Parse(inp[0]);

        if(inp[0].Equals("ABC")) {
            Console.WriteLine("ARC");
        } else {
            Console.WriteLine("ABC");
        }
    
    }
}

Measured memory_bytes: 25800
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    int i = 1;
    for(i = 1; i <= n; i++) {
        sum += i;
        if(sum >= n) break;
    }
    bool a[i+1];
    for(int j = 0; j < i; j++) {
        a[j] = true;
    }
    for(int j = i; j >= 1; j--) {
        if(sum - j == n) continue;
        cout << j << endl;
    }

}

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

vector<vector<array<int,3>>> v(100010);
int depth[100010];
int par[100010][20];

void dfs2(int p,int d,int pre){
    depth[p] = d;
    for(auto e:v[p]){
        int i=e[0], c=e[1], di=e[2];
        if(i!=pre){
            dfs2(i,d+1,p);
            par[i][0] = p;
        }
    }
}

void init(int n,int root=0){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            par[i][j] = -1;
        }
    }
    dfs2(root,0,-1);
    for(int j=1;j<20;j++){
        for(int i=0;i<n;i++){
            if(par[i][j-1] == -1) continue;
            par[i][j] = par[par[i][j-1]][j-1];
        }
    }
}

int lca(int a,int b){
    if(depth[a] < depth[b]) swap(a,b);
    int dif = depth[a] - depth[b];
    for(int i=19;i>=0;i--){
        if(dif & (1<<i)) a = par[a][i];
    }
    if(a==b) return a;
    for(int i=19;i>=0;i--){
        if(par[a][i]!=par[b][i]){
            a = par[a][i], b = par[b][i];
        }
    }
    return par[a][0];
}

int dist[100020];
int cnt[100010];
int dc[100010];
map<int,int> col[100010];
map<int,int> dcol[100010];

void dfs(int p,int d,int pre){
    dist[p]=d;
    for(auto e:v[p]){
        int i=e[0],c=e[1],di=e[2];
        if(i != pre){
            cnt[c]++;
            dc[c] += di;
            for(auto &k:col[i]){
                k.second = cnt[k.first];
                dcol[i][k.first] = dc[k.first];
            }
            dfs(i,d+di,p);
            cnt[c]--;
            dc[c] -= di;
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--;
        v[a].push_back({b,c,d});
        v[b].push_back({a,c,d});
    }
    init(n,0);
    array<int,5> a[q];
    for(int i=0;i<q;i++){
        int c,d,x,y;
        cin>>c>>d>>x>>y;
        x--,y--;
        int l = lca(x,y);
        a[i] = {c,d,x,y,l};
        col[x][c]=0;
        col[y][c]=0;
        col[l][c]=0;
    }
    dfs(0,0,-1);
    for(int i=0;i<q;i++){
        int x=a[i][2],y=a[i][3],l=a[i][4];
        int c=a[i][0],d=a[i][1];
        int ans = dist[x]+dist[y]-2*dist[l] + (col[x][c]+col[y][c]-2*col[l][c])*d;
        ans -= dcol[x][c] + dcol[y][c] - 2*dcol[l][c];
        cout << ans << "\n";
    }


    
}

Measured memory_bytes: 54840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i;
	string a,b;
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(i=0;i<a.size();i++)
    {
        if(a[i]=='b') 
		{
			a[i]='d';
		}
        else if(a[i]=='d') 
		{
			a[i]='b';
		}
        else if(a[i]=='p') 
		{
			a[i]='q';
		}
        else if(a[i]=='q') 
		{
			a[i]='p';
		}
    }
    if(a==b) 
	{
		cout<<"Yes";
	}
    else 
	{
		cout<<"No";
	}
	return 0;
}

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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll A;
  double B, N;
  cin >> A >> B >> N;

  double x = N < B ? N : B-1;
  ll ans = (ll)(A * x / B) - A * (ll)(x / B);
  cout << ans << endl;
  return 0; 
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e16;
typedef long long ll;
ll mod = 1e9+7;
ll fast_exp(ll a, ll b)
{
    if(b == 0)
        return 1;
    else
    {
        ll res = 1;
        res = fast_exp(a,b/2);
        res = (res*res)%mod;
        if(b%2 == 1)
            res = (res*a)%mod;
        return res;
 
    }
}

 
int main()
{
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
   
  int n;
  cin>>n;
  string s;
  cin>>s;
  int chk =1;
  if(n%2 == 1)
    chk =0;
  else
    for(int i=0; i<n/2; i++)
    {
      if(s[i]!=s[n/2+i])
        chk=0;
    }

  if(chk)
    cout<<"Yes\n";
  else
    cout<<"No\n";


 return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int N = Integer.parseInt(n);
    int s = 0;
    for(int i = 0; i < n.length(); i++) {
      int a = Integer.parseInt(String.valueOf(n.charAt(i)));
      s += a;
    }
    String ans = "No";
    if(N % s == 0) ans = "Yes";
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
coins = [100, 101, 102, 103, 104, 105]
MAX = 100000

result = [0]*(MAX+1)

# 100の判定
for price in range(1,MAX+1):
    if (price in coins):
        result[price] = 1
    else:
        result[price] = 0

for coin in coins:
    for price in range(106, MAX + 1):
        result[price] += result[price-coin]

X = int(input())
if(result[X] >= 1): print('1')
else : print('0')

Measured memory_bytes: 7412
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	int n, pt=0, ph=0;;
	cin >> n;

	string t, h;

	for (int i = 0; i < n; i++){
		cin >> t >> h;

		if (t == h){
			pt++;
			ph++;
		}
		else if (t > h){
			pt += 3;
		}
		else{
			ph += 3;
		}
	}

	cout << pt << " " << ph << endl;

	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n; cin >> n;
    vector<double> x(n);
    double sum = 0;
    for(int i=0;i<n;i++){
        cin >> x[i];
        sum += x[i];
    }
    double ave; int Ave;
    ave = sum / n;
    Ave = sum / n;

    if(ave-Ave >= 0.5){
        Ave++;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += (x[i]-Ave)*(x[i]-Ave);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc143/tasks/abc143_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
void recursive_comb(vector<ll>& indexes, ll s, ll rest, std::function<void(vector<ll>&)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes.at(rest - 1) = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}
// nCkの組み合わせに対して処理を実行する
void foreach_comb(ll n, ll k, std::function<void(vector<ll>&)> f) {
    vector<ll> indexes(k);
    recursive_comb(indexes, n - 1, k, f);
}
//foreach_comb(N-1, 2, [&](vector<ll>& indexes) {
//    dump(indexes[0],indexes[1]);
//}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<ll> ln(N);
    for(auto&& l:ln){
        cin>>l;
    }
    sort(ln.begin(),ln.end());
    ll ans=0;
    REP(i,N){
        ll a=ln.at(i);
        FOR(j,i+1,N){
            //if(i==j)continue;
            ll b=ln.at(j);
            auto it = lower_bound(ln.begin(),ln.end(),a+b);
            //if (it==ln.end()) continue;
            if (it==ln.begin()) continue;
            --it;
            auto d = std::distance(ln.begin(),it);
            ans += max<ll>(d - j,0);
        }
    }
    cout<<ans<<endl;
    return 0;
#if 0
    //TLE...
    ll ans=0;
    foreach_comb(N,3,[&](vector<ll>& t){
        //dump(t);
        ll a=ln.at(t.at(0));
        ll b=ln.at(t.at(1));        
        ll c=ln.at(t.at(2));        
        if(a<b+c&&b<c+a&&c<a+b){
            ++ans;
        }
    });
    cout<<ans<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);

         int N = sc.nextInt();

        long[][] A = new long[N][N];
        long[][] B = new long[N][N];


        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                A[i][j] = sc.nextInt();
                B[i][j] = A[i][j];
            }
        }

        long ans = 0;;

        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                for(int k = 0; k < N; k++){
                    if( A[i][j] + A[i][k] < A[j][k] || Math.abs( A[i][j] - A[i][k] ) > A[j][k] ){
                        ans = -1;
                        break;
                    }
                    else if(A[i][j] + A[j][k] == A[i][k] && j != k && j != i && i != k){
                        B[i][k] = 0;
                    }
  //                  System.out.println("B[" + i + "][" + j + "]:" + B[i][j]);
                }
            }
        }
        if(ans == 0){
            for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                    ans += B[i][j];
                }
            }
            ans /= 2;
        }

        System.out.println(ans);
    }
}

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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
//#define x first
#define y second
#define point pair<int,int>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

void initialize(vector<int> &F, int n){
    F = vector<int> (n+1, 0);

    for(int i=2; i*i  <= n; i++){
        if(F[i] == 0)
            for(int k=i*i; k <=n ; k+= i)
                if(F[k] == 0) F[k] = i;
    }
}

//you don't know math, unless you can do math!
int n,k;
vector<int> a;

int meme[2][110000];
bool solve(bool turn, int k){
    int &ret = meme[turn][k];
    if(ret != -1)
        return ret;

    for(int i = 0; i < n; i++){
        if(a[i] <= k && solve(!turn, k - a[i]) == turn)
            return ret = turn;
    }

    return ret = !turn;
}

int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    //cin.tie(0);
    //cin.sync_with_stdio(0);

    cin>>n>>k;
    a = vector<int> (n);

    for(int i= 0; i < n; i++)
        cin>>a[i];

    int mn = *min_element(a.begin(), a.end());
    for(int i = 0; i < mn; i++){
        meme[0][i] = 1;
        meme[1][i] = 0;
    }

    for(int i = mn; i <= k; i++){
        meme[0][i] = 1;
        meme[1][i] = 0;

        for(int j = 0; j < n; j++){
            if(i - a[j] < 0)
                continue;

            for(int turn = 0; turn < 2; turn++){
                if(meme[!turn][i - a[j]] == turn)
                    meme[turn][i] = turn;
            }
        }
    }

    cout<<((meme[0][k])? "Second":"First");
}


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

using ll = long long;

int main() {
    string S;
    cin >> S;
    int n = S.size();
    for (int i = n / 2 - 1; i > 0; i--) {
        bool f = true;
        rep(j, i) {
            if (S[j] != S[i + j]) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << i * 2 << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let l: usize = it.next().unwrap().parse().unwrap();
    let r: usize = it.next().unwrap().parse().unwrap();
    const MOD: usize = 1_000_000_007;
    let mut dp = [[[[0; 2]; 2]; 2]; 61];
    dp[60][0][0][0] = 1;
    for i in (0..60).rev() {
        let p = (l >> i) & 1;
        let q = (r >> i) & 1;
        for x in 0..2 {
            for y in 0..2 {
                for s in 0..2 {
                    //00
                    if x == 1 || p == 0 {
                        dp[i][x][y | q][s] += dp[i + 1][x][y][s];
                    }
                    //01
                    if s == 1 && (x == 1 || p == 0) && (y == 1 || q == 1) {
                        dp[i][x][y][1] += dp[i + 1][x][y][s];
                    }
                    //11
                    if y == 1 || q == 1 {
                        dp[i][x | (p == 0) as usize][y][1] += dp[i + 1][x][y][s];
                    }
                }
            }
        }
        for x in 0..2 {
            for y in 0..2 {
                for s in 0..2 {
                    dp[i][x][y][s] %= MOD;
                }
            }
        }
    }
    let mut ans = 0;
    for x in 0..2 {
        for y in 0..2 {
            ans += dp[0][x][y][1];
        }
    }
    ans %= MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    ll N, K;
    string ans;
    cin >> N >> K;
    if (N%2 == 0){
        if (N/2 >= K) ans = "YES";
        else ans = "NO";
    }
    else{
        if (N/2 + 1 >= K) ans = "YES";
        else ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define X first
#define Y second

const int N=2e3+10;


ll solve(ll L,ll R){
    int st=61;
    if (L==R) return 1;
    while ((L&(1LL<<st))==(R&(1LL<<st))){
        L&=~(1LL<<st);
        R&=~(1LL<<st);
        st--;
    }
    int p1=st-1,p2=st-1;
    ///
    while (p1>=0&&!(L&(1LL<<p1))) p1--;
    if (p1==-1) return 1LL<<(st+1);
    ///
    while (p2>=0&&!(R&(1LL<<p2))) p2--;
    if (p2==-1) return (R-L)*2+1;
    if (p1<=p2) return (1LL<<(st+1))-L;
    int len=st-p1-1+p2+1,rem=p1-p2;
    /// < (1<<st)
    assert(L<(1LL<<st));
    ll ans=(1LL<<st)-L;
    ///>= (1<<st)
    ans+=(1LL<<len)+(1LL<<(p2+1))*((1LL<<(st-p1-1))-1)*((1LL<<rem)-1);
    ans+=(1LL<<(p1+1))-(L&((1LL<<(p1+1))-1));
    return ans;
}
int main(){
    ll L,R;
    cin>>L>>R;
    cout<<solve(L,R);
}


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

using namespace std;

long long dp[100100];
int w[100100], v[100100];
int N, W;

int main(){
    cin >> N >> W;
    for(int i = 1; i <= N; i++) cin >> w[i] >> v[i];
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = W - w[i]; j >= 0; j--){
            dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
        }
    }
    cout << dp[W] << '\n';
}

Measured memory_bytes: 1024
#include <map>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;


int n, m, k;
int a[10][10];

bool check(int x, int y) {
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if( (x &( 1<<(i-1) ))  && (y & (1<<(j - 1))) && a[i][j] == 1) cnt++;
		}
	}
	if(cnt == k) return true;
	return false;
}

int main() {
	int ans = 0;
	string s;
	cin >> n >> m >> k;
	for(int i =1; i <= n; i++){
		cin >> s;
		for (int j = 0; j < m;j ++) {
			if  (s[j] == '#') a[i][j + 1] = 1;
			else a[i][j + 1] = 2;
		}
	}
	for (int i = 0; i < (1<<n); i++) {
		for (int j = 0; j < (1<<m);j ++) {
			if (check(i, j)) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repn(i, n) for (ll i = 0; i <= (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main()
{
    string s;
    cin >> s;
    ll n = siz(s);
    vector<ll> ans(n, 0);

    ll cnt=0;
    for (int i = 0; i < n; i++)
    {

        if(s.at(i)=='L')
        {
            ans[i]+=cnt/2;
            ans[i-1]+=(1+cnt)/2;
            cnt=0;
        }else{
            cnt++;
        }
    }

    cnt=0;
    for(int i=n-1;0<=i;i--)
    {
        if(s.at(i)=='R')
        {
            ans[i]+=cnt/2;
            ans[i+1]+=(1+cnt)/2;
            cnt=0;
        }else{
            cnt++;
        }
    }

    rep(i, n) cout << ans[i] << (i < n ? ' ' : '\n');
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }

    sort(all(a));

    bool f = true;
    rep(i, n-1){
        if(a[i] == a[i+1]){
            f = false;
            break;
        }
    }

    cout << (f ? "YES" : "NO") << endl;


    return 0;
}



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

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

using namespace std;

int main(){
	int n,a,b; scanf("%d%d%d",&n,&a,&b);
	int cnt[3]={};
	rep(i,n){
		int p; scanf("%d",&p);
		if     (p<=a) cnt[0]++;
		else if(p<=b) cnt[1]++;
		else          cnt[2]++;
	}
	printf("%d\n",min({cnt[0],cnt[1],cnt[2]}));
	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    string str;
    vector<char> c;

    cin >> N;
    cin >> str;
    int wLeft = N;
    int rRight = -1;
    int count = 0;

    c.resize(N);
    for (int i = 0; i < N; i++){
        c[i] = str[i];
    }
    for (int i = 0; i < N; i++)
    {
        if(c[i]=='R'){
            rRight = i;
        }
        if(c[N - 1 - i] == 'W'){
            wLeft = N - 1 - i;
        }
    }

    while(wLeft < rRight){
        count++;
        c[wLeft] = 'R';
        c[rRight] = 'W';
        for (int i = wLeft; i < N; i++){
            wLeft++;
            if(c[wLeft] == 'W'){
                break;
            }
        }
        for (int i = rRight; i >= 0; i--){
            rRight--;
            if(c[rRight] == 'R'){
                break;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3920
#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(){
  int a,b,t;
  double tall;
  cin >> a >> b >> t;
  int ans=0; 
  tall = t+0.5;
  ans = (tall/a);
  ans = ans * b;
  cout << ans << endl;
}

Measured memory_bytes: 3600
N = int(input())
x1, x2, y1, y2 = {}, {}, {}, {}
INF = 10 ** 10

for i in range(N):
    x, y, d = input().split()
    x, y = int(x) * 2, int(y) * 2

    def update_x(v, x):
        if v not in x1:
            x1[v] = x2[v] = x
        else:
            x1[v] = min(x1[v], x)
            x2[v] = max(x2[v], x)

    def update_y(v, y):
        if v not in y1:
            y1[v] = y2[v] = y
        else:
            y1[v] = min(y1[v], y)
            y2[v] = max(y2[v], y)

    if d == 'R':
        update_x(+1, x)
        update_y(0, y)
    elif d == 'L':
        update_x(-1, x)
        update_y(0, y)
    elif d == 'U':
        update_x(0, x)
        update_y(+1, y)
    elif d == 'D':
        update_x(0, x)
        update_y(-1, y)

def area(t):
    xmin, xmax, ymin, ymax = INF, -INF, INF, -INF
    for (v, x) in x1.items():
        xmin = min(xmin, x + v * t)
    for (v, x) in x2.items():
        xmax = max(xmax, x + v * t)
    for (v, y) in y1.items():
        ymin = min(ymin, y + v * t)
    for (v, y) in y2.items():
        ymax = max(ymax, y + v * t)
    return (xmax - xmin) * (ymax - ymin)

ans = area(0)

x3 = list(x1.items()) + list(x2.items())
for i in range(len(x3)):
    for j in range(i + 1, len(x3)):
        if x3[i][0] != x3[j][0]:
            t = (x3[j][1] - x3[i][1]) // (x3[i][0] - x3[j][0])
            if t >= 0:
                ans = min(ans, area(t))

y3 = list(y1.items()) + list(y2.items())
for i in range(len(y3)):
    for j in range(i + 1, len(y3)):
        if y3[i][0] != y3[j][0]:
            t = (y3[j][1] - y3[i][1]) // (y3[i][0] - y3[j][0])
            if t >= 0:
                ans = min(ans, area(t))

print(ans / 4)


Measured memory_bytes: 3572
import java.util.*;


class Main{
    static{
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        System.out.print("Christmas ");
        for(int i = d; i < 25; i++){
            System.out.print("Eve ");
        }
    }
    public static void main(String[] args){
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
    int n,i,k,l;
    scanf("%d\n",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&l);
        A[l-1]=i+1;
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",A[i]);
    }
    return 0;
}

Measured memory_bytes: 1152
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll x,y,a,b,c;
cin>>x>>y>>a>>b>>c;
vector<ll>r,g,col;
for(ll i=0;i<a;i++)
{
    ll f;
    cin>>f;
    r.pb(f);
}
for(ll i=0;i<b;i++)
{
    ll f;
    cin>>f;
    g.pb(f);
}
for(ll i=0;i<c;i++)
{
    ll f;
    cin>>f;
    col.pb(f);
}
sort(all(r),greater<ll>());
sort(all(g),greater<ll>());
sort(all(col),greater<ll>());
vector<ll>ansr;
vector<ll>ansg;
for(ll i=0;i<min(x,a);i++)
{
    ansr.pb(r[i]);
}
for(ll i=0;i<min(y,b);i++)
{
    ansg.pb(g[i]);
}
ll ptr=0;
ll i=x-1;
ll j=y-1;
while(i>=0&&j>=0&&ptr<c)
{
    if(ansr[i]<ansg[j])
    {
        if(ansr[i]<col[ptr])
        {
            ansr[i]=col[ptr];
            ptr++;
            i--;
        }else
        {
            break;
        }
    }else{
        if(ansg[j]<col[ptr])
        {
            ansg[j]=col[ptr];
            ptr++;
            j--;

        }else
        {
            break;
        }
    }
}
if(i==-1)
{
    while(j>=0&&ptr<c)
    {
        if(ansg[j]<col[ptr])
        {
            ansg[j]=col[ptr];
            ptr++;
            j--;

        }else
        {
            break;
        }
    }
}
if(j==-1)
{
    while(i>=0&&ptr<c)
    {
        if(ansr[i]<col[ptr])
        {
            ansr[i]=col[ptr];
            ptr++;
            i--;
        }else
        {
            break;
        }
    }
}
ll ans=0;
for(ll i=0;i<ansr.size();i++)
{
    ans+=ansr[i];
}
for(ll j=0;j<ansg.size();j++)
{
    ans+=ansg[j];
}
cout<<ans<<endl;

return 0;
}


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

typedef long long int lli;
#define rep(i, a, b) for(lli i  = (lli)(a); i < (lli)(b);i++)
#define REP(i,n) for(lli(i)=0;(i)<(lli)(n);(i)++)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define trace(x) cerr << #x << ": " << x << endl;


typedef pair<lli, lli> ii;
typedef pair<ii, lli> iii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef long double C;
typedef complex<C> P;
#define X real()
#define Y imag()
C EPS=1e-9;
C pi=acos(-1.0);
const int N=1e5+200;
const int INF=1100000;


int main(){
	fastio;
	lli n,a,b,c;
	cin>>n>>a>>b>>c;
	int dp[n+1][3];
	dp[0][0]=a; dp[0][1]=b; dp[0][2]=c;
	rep(i,1,n){
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}

	lli ans=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // bfs
    int N, M;
    cin >> N >> M;
    vector<int> graph[N]; // 0-indexed
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> dir(N, -1);
    dir[0] = 0;
    queue<P> que;
    auto push = [&] (int x, int step) {
        que.emplace(x, step);
        return;
    };
    que.emplace(0, 0);
    while (!que.empty()) {
        auto p = que.front(); que.pop();
        int cur = p.first, step = p.second;
        for (int next : graph[cur]) {
            if (dir[next] != -1) continue;
            dir[next] = cur;
            push(next, step+1);
        }
    }
    rep(i, N) {
        if (dir[i] == -1) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    for (int i = 1; i < N; i++) {
        cout << dir[i] + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 10476
from collections import Counter

n=int(input())
count=Counter(input())
for i in range(n-1):
    t_count=Counter(input())
    for c_k in count.keys():
        if c_k in t_count.keys():
            count[c_k]=min(count[c_k],t_count[c_k])
        else:
            count[c_k]=0
s=''
for c_k in sorted(count.keys()):
    s+=c_k*count[c_k]
print(s)

Measured memory_bytes: 3316