akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
int a,b,h,m;
double ans;
int angle;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> a >> b >> h >> m;
    double hour = m / 2.0 + (h * 30) % 360;
    double minute = 6 * m;

    double ret = abs(hour - minute);
    ret = min(ret, 360 - ret);

    ans = sqrt(1.0 * a * a + b * b - 2 * a * b * cos(ret * PI / 180.0));
    cout << fixed << setprecision(12) << ans;
	return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

vector<string> m;
int r, c, k;

bool eval(int mx, int my) {
	int a = 0;
	for (int i = 0; i < r && a <= k; i++) {
		for (int j = 0; j < c && a <= k; j++) {
			if (!TEST(mx,i) && !TEST(my,j) && m[i][j] == '#') {
				a++;
			}
		}
	}
	return a == k;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> r >> c >> k;
	
	vector<string> mat(r,"");
	for (int i = 0; i < r; i++){
		cin >> mat[i];
	}
	m = mat;
	
	int a = 0;
	for (int i = 0; i < (1<<r); i++) {
		for (int j = 0; j < (1 << c); j++) {
			a+=eval(i,j);
		}
	}
	cout << a << "\n";
 
}


Measured memory_bytes: 3656
class BIT():

    __slots__ = ["n", "data"]

    def __init__(self, li):
        self.n = len(li) + 1
        self.data = [0] + li
        for i in range(1, self.n):
            if i + (i & -i) < self.n:
                self.data[i + (i & -i)] += self.data[i]

    def add(self, i, a):
        i += 1
        while i < self.n:
            self.data[i] += a
            i += i & -i
        
    def acc(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def fold(self, l, r):
        return self.acc(r) - self.acc(l)

import sys
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
A = list(map(int, input().split()))
bit = BIT(A)
for _ in range(q):
    t, p, x = map(int, input().split())
    if t == 0:
        bit.add(p, x)
    else:
        print(bit.fold(p, x))

Measured memory_bytes: 58804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  set<string> st;
  int overRed = 0;
  rep(i, n){
    int num;
    cin >> num;
    if(num < 400){
      st.insert("hai");
    }else if(num < 800){
      st.insert("cha");
    }else if(num < 1200){
      st.insert("mid");
    }else if(num < 1600){
      st.insert("miz");
    }else if(num < 2000){
      st.insert("aoi");
    }else if(num < 2400){
      st.insert("kii");
    }else if(num < 2800){
      st.insert("dai");
    }else if(num < 3200){
      st.insert("aka");
    }else{
      overRed++;
    }
  }
  if(st.size() != 0) cout << st.size() << " " << st.size() + overRed << endl;
  else cout << 1 << " " << overRed << endl;
  return 0;
}
        
      
      
      
      
      
      
      
  


Measured memory_bytes: 3600
n = gets.to_i
edges = []
(n - 1).times { edges << gets.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
# 無向グラフなので両始点のグラフに入れる
edges.each do |f, t, w|
  graph[f] << [f, t, w]
  graph[t] << [t, f, w]
end

q, k = gets.split.map(&:to_i)
weights = Array.new(n + 1)
queue = [[k, k, 0]]

until queue.empty?
  from, to, weight = queue.shift
  weights[to] = weight
  graph[to].each do |f, t, w|
    # 逆流しないようにする（両方のグラフに入れているので必ず1つ該当する）
    next if t == from
    queue << [f, t, w + weight]
  end
end

queries = []
q.times { queries << gets.split.map(&:to_i) }

queries.each do |from, to|
  puts weights[from] + weights[to]
end


Measured memory_bytes: 48380
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    
    if( a.size() + 1   ==   b.size()  && b.compare(0,b.size()-1,a,0,b.size()-1 ) == 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,a;
    cin>>x>>a;
    cout <<(x<a?0:10)<<"\n";
}

Measured memory_bytes: 256
/* ex4_3
  terakura */

#include <stdio.h>

int depth(int west_height, int east_height);

int main(void){
    int west_height, east_height;
    scanf("%d %d", &west_height, &east_height);

    printf("%d\n", depth(west_height, east_height));

    return 0;

}


int depth(int west_height, int east_height){
    int diff, ans, hei ;
    diff = east_height - west_height;
    int i;
    for(i=0; i < diff + 1; i++){
        hei = hei + i;
    }

    ans = hei - east_height;

    return ans;

}


Measured memory_bytes: 128
#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>
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;
    V<P<ll, ll> > a;
    REP(i, n) {
        ll _a; cin >> _a;
        a.push_back(make_pair(_a, i+1));
    }
    sort(a.begin(), a.end());
    REP(i, n) cout << a[i].second << (i==n-1?'\n':' ');
    return 0;
}


Measured memory_bytes: 2544
from collections import *
n,m=map(int,input().split())
v=[False for i in range(n)]
t=[[]for i in range(n)]
for i in range(m):
    x,y,z=map(int,input().split())
    x,y=x-1,y-1
    t[x].append(y)
    t[y].append(x)
ans=0
for i in range(n):
    if v[i]:
        continue
    else:
        ans+=1
        for j in t[i]:
            q=deque()
            if v[j]==False:
                q.append(j)
                while q:
                    k=q.popleft()
                    v[k]=True
                    for l in t[k]:
                        if v[l]==False:
                            q.append(l)
print(ans)


Measured memory_bytes: 94180
#include <iostream>
#include <cmath>
#include <cstdlib>

class Point2d {
private:
	double x, y;
public:
	void set(double x, double y) { this->x = x; this->y = y; }
	double X() { return this->x; }
	double Y() { return this->y; }
	Point2d operator+(Point2d &p) {
		Point2d result;
		result.set(this->x + p.X(), this->y + p.Y());
		return result;
	}
	Point2d operator-(Point2d &p) {
		Point2d result;
		result.set(this->x - p.X(), this->y - p.Y());
		return result;
	}
	Point2d operator*(double a) {
		Point2d result;
		result.set(this->x * a, this->y * a);
		return result;
	}
	/* ¼ü p1p2 Æüª q1q2 ªðíÁÄ¢êÎ true ðÔ· */
	static bool interectLine(Point2d &p1, Point2d &p2, Point2d &q1, Point2d &q2) {
		Point2d p = p2 - p1, pq1 = q1 - p1, pq2 = q2 - p1;
		double tmp1, tmp2, t1z;
		tmp1 = p.X() * pq1.Y() - p.Y() * pq1.X();	/* p Æ pq1 ÌOÏÌz¬ª */
		tmp2 = p.X() * pq2.Y() - p.Y() * pq2.X();	/* p Æ pq2 ÌOÏÌz¬ª */
		t1z = tmp1 * tmp2;	/* OÏÌü«ªá¦Î¼ü p1p2 Æüª q1q2 ÍðíÁÄ¢é */
		return t1z <= 0.;
	}
	/* üª p1p2 Æüª q1q2 ªðíÁÄêÎ true ðÔ· */
	static bool interect(Point2d &p1, Point2d &p2, Point2d &q1, Point2d &q2) {
		return interectLine(p1, p2, q1, q2) && interectLine(q1, q2, p1, p2);
	}
	/* _ p ª¼ü q1q2 ãÉ êÎ true ðÔ· */
	static bool pointInLine(Point2d &p, Point2d &q1, Point2d &q2) {
		Point2d l1 = q1 - p, l2 = q2 - p;
		double crossZ = l1.X() * l2.Y() - l1.Y() * l2.X();
		return crossZ == 0.;
	}
};

int main() {
	using namespace std;
	double x[3], y[3], xp, yp, xq, yq;
	Point2d ptR[3], ptP, ptQ;
	int count;

	while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
		for (int i = 0; i < 3; ++i) {
			ptR[i].set(x[i], y[i]);
		}
		ptP.set(xp, yp);
		xq = x[0];
		for (int i = 1; i < 3; ++i) {
			if (x[i] > xq) { xq = x[i]; }
		}
		xq += (double)(rand() % 100 + 10) * 0.1;
		for (;;) {
			yq = yp + (double)((rand() % 100) - 50) * 0.1;
			ptQ.set(xq, yq);

			bool flag = false;
			for (int i = 0; i < 3; ++i) {
				if (Point2d::pointInLine(ptR[i], ptP, ptQ)) { flag = true; }
			}
			if (!flag) { break; }
		}

		count = 0;
		for (int i = 0; i < 3; ++i) {
			if (Point2d::interect(ptP, ptQ, ptR[i], ptR[(i + 1) % 3])) {
				++count;
			}
		}
		cout << (((count & 1) != 0) ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    long[] l = new long[n];

    for(int i=0; i<n; i++){
      l[i] = sc.nextInt();
    }
    
    long counter = 0;
    for(int i=0; i<n; i++){
      for(int j=i+1; j<n; j++){
        for(int k=j+1; k<n; k++){
          if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
            if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
              counter++;
            }
          }
        }
      }
    }

    System.out.println(counter);
    
    return;

  }
}

Measured memory_bytes: 36696
#include<stdio.h>
int main(void){
	int h,w,i,j;
	
	while(1){
	scanf("%d%d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		else{
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					if(i==0 || i==h-1){
						printf("#");
					}
					else if(j==0 || j==w-1 ){
						printf("#");
					}
					else{
						printf(".");
					}
			}
				printf("\n");
		}
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,i,a=1,ans=0;
  scanf("%lld",&N);
  char S[N][11];
  rep(i,N)scanf("%s",S[i]);
  qsort(S,N,sizeof(S[0]),scmp);
  rep(i,N-1){
    if(strcmp(S[i],S[i+1])==0)a++;
    else ans=MAX(ans,a),a=1;
  }
  ans=MAX(ans,a);
  a=1;
  rep(i,N-1){
    if(strcmp(S[i],S[i+1])==0)a++;
    else{
      if(a==ans)printf("%s\n",S[i]);
      a=1;
    }
  }
  if(a==ans)printf("%s\n",S[N-1]);

  //printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <iomanip>
#include <set>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 

int dx[6] = {1,1,0,-1,-1,0};
int dy[6] = {0,1,1,0,-1,-1};

int data[300][300]={0};

bool inrange(int x,int y){
  if(x<-100||y<-100) return false;
  else return true;
}
queue<pair<int,pair<int,int> > > q;
int turn;

int search(){
  int res = 0;
  while(!q.empty()){
    int tmpturn = q.front().first;
    pair<int,int> tmpq = q.front().second;
    int px = tmpq.first;
    int py = tmpq.second;
    q.pop();
    if(tmpturn>0){
      REP(i,6){
        int nx = px+dx[i];
        int ny = py+dy[i];
        if(inrange(nx,ny)&&(data[nx+100][ny+100]==0)){
          res++;
          data[nx+100][ny+100] = 1;
          q.push(make_pair(tmpturn-1,make_pair(nx,ny)));
        }
      }
    }
  }
  return res;
}


int main(){
  int n;
  while(1){
    cin >> turn >> n;
    if(turn==0&&n==0) break;
    REP(i,300) REP(j,300) data[i][j] = 0;
    REP(i,n){
      int tx,ty;
      cin >> tx >> ty;
      data[tx+100][ty+100] = -1;
    }
    while(!q.empty()) q.pop();
    int sx,sy;
    cin >> sx >> sy;
    data[sx+100][sy+100] = 1;
    q.push(make_pair(turn,make_pair(sx,sy)));
    cout << search()+1 << endl;
  }
}

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

using namespace std;
#define sd(x) scanf("%d",&x);
#define sdl(x) scanf("%lld",&x);
#define pr(x) printf("%d\n",x);
#define prl(x) printf("%lld\n",x);


   long long int gcd(long long int a,long long int b)
{
    if (b<a)return gcd(b,a);
    else if (b%a==0)return a;
    else return gcd(b%a,a);
 
}

long long fast_exp(long long a,long long n,long long mod1)
    {

    if (n==0)return 1;
    else if (n==1)return a;
    if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
    else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
bool is_square(long long  a)
{
    long long int b=sqrt(a);
    if (b*b==a)return true;
    else return false;
}


void solve()
{
   string s;
   cin >> s;
   if (s=="ARC")
    cout << "ABC" << endl;
    
    else cout << "ARC" << endl;
    
}



int main ()
{
      
     int t;
     //cin >> t;
     t=1;
     for (int tt=1;tt<=t;tt++)
     {
         solve();

     }

    return 0;
     
     
     
     
 }


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i = a;i<=b;++i)
#define For_(i,a,b) for(int i = a;i>=b;--i)
typedef long long LL;
inline int read(){
    int r = 0,f = 1;
    char c = getchar();
    while(c<'0' || c >'9'){
        if(c =='-') f = -1;
        c = getchar();
    }
    while(c>='0' && c<='9'){
        r = (r<<1) + (r<<3) + c - '0';
        c = getchar();
    }
    return r * f;
}

const int N = 2000 + 2,Mod = 1e9 + 7;
LL F[N];
int S;
LL ans;


int main(){
    S = read();
    F[3] = 1;
    F[4] = 1;
    F[5] = 1;
    For(i,6,S){
        int r = 0;
        while(3+r<=i-3){
            F[i] += (F[3+r])%Mod;
            r++;
        }
        F[i] = (F[i]+1)%Mod;
    }
    cout<<F[S]%Mod<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3680
/*
ЗАПУСКАЕМ ВЫСОКОГО
░ГУСЯ░▄▀▀▀▄░РАБОТЯГИ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
template<typename T> 
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h <<"\n"; 
}
template<typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
    int _b = 0;
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++; 
    cerr << " = " << _h << ","; 
    _dbg(_s+1, _t...);
}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        #ifdef LOCAL
        srand(300); 
        #else
        using namespace std::chrono;
        srand(duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch()).count()); 
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

void no(){cout << "No\n"; exit(0);}

int main() {
    
    int n, px=0, py=0, pt=0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y, t;
        cin >> t >> x >> y;
        int d = abs(x - px) + abs(y - py);
        if (d > t - pt) no();
        if ((t - pt - d) & 1) no();
        px = x, py = y, pt = t;
    }
    cout << "Yes\n";
    
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)


Measured memory_bytes: 61840
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
#define range(v,x) (iota((v).begin(),(v).end(),(x)))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

int main(){
	int a,b;
	cin>>a>>b;
	// const int c = 1440;
	const int c = 24;
	// a = a/100*60 + a%100;
	// b = b/100*60 + b%100;
	a = (a + b) % c;
	// a = a/60 + a%60;
	cout<< a <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};



const int mod = 1e9 + 7;



int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int k,x;
    cin >> k >> x;
    if(k * 500 >= x){
      print("Yes");
    } else{
      print("No");
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s,t;
    cin>>s>>t;
    map<char,char> mp,np;
    int n=s.size();
    rep(i,n) mp[s[i]]=t[i];
    rep(i,n) np[t[i]]=s[i];
    bool ok=true;
    rep(i,n){
        if(mp[s[i]]!=t[i]) ok=false;
        if(np[t[i]]!=s[i]) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  
  vector<int> vecX(N); vector<int> vecY(M);
  
  for (int i = 0; i < N; i++) cin >> vecX[i];
  
  for (int i = 0; i < M; i++) cin >> vecY[i];
  
  sort(vecX.begin(), vecX.end()); sort(vecY.begin(), vecY.end());
  
  for (int i = X + 1; i < Y; i++) {
    if (vecX.back() < i && i <= vecY.front()) {
      cout << "No War" << endl;
      return 0;
    }
  }
  
  cout << "War" << endl;
  
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    s = S()
    r = 0
    t = 0
    for c in s:
        if c == 'I':
            t += 1
            if r < t:
                r = t
        else:
            t -= 1
    return r


print(main())


Measured memory_bytes: 7960
N = int(input())
moti_list = []
for i in range(N):
    moti_list.append(int(input()))

moti_list.sort(reverse=True)
tower = 1
for j in range(N - 1):
    if moti_list[j] > moti_list[j + 1]:
        tower += 1

print(tower)

Measured memory_bytes: 8956
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main() {
    #ifndef ONLINE_JUDGE
	// freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin >> a >> b;
    int s = 10*a, e = 20*a;
    int ans = -1;
    for_(i, s, e+1) {
        if ((int) (0.08 * i) == a and (int) (0.1 * i) == b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long int> v1(n, 0), v2(m, 0);
    for (int i = 0; i < n; i++) {
        cin >> v1[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> v2[i];
    }
    long long int s1 = 0, s2 = 0;
    const int mod = 1e9 + 7;
    for (int i = 0; i + 1 < n; i++) {
        s1 += (v1[i + 1] - v1[i]) * (i + 1) * (n - i - 1);
        s1 %= mod;
    }
    for (int i = 0; i + 1 < m; i++) {
        s2 += (v2[i + 1] - v2[i]) * (i + 1) * (m - i - 1);
        s2 %= mod;
    }
    cout << s1 * s2 % mod << endl;
}


Measured memory_bytes: 4764
def factors(n):
  a = [1,n]
  x = 2
  while x * x <= n :
    if n % x == 0:          
      a.append(x)
      c=n//x
      while(c+1)*x<=n:
        c+=1
      a.append(c)
    x+=1
  return a
n,k=map(int,input().split())
a=list(map(int,input().split()))
candidates=factors(sum(a))
candidates.sort()
candidates.reverse()
for i in candidates:
  b=[]
  for j in range(n):
    b.append(a[j]%i)
  b.sort()
  upsum=0
  downsum=0
  for j in range(n):
    upsum+=i-b[j]
  for j in range(n):
    upsum-=i-b[j]
    downsum+=b[j]
    if upsum<=downsum:
      break
  if upsum<=k:
    print(i)
    break

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

int main(void)
{
    long long int b,c,i,j,k,n;
    char a[9];

    for(i=0;i<9;i++){
        cin >> a[i];
    }

    cout << a[0] << a[4] << a[8];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    long long n;cin>>n;
    long long arr[n][2];
    fo(i,n){
        cin >> arr[n-1-i][0] >> arr[n-1-i][1];
    }
    long long cnt = 0;
    fo(j,n){
        long long x = arr[j][0] + cnt,y =arr[j][1];
        if(x%y!=0){
            cnt += y-(x%y);
        }    
    }
    cout << cnt;
   
}

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

int main() {
  int h,n;
  string s="",t="",x;
  cin >> h >> n;
  
  for (int i=0;i<n+2;i++)
    s +='.';    
  t += s;  
  for (int i=0;i<h;i++) {
    cin >> x;
    t +="."+x+".";
  }    
  t += s;
  
  for (int i=0; i<h;i++) {
    string u="";
    for (int j=0;j<n;j++) {
     int l=0,k=n+3+(n+2)*i+j;
     if (t.at(k)=='#') {
       u +="#";
       continue;
     }
     for (int o=-1;o<2;o++) {
      for (int p=-1;p<2;p++) {        
       if (t.at(k+(n+2)*o+p)=='#')
        l++;
      }
     }
       if (l==0)
         u +="0";
       if (l==1)
         u +="1";
       if (l==2)
         u +="2";
       if (l==3)
         u +="3";
       if (l==4)
         u +="4";
       if (l==5)
         u +="5";
       if (l==6)
         u +="6";
       if (l==7)
         u +="7";
       if (l==8)
         u +="8";
    }  
     cout << u << endl;    
  }
}

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

int main()
{
	int n, m, a, h, p, q;
	while (cin >> n >> m >> a, n || m || a) {
		vector< vector<int> > amida(n + 1, vector<int>(1001, -1));
		int retu = a, takasa = 1000;
		for (int i = 0; i < m; i++) {
			cin >> h >> p >> q;
			amida[p][h] = q;
			amida[q][h] = p;
		}
		for (; takasa > 0; takasa--) {
			if (amida[retu][takasa] != -1) {
				retu = amida[retu][takasa];
			}
		}
		cout << retu << endl;
	}
	return 0;
}

Measured memory_bytes: 3396
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int x=0;
        int m=0;
        for(int i=0;i<N;i++){
        	if(S.charAt(i)=='I')x++;
        	else x--;
        	if(x>m)m=x;
        }
        System.out.println(m);
    }
}

Measured memory_bytes: 10192
fun main(args: Array<String>) {
    infix fun Int.pow(x: Int): Int {
        var res = 1
        repeat(x) {
            res *= this
        }
        return res
    }
    fun calcKetawa(x: Int): Int {
        if(x == 0) return 0
        return x % 10 + calcKetawa(x / 10)
    }

    var ans = 0
    val (a, n, m) = readLine()!!.split(" ").map { it.toInt() }
    for(y in 1..Int.MAX_VALUE) {
        val x = (a + y) pow n
        if(x in 0..m) {
            if(calcKetawa(x)==y) ans++
        } else {
            break
        }
    }
    println(ans)
}


Measured memory_bytes: 33988
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,w,n;cin >> h >> w>> n;
    vpl v(n);rep(i,n){
        ll a,b;cin >> a >> b;a--;b--;
        v[i]={a,b};
    }
    sort(all(v));
    vl dp(w);dp[0]=1;ll now=0,see=0;
    rep(i,h){
        ll z=now;
        while(z<n&&v[z].fi==i){
            if(dp[v[z].se])cout << i << endl,exit(0);
            z++;
        }
        now=z;
        if(!binary_search(all(v),make_pair(i+1,see+1))){
            see++;
            if(see<w)dp[see]++;
        }
        //rep(j,w)cout << dp[j];cout << endl;
    }
    cout << h <<endl;
} 

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

int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] && S[1] == S[2]) cout<< "Yes" << endl;
  else if (S[1] == S[2] && S[2] == S[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	int ans;
	for(int i = 1; i < S.length() / 2; i++){
		if(S.substr(0, i) == S.substr(i, i)) ans = i * 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;    
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;
 
ll fpow(ll a, ll n) {
    ll ans = 1;
    while (n) {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}
 
void solve() {
    int h,w,n; cin >> h >> w >> n;
    int ans = n/max(h,w);
    if (n%max(h,w) != 0) ++ans;
    cout << ans << endl;    
}
 
int main() {
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

ll N,m = INF,c = 0;
ll P[200010];

int main(){
  cin >> N;
  rep(i,N) cin >> P[i];
  rep(i,N){
    if(m > P[i]){
      m = P[i];
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int large(int a,int b){
    if(a<b)return b;
    else return a;
}
int main(void){
    int n,temp=0;
    char s[101];
    scanf("%d %s",&n,s);
    int i,max=0;
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='I'){
            temp++;
            max=large(max,temp);
        }else{
            temp--;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
<?php
    while(true) {
        fscanf(STDIN, "%d", $price);
        if ($price == 0) {
            exit;
        }

        $arr = array(500, 100, 50, 10, 5, 1);
        $chg = 1000 - $price;
        $ans = 0;

        foreach ($arr as $coin) {
            while($coin <= $chg) {
                $chg -= $coin;
                $ans++;
            }
        }

        echo $ans . PHP_EOL;
    }

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

int main() {
    int N;
    cin >> N;
    int i = 1;
    while ((i+1)*(i+1) <= N) {
        i++;
    }
    cout << i * i << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;
signed main() {
	string s; cin >> s;
	deque<char>que;
	rep(i, s.size())que.push_back(s[i]);
	int q; cin >> q;
	bool re = false;
	rep(i, q) {
		int a; cin >> a;
		if (a == 1) {
			if (!re)re = true;
			else re = false;
		}
		else {
			int b; char c; cin >> b >> c;
			if (!re) {
				if (b == 1)que.push_front(c);
				else que.push_back(c);
			}
			else {
				if (b == 1)que.push_back(c);
				else que.push_front(c);
			}
		}
	}
	if (!re) {
		while (!que.empty()) { cout << que.front(); que.pop_front(); }
		return 0;
	}
	while (!que.empty()) { cout << que.back(); que.pop_back(); }
	return 0;
}


Measured memory_bytes: 1024
#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() {
  string S;
  cin >> S;
  set<char> st;
  rep(i, 3) st.insert(S[i]);
  bool bl = sz(st) > 1;
  puts(bl ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
	int n, r = 0;
	cin >> n;
	for (int i = 1, x; i <= n; ++i) {
		cin>> x;
		if((i&1) && (x&1)) ++r;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

const int INF = int(1e9 + 7);
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n;
    cin >> n;
    if (n/1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ring
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();

            string input3 = input1 + input1;
            if (input3.IndexOf(input2) < 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}



Measured memory_bytes: 20352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

int main() { init_io();
  int N; cin >> N;
  vector<int> D(N); rep(i, N) cin >> D[i];
  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> cnt(N);
  sort(range(D));
  mint ans = 1;
  cnt[D[0]]++;
  for (int i = 1; i < N; i++) {
    if (D[i] == 0) {
      ans = 0;
    } else {
      ans *= cnt[D[i] - 1];
    }
    cnt[D[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Set<String> marchSet = new HashSet<>();
		long march[] = new long[5];

		for (int i = 0; i < n; i++) {
			String s = scanner.next();
			marchSet.add(s);
		}

		for (String s : marchSet) {
			if (s.charAt(0) == 'M')
				march[0]++;
			else if (s.charAt(0) == 'A')
				march[1]++;
			else if (s.charAt(0) == 'R')
				march[2]++;
			else if (s.charAt(0) == 'C')
				march[3]++;
			else if (s.charAt(0) == 'H')
				march[4]++;
		}

		long cnt = 0;
		for (int i = 0; i < 5; i++) {
			for (int j = i + 1; j < 5; j++) {
				for (int k = j + 1; k < 5; k++) {
					cnt += (march[i] * march[j] * march[k]);
				}
			}
		}

		System.out.println(cnt);

	}
}


Measured memory_bytes: 53784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

int main(){
    long int n;
    cin >> n;
    long int ans;
    for (long int i = 0; i * i <= n; i++){
        ans = i * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int h,w;
    while(1){
    scanf("%d %d",&h,&w);
    if(h==0)
        break;
    for(int i=0;i<h;i++){
        for(int l=0;l<w;l++){
            printf("#");
        }
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2628
#include<stdio.h>
int main(){
  int c[3][3],i,j;
  for(i=0;i<3;i++)for(j=0;j<3;j++)scanf("%d",&c[i][j]);
  for(i=0;i<2;i++)if(c[0][i]-c[0][i+1]!=c[1][i]-c[1][i+1]||c[0][i]-c[0][i+1]!=c[2][i]-c[2][i+1]){printf("No");return 0;}
  for(i=0;i<2;i++)if(c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1]||c[i][0]-c[i+1][0]!=c[i][2]-c[i+1][2]){printf("No");return 0;}
  printf("Yes");
}


Measured memory_bytes: 1732
#include <cstdio>
#include <algorithm>
using namespace std;
int in(){ int x; scanf("%d", &x); return x; }
int main(){
	int num[100];
	while(1){
		for(int i = 0; i < 2; i++) num[i] = in();
		if(num[0] == 0 && num[1] == 0) break;
		sort(num, num+2);
		for(int i = 0; i < 2; i++) printf("%d%s", num[i], i<1?" ":"\n");
	}
	return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n;
	cin>>n;
	
	int W;
	cin>>W;

	int w[n];
	int v[n];
	for(int i=0 ; i<n ; i++)
	{
		cin>>w[i];
		cin>>v[i];
	}
	int dp[n][W+1];

	for(int i=0 ; i<n ; i++)
	{
		dp[i][0] = 0;
	}
	for(int i=0 ; i<W+1 ; i++)
	{
		if(i<w[0])
			dp[0][i] = 0;
		else
			dp[0][i] = v[0];
	}

	for(int i=1 ; i<n ; i++)
	{
		for(int j=1 ; j<W+1 ; j++)
		{
			if(j<w[i])
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = max(v[i]+dp[i-1][j-w[i]] , dp[i-1][j]);

		}
	}
	int ans=0;
	for(int i=0 ; i<W+1 ; i++)
	{
		ans = max(ans , dp[n-1][i]);
	}
	// for(int i =0 ; i<n ; i++)
	// {
	// 	for(int j = 0 ; j<W+1 ; j++)
	// 		cout<<dp[i][j]<<" ";

	// 	cout<<"\n";
	// }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 78336
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int ans = Math.min(A * N, B);
        
        System.out.println(ans);
    }
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> cnt(N,0);
  vector<int> road(2*M);
  for (int i = 0; i < 2*M; i++) {
    cin >> road.at(i);
  }
  for (int i = 0; i < 2*M; i++) {
    for (int j = 0; j < N; j++) {
      if(j + 1 == road.at(i)) {
        cnt.at(j)++;
      }
    }
  }
  for(int i = 0; i < N; i++) {
    cout << cnt.at(i) << endl;
  }
}


Measured memory_bytes: 256
l = int(input())

ans = 0
i = 0
while i < l:
    if (l - i) % 2 == 0:
        a = (l - i) / 2
        b = (l - i) / 2
    else:
        a = ((l - i) / 2)
        b = (l - i) / 2
    ans = max(ans, a * b * i)
    i += 0.001

print(ans)

Measured memory_bytes: 3060
a, b, c = map(int, input().split())
k = int(input())
p = "No"
for i in range(k):
  if not(a < b and b < c):
    if b <= a:
      b = b * 2
    else:
      c = c * 2
if a < b and b < c:
  p = "Yes"
print(p)

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

int n, a, b, total, now, ans;

int main() {
    cin >> n >> a >> b;
    ans = 0;
    for (int i = 1; i <= n; i++){
        now = i;
        total = 0;
        while (now){
            total += now % 10;
            now /= 10;
        }
        if (total >= a && total <= b){
            ans += i;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
ceil = lambda a, b: -(-a // b)

K, A, B = map(int, input().split())
if A >= K:
    print(1)
    exit()
p = A - B
if p <= 0:
    print(-1)
    exit()

ans = 1
ans += ceil(K - A, A - B) * 2
print(ans)


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "No";
    char[] c = new char[s.length()];

    for(int i=0; i<s.length(); ++i)
      c[i] = s.charAt(i);

    Arrays.sort(c);

    if(c[0] == c[1] && c[2] == c[3] && c[1] != c[2])
      ans = "Yes";

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844