akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100000

struct Node{
  int p,l,r;
};
struct Node T[N+1];
int main()
{
  int n,k,c,l=0,i,j,m,p;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&i,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j == 0){
	T[i].l=c;
      }
      else T[l].r=c;
      l=c;
      T[c].p=i;
    }
  }

  for(p=0;p<n;p++){
    printf("node %d: parent = %d, ",p,T[p].p);
    m = T[p].p;
    j=0;
    while(1){
      if(m == -1)break;
      else {
        m = T[m].p;
        j++;
      }
    }
    printf("depth = %d, ",j);
    if(T[p].p == -1){
      printf("root, [");
    }
    else if(T[p].l == -1){
      printf("leaf, [");
    }
    else printf("internal node, [");
    
    if(T[p].l != -1){
      printf("%d",T[p].l);
      i=T[p].l;
      while(1){
        if(T[i].r == -1)break;
        else {
	  printf(", %d",T[i].r);
          i = T[i].r;
	}
      }
    }
    printf("]\n");
  }
  return 0;
}
    

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
	string str;

	int data[2][1001][40];
	for(int i=0;i<=1000;i++){
		for(int j=0;j<40;j++){
			for(int k=0;k<2;k++){
				data[k][i][j]=0;
			}
		}
	}

	while(getline(cin,str)){
		if(str.empty())break;
		for(int i=0;i<str.size();i++){
			int spaceN = str.find(',',0);
			int person=atoi(str.substr(0,spaceN).c_str());
			int date  =atoi(str.substr(spaceN+1,str.size()-1).c_str());
			data[0][person][date]=1;
		//	cout<<"p="<<person<<" date="<<date<<endl;
		}
	}

	while(cin>>str){
	if(str.at(0)=='0')break;
		for(int i=0;i<str.size();i++){
			int spaceN = str.find(',',0);
			int person=atoi(str.substr(0,spaceN).c_str());
			int date  =atoi(str.substr(spaceN+1,str.size()-1).c_str());
			data[1][person][date]=1;
		}
	}
	int cnt=0;
	int flag=0;

	for(int j=0;j<=1000;j++){
		cnt=0;
		flag=0;
		for(int i=1;i>=0;i--){
			for(int k=0;k<40;k++){
				if(i==1){
					if(data[i][j][k]==1){
						cnt++;
						flag=1;
					}
				}
				else{
					if(data[i][j][k]==1&&flag>=1){
						cnt++;
						flag=2;
					}
				}
			}
		}
		if(flag==2){
			cout<<j<<" "<<cnt<<endl;
		}
	}
				
	return 0;

}

Measured memory_bytes: 1512
#include "bits/stdc++.h"
 
using namespace std;

#define VI vector<int>
#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define Cout(str) cout << str << endl

int main(){
	int N;

	cin >> N;

	cout << 1110 - N << endl;

	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  int cnt = 0;
  for(int i = 1;i<n-1;i++){
    if(p[i-1]>p[i] && p[i]>p[i+1]) cnt++;
    else if(p[i-1]<p[i] && p[i]<p[i+1]) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3464
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;


int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	ll ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		vector <char> a, b;
		ll dp[19][19];
		for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = 0; 
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) 
			if (mask & (1 << i)) a.push_back(str[i]);
			else b.push_back(str[i]);
		int lena = a.size(), lenb = b.size();
		


		for (int i = 1; i <= n; i++) { 
			for (int j = 0; j < i; j++) {
				int f = j;
				int s = i - 1 - j;
				if (s > lena) continue;
				if (f < b.size() && b[f] == str[2 * n - i]) 
					dp[i][f + 1] += dp[i - 1][f];
				if (s < a.size() && a[s] == str[2 * n - i]) 
					dp[i][f] += dp[i - 1][f];
			}
		}
		ans += dp[n][b.size()];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// header file section
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>

using namespace std;
using llong = long long;

// library section
// ===

string s, t;

int main() {
    cin >> s >> t;
    llong ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }

    cout << ans << endl;
    return 0;
};



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


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

    string s;
    cin >> s;
    int n=s.size();
    string t="keyence";
    bool flag=0;
    rep(i,7) {
        bool f=1;
        rep(j,i) {
            if (s[j]!=t[j]) f=0;
        }
        repr(j,i,7) {
            if (s[n-7+j]!=t[j]) f=0; 
        }
        if (f) flag=1;
    } 
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;   
}

Measured memory_bytes: 3652
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int m[10010],e[10010],j[10010];
        char ans[10010] = {0};
        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&m[i],&e[i],&j[i]);
            if(m[i] == 100 || e[i] == 100 || j[i] == 100)ans[i] = 'A';
            else if((m[i]+e[i])/2 >= 90)ans[i] = 'A';
            else if((m[i]+e[i]+j[i])/3 >= 80)ans[i] = 'A';
            else if((m[i]+e[i]+j[i])/3 >= 70)ans[i] = 'B';
            else if((m[i]+e[i]+j[i])/3 >= 50 && e[i] >= 80)ans[i] = 'B';
            else if((m[i]+e[i]+j[i])/3 >= 50 && m[i] >= 80)ans[i] = 'B';
            else ans[i] = 'C';
        }
        for(int i = 0;i < n; i++)printf("%c\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1056
# roadwork
import heapq
N, Q = map(int, input().split())
que = []
ans = [-1 for i in range(Q)]
D = [0 for i in range(N)]
heap = []
heapq.heapify(heap)
Set = set([])
for i in range(N):
    s, t, x = map(int, input().split())
    que.append((s-x, 0, i))  # append
    que.append((t-x, 1, i))  # remove
    D[i] = x

for i in range(Q):
    d = int(input())
    que.append((d, 2, i))  # querie

que.sort(key=lambda x: x[0])

for x in que:
    demand = x[1]
    if demand == 0:
        # append
        heapq.heappush(heap, (D[x[2]], x[2]))
        Set.add(x[2])
    elif demand == 1:
        # remove
        Set.remove(x[2])
    else:
        # querie
        flag = True
        while heap and flag:
            distance, index = heapq.heappop(heap)
            if index in Set:
                ans[x[2]] = distance
                heapq.heappush(heap, (distance, index))
                flag = False
for i in range(Q):
    print(ans[i])

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

int main(){
int S;
cin >> S;
int h;
int m;
int s;
h=S / 3600 ;
m=(S / 60) - (h * 60);
s=S % 60;
cout << h <<":"<< m <<":" <<s<<endl;
return 0;
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
//J=1 O=2 I=4
int main(){
	int n;
	cin>>n;
	char skn[1001];
	for(int i=1;i<=n;i++){
		cin>>skn[i];
	}

	int keka[1001][8];


	keka[0][1]=1;
	keka[0][2]=0;
	keka[0][3]=0;
	keka[0][4]=0;
	keka[0][5]=0;
	keka[0][6]=0;
	keka[0][7]=0;
	

	for(int day=1;day<=n;day++){
		//J
		if(skn[day]=='J'){
			keka[day][1]=keka[day-1][1]
						+keka[day-1][3]
						+keka[day-1][5]
						+keka[day-1][7];
		}
		else{
			keka[day][1]=0;
		}
		//O
		if(skn[day]=='O'){
			keka[day][2]=keka[day-1][2]
						+keka[day-1][3]
						+keka[day-1][6]
						+keka[day-1][7];
		}
		else{
			keka[day][2]=0;
		}
		//I
		if(skn[day]=='I'){
			keka[day][4]=keka[day-1][4]
						+keka[day-1][5]
						+keka[day-1][6]
						+keka[day-1][7];
		}
		else{
			keka[day][4]=0;
		}
		//J+O
		if(skn[day]=='J'||skn[day]=='O'){
			keka[day][3]=keka[day-1][1]
						+keka[day-1][2]
						+keka[day-1][3]
						+keka[day-1][5]
						+keka[day-1][6]
						+keka[day-1][7];
		}
		else{
			keka[day][3]=0;
		}
		//J+I
		if(skn[day]=='J'||skn[day]=='I'){
			keka[day][5]=keka[day-1][1]
						+keka[day-1][3]
						+keka[day-1][4]
						+keka[day-1][5]
						+keka[day-1][6]
						+keka[day-1][7];
		}
		else{
			keka[day][5]=0;
		}
		//O+I
		if(skn[day]=='O'||skn[day]=='I'){
			keka[day][6]=keka[day-1][2]
						+keka[day-1][3]
						+keka[day-1][4]
						+keka[day-1][5]
						+keka[day-1][6]
						+keka[day-1][7];
		}
		else{
			keka[day][6]=0;
		}
		//J+O+I
		keka[day][7]=keka[day-1][1]
					+keka[day-1][2]
					+keka[day-1][3]
					+keka[day-1][4]
					+keka[day-1][5]
					+keka[day-1][6]
					+keka[day-1][7];

		for(int i=1;i<8;i++){
			keka[day][i]%=10007;
		}
	}
	int sum=0;
	for(int i=1;i<8;i++){
		sum+=keka[n][i];
	}
	cout<<sum%10007<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    char s[1001];
    int x=0;
    map<char, int> mp;
    mp['N']=0; mp['W']=1; mp['S']=2; mp['E']=3;

    scanf("%s", s);
    for (int i = 0; s[i] != '\0'; i++) {
        x = x | (1 << mp[s[i]]);
    }
    if (x==5 || x==10 || x==15) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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



int main(){
  int A,B;
  cin>>A>>B;
  
  int kaz=1;
  int mis=A;
  if(B==1){
    cout<<0<<endl;
    return 0;
  }
  while(mis<B){
    kaz++;
    mis+=(A-1);
  }
  cout<<kaz<<endl;
  
  
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    map<ll,ll> b; 
    ll o=0;
    rep(i,n){
        cin >> a.at(i);
        o=(o+a.at(i))%m;
        b[o]++;
    }
    ll ans=0,v=0;
    rep(i,n){
        auto it=b.find(v);
        if (it!=b.end()) ans+=b.at(v);
        v=(v+a.at(i))%m;
        b[v]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<string> vec(N);
  for(int i = 0; i<N;i++){
    cin >> vec.at(i); 
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(vec.at(i).at(j)=='.'){
        int count=0;
        if(i>0&&vec.at(i-1).at(j)=='#'){
          count+=1;
        }
        if(i<(N-1)&&vec.at(i+1).at(j)=='#'){
          count+=1;
        }
        if(j>0&&vec.at(i).at(j-1)=='#'){
          count+=1;
        }
        if(j<M-1&&vec.at(i).at(j+1)=='#'){
          count+=1;
        }
        if(i>0&&j>0&&vec.at(i-1).at(j-1)=='#'){
          count+=1;
        }
        if(i>0&&j<M-1 &&vec.at(i-1).at(j+1)=='#'){
          count+=1;
        }
        if(i<N-1&&j>0&&vec.at(i+1).at(j-1)=='#'){
          count+=1;
        }
        if(i<N-1&&j<M-1 &&vec.at(i+1).at(j+1)=='#'){
          count+=1;
        }
        char s='0'+count;
        vec.at(i).at(j) = s;
      }
    }
  }
  for(int i = 0;i<N;i++){
  cout << vec.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    pair<int, int> p[200010];
    rep(i, N) {
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p + N);
    int t = 0;
    rep(i, N) {
        t += p[i].second;
        if(t > p[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}


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

using namespace std;

int main(void) {
    int N, V[21], C[21], X;

    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> V[i];
    }
    for (int i=0;i<N;i++) {
        cin >> C[i];
    }

    X = 0;
    for (int i=0;i<N;i++) {
        if (V[i]-C[i]>=0) X += V[i] - C[i];
    }
    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 110
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,Dis[N],Dir[N],mp[N][N];
int dx[]={0,2,0,-2};
int dy[]={2,0,-2,0};

bool checkDir(int y,int x,int dir,int ndir){
  int nx = x+dx[ndir]/2;
  int ny = y+dy[ndir]/2;
  return !((dir+2)%4==ndir||nx<0||ny<0||mp[ny][nx]==0);
}

int used[N][N][4];
set<PP> mem[N][N][4][12];
set<PP> getNx(int sy,int sx,int sdir,int d){
  if(used[sy][sx][sdir]++) return mem[sy][sx][sdir][d];
  bool D[N][N][4][12]={};
  queue<PP> Q;
  
  int nsy = 2*sy + dy[sdir];
  int nsx = 2*sx + dx[sdir];
  if(!checkDir(2*sy,2*sx,sdir,sdir)) return set<PP>();
  D[nsy][nsx][sdir][1] = 1;
  Q.push(PP(P(nsy,nsx),P(sdir,1)));
  mem[sy][sx][sdir][1].insert(PP(P(nsy/2,nsx/2),P(sdir,-1)));
  
  while(!Q.empty()){
    PP t = Q.front();Q.pop();
    int y = t.first.first;
    int x = t.first.second;
    int dir = t.second.first;
    int c = t.second.second;
    
    if(c==10)continue;
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(!checkDir(y,x,dir,i)||D[ny][nx][i][c+1])continue; 
      D[ny][nx][i][c+1] = 1;
      Q.push(PP(P(ny,nx),P(i,c+1)));
      mem[sy][sx][sdir][c+1].insert(PP(P(ny/2,nx/2),P(i,-1)));
    }    
  }
  return mem[sy][sx][sdir][d];
}

set<P> bfs(int sy,int sx){
  set<P> res;
  bool D[N][N][N][4]={};
  queue<PP> Q;
  
  for(int i=0;i<4;i++)D[0][sy][sx][i] = 1,Q.push(PP(P(0,sy),P(sx,i)));
  
  while(!Q.empty()){
    PP t = Q.front();Q.pop();
    int idx = t.first.first;
    int y = t.first.second;
    int x = t.second.first;
    int dir = t.second.second;
    if(idx==n) {res.insert(P(x,y));continue;}

    set<PP> R = getNx(y,x,dir,Dis[idx]);
    for(PP r:R){
      int ny = r.first.first;
      int nx = r.first.second;
      int rdir = r.second.first;
      int ndir = Dir[idx];
      
      if(ndir == rdir)
	for(int j=0;j<4;j++){
	  if(!checkDir(2*ny,2*nx,rdir,j)||D[idx+1][ny][nx][j]) continue;
	  D[idx+1][ny][nx][j] = 1;
	  Q.push(PP(P(idx+1,ny),P(nx,j)));
	}

      if(ndir==rdir||!checkDir(2*ny,2*nx,rdir,ndir)||D[idx+1][ny][nx][ndir]) continue;
      D[idx+1][ny][nx][ndir] = 1;
      Q.push(PP(P(idx+1,ny),P(nx,ndir)));
    } 
  }
  return res;
}

int main(){
  int m,sx,sy;
  cin>>m>>sx>>sy>>n;
  
  for(int i=0,x,y,X,Y;i<m;i++){
    cin>>x>>y>>X>>Y;
    if(x>X)swap(x,X);
    if(y>Y)swap(y,Y);
    for(int i=2*y;i<=2*Y;i++)
      for(int j=2*x;j<=2*X;j++) mp[i][j] = 1;
  }

  for(int i=0;i<n;i++){
    char ch;
    cin>>Dis[i]>>ch;
    if(ch == 'N') Dir[i] = 0;
    if(ch == 'E') Dir[i] = 1;
    if(ch == 'S') Dir[i] = 2;
    if(ch == 'W') Dir[i] = 3;
  }

  set<P> ans = bfs(sy,sx);
  for(P a:ans)cout<<a.first<<" "<<a.second<<endl;
  return 0;
}

Measured memory_bytes: 166748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int x,flag=0;
  string s,t;
  cin>>s;
  x=s.size();
  rep(i,x/2){
    t=s.substr((x-2*(i+1))/2);
    if (flag==0) {
      rep(j,(x-2)/2){
        if (s.at(j)!=t.at(j)){
          break;
          }
        else if (s.at(j)==t.at(j) && j==((x-2*(i+1))/2)-1) {
          cout<<((x-2*(i+1))/2)*2<<endl;
          flag+=1;
          break;
        }  
      }
    }
  }
}

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

const int Maxn = 2005;
const int mod = 1000000007;

int n, m;
int A[Maxn], B[Maxn];
int dp[Maxn][Maxn][2];

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &B[i]);
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= m; j++) {
            // from 0
            dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][0]) % mod;
            dp[i][j][1] = (dp[i][j][1] + dp[i][j][0]) % mod;
            // from 1
            if (j < m) {
                dp[i][j + 1][1] = (dp[i][j + 1][1] + dp[i][j][1]) % mod;
                if (A[i] == B[j])
                    dp[i + 1][j + 1][0] = (dp[i + 1][j + 1][0] + dp[i][j][1]) % mod;
            }
        }
    int res = 0;
    for (int j = 0; j <= m; j++)
        res = (res + dp[n][j][0]) % mod;
    printf("%d\n", res);
    return 0;
}


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

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

using namespace std;

int main(){
	int n; cin>>n;
	vector<int> a(n+3);
	rep(i,n) cin>>a[i+1];

	int sum=0;
	rep(i,n+1) sum+=abs(a[i+1]-a[i]);
	rep(i,n) cout<<sum-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i])<<endl;

	return 0;
}


Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func kaibun(s string) bool {
	i := 0
	j := len(s) - 1
	for i < len(s)/2 {
		if s[i] != s[j] {
			return false
		}
		i = i + 1
		j = j - 1
	}

	return true
}

func check(s string) bool {
	if len(s)%2 == 0 {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2:]) == false {
			return false
		}
	} else {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2+1:]) == false {
			return false
		}
	}
	return true
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	S := sc.nextStr()

	if !kaibun(S) {
		fmt.Println("No")
	} else {
		if check(S) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    int a,b,c,t;
    cin>>a>>b>>c;
    t=a;
    a=c;
    c=b;
    b=t;
    cout<<a<<" "<<b<<" "<<c;
}


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

using namespace std;

const int INF = 1 << 30;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  vector<int> dp(N, INF);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < min(N, i + K + 1); j++) {
      chmin(dp[j], dp[i] + abs(H[j] - H[i]));
    }
  }

  cout << dp[N - 1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
    string s;
    cin >> s;
    int res = 0;

    int cnt = 0;
    for(char c: s) {
        if(c == 'g') {
            if(cnt > 0) {
                res++;
                cnt--;
            }
            else {
                cnt++;
            }
        }

        else {
            if(cnt > 0) {
                cnt--;
            }
            else {
                res--;
                cnt++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;
    int x, y;
    cin >> x >> y;

    vector<int> d;
    int cnt = 0;
    rep(i, S.size()) {
        if (S[i] == 'F') cnt++;
        else {
            d.push_back(cnt);
            cnt = 0;
        }
    }
    if (cnt != 0) d.push_back(cnt);

    int tmp = (int)d.size() / 2;
    int len = (int)d.size();
    vector<vector<bool>> X(tmp + 2, vector<bool>(16002, false));
    vector<vector<bool>> Y(tmp + 1, vector<bool>(16002, false));
    X[0][d[0] + 8000] = true;
    int xl = 0, yl = 0;
    repd(i, 1, d.size()) {
        if (2 * i >= len) break;
        xl = i;
        rep(j, 16002) {
            if (j - d[2 * i] >= 0) {
                X[i][j] = X[i][j] || X[i - 1][j - d[2 * i]];
            }
            if (j + d[2 * i] < 16002) {
                X[i][j] = X[i][j] || X[i - 1][j + d[2 * i]];
            }
        }
    }
    Y[0][8000] = true;
    repd(i, 1, d.size()) {
        if (2 * i - 1 >= len) break;
        yl = i;
        rep(j, 16002) {
            if (j - d[2 * i - 1] >= 0) {
                Y[i][j] = Y[i][j] || Y[i - 1][j - d[2 * i - 1]];
            }
            if (j + d[2 * i - 1] < 16002) {
                Y[i][j] = Y[i][j] || Y[i - 1][j + d[2 * i - 1]];
            }
        }
    }

    if (X[xl][8000 + x] && Y[yl][8000 + y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 16256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		int N = sc.nextInt();

		PriorityQueue pq = new PriorityQueue(N, new MyComparator());
		for(int i = 1;i <= N;i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			Sigoto s = new Sigoto(A, B);
			pq.add(s);
		}
		sc.close();

		long time = 0;
		boolean success = true;
		for(int i = 1;i <= N;i++) {
			Sigoto s = (Sigoto) pq.poll();
//			System.out.println(s);
			time += s.A;
			if(time > s.B) {
				success = false;
				break;
			}

//			System.out.println(time);
		}
		if(success) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}



	}
}

class MyComparator implements Comparator<Sigoto> {
	@Override
	public int compare(Sigoto s1, Sigoto s2) {
		if(s1.B < s2.B) {
			return -1;
		}else if(s1.B > s2.B) {
			return 1;
		}else {
			return 0;
		}
	}
}

class Sigoto {
	public long A;
	public long B;
//	public long C;

	public Sigoto(long a, long b) {
		A = a;
		B = b;
//		C = b - a;
	}

	@Override
	public String toString() {
		return "Sigoto [A=" + A + ", B=" + B + "]";
	}


}

Measured memory_bytes: 104944
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, k = map(int, input().split())
    res = a - b
    op = 1 if k % 2 == 0 else -1
    if abs(res) > 10 ** 18:
        print("Unfair")
    else:
        print(res * op)


if __name__ == '__main__':
    resolve()


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

int main(){
  string s;
  vector<string>edit;
  cin >> s;
  int index=-1;
  for(int i=0;i < s.size();i++){
    
    if(s.at(i) == '0'){
      edit.push_back("0");
      index++; 
    }else if(s.at(i) == '1'){
      edit.push_back("1");
      index++;
    }else{
      if(index == -1){
        continue;
      }else{
      edit.erase(edit.begin() + index);
      index--;  
      }
    }
  }
  for(int i=0;i<edit.size();i++){
    cout << edit.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
static const int MOD = 1000000007;

// DPテーブル
ll dp[2005];


int main() {
    int S;
    cin >> S;
    // 初期条件
    dp[0] = 1;
    for (int i = 3; i <= S; i++) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }
    if (S >= 1 && S <= 2) cout << 0 << endl;
    else cout << dp[S] << endl;

    return 0;
}

Measured memory_bytes: 3624
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(_ for _ in input())
    ans = 1

    for i in range(len(S)):
        if(len(S)%2 == 1 or i ==0):
            S.pop(len(S)-1)
            continue
        mid = len(S)//2

        if(S[:mid] == S[mid:]):
            ans = len(S)
            break
        S.pop(len(S)-1)
    print(ans)
    
if __name__ == '__main__':
    main()


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

int main() {
  
  int n,a,b;
  cin >> n;
  
  if ( n == 1 ){
    cout << "Hello World" << endl;
  }else{
    cin >> a >> b;
    cout << a + b << endl;
  }
  
  
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        t:usize
    }
    for _ in 0..t {
        input! {
            n:usize
        }
        let mut ans = 0_isize;
        let mut type_A = vec![vec![]; n + 1];
        let mut type_B = vec![vec![]; n + 1];
        for _ in 0..n {
            input! {k:usize,l:isize,r:isize}
            ans += std::cmp::min(l, r);
            if l > r {
                type_A[k].push(l - r);
            } else {
                type_B[k].push(r - l);
            }
        }
        let mut h = BinaryHeap::new();
        for i in 1..=n {
            for &q in &type_A[i] {
                h.push(-1 * q);
            }
            while h.len() > i {
                h.pop();
            }
        }
        ans += -1 * h.iter().sum::<isize>();
        let mut h = BinaryHeap::new();
        for i in (1..=n).rev() {
            for &q in &type_B[i] {
                h.push(-1 * q);
            }
            while h.len() > n - i {
                h.pop();
            }
        }
        ans += -1 * h.iter().sum::<isize>();
        println!("{}", ans);
    }
}


Measured memory_bytes: 21524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char S[100001];
    int  O[100000];
    int n,i=0,count,jmin,j,index,flag=0,nbR=0,nbL=0;
   
    
    scanf("%s",S);
    n=strlen(S);
    for (i=0;i<n;i++){
        O[i]=0;
    }
    for (i=0;i<n;i++){
           if ((S[i]=='R')){
              nbR++;
            }
           if ((S[i]=='L')){
              nbL++;
            }
           if ((S[i]=='R')&&(S[i+1]=='L')){
             index=i; 
           }
           else if (((S[i]=='L')&&(S[i+1]=='R'))||(i==n-1)){
               if ((nbR%2==1) && (nbL%2==0)){
                 count=nbR+nbL;
                 O[index+1]=count/2;
                 O[index]=count-O[index+1];
               }
               else {
                   count=nbR+nbL;
                   O[index]=count/2;
                   O[index+1]=count-O[index];
               }
               nbR=0;
               nbL=0;
               
           }
           
    } 
    for (i=0;i<n;i++){
        printf("%d\n",O[i]);
    }
    return (EXIT_SUCCESS);
}



Measured memory_bytes: 896
#include <cstdio>
int a[100010];
int dist[100010];
int ch[100010];
int abs(int x){
    if(x>0) return x;
    return -x;
}
int main(int argc, const char * argv[]) {
    
    int n;
    
    scanf("%d",&n);
    
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    long long ans = 0;
    
    for(int i=0;i<=n;i++){
        dist[i+1] = abs(a[i+1]-a[i]);
        
        ans+=abs(a[i+1]-a[i]);
        if(i>=2) {
            ch[i] = abs(a[i]-a[i-2]);
        }
    }
    ch[n+1]=abs(0-a[n-1]);
    
    
    for(int i=1;i<=n;i++){
        printf("%lld\n",ans-dist[i]-dist[i+1]+ch[i+1]);
    }
    return 0;
}


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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	string S;
	cin >> S;
	int len = S.size();
	bool a[26] = {0};
	rep(i, len){
		a[S[i] - 'a'] = true;
	}
	rep(i, 26){
		if(!a[i]){
			printf("%c\n", i + 'a');
			return 0;
		}
	}
	puts("None");
	return 0;
}


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

int main(void)
{
	int p=1<<30,j=1<<30;
	int a,b;

	for(int i = 0; i < 3; i++){
		cin >> a;
		p = min(p,a);
	}
	for(int i = 0; i < 2; i++){
		cin >> a;
		j = min(j,a);
	}

	cout << p+j-50 << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

ll a,b;

main()
{
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
}

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

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            int K = int.Parse(ReadLine());
            string[] Reader = ReadLine().Split(' ');
            int A = int.Parse(Reader[0]);
            int B = int.Parse(Reader[1]);

            for (int loop = A; loop <= B; loop++) 
            {
                if (loop % K == 0) 
                {
                    WriteLine("OK");
                    return;
                }
            }

            WriteLine("NG");
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}

Measured memory_bytes: 17868
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int p[8],q[8],t[8],a,b;
int main(){
	cin>>n;
	rep(i,n)
	cin>>p[i];
	rep(i,n)
	cin>>q[i];
	rep(i,n){
		t[i]=i+1;
	}
	int j=0;
	do{
		bool f=true;
		for(int i=0;i<n;i++)
		if(p[i]!=t[i])
		f=0;
		if(f)
		a=j;
		f=1;
		for(int i=0;i<n;i++)
		if(q[i]!=t[i])
		f=0;
		if(f)
		b=j;
		j++;
	}while(next_permutation(t,t+n));
	cout<<abs(a-b);
	re 0;
}


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

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

  string s;
  cin >> s;

  string sunny = "Sunny", cloudy = "Cloudy", rainy = "Rainy";
  if (s == sunny)
    cout << cloudy << endl;
  else if (s == cloudy)
    cout << rainy << endl;
  else
    cout << sunny << endl;
}


Measured memory_bytes: 256
#INPUT
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)

#Utilitiy
def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy():
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j])
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay
    return ans, p
        
#MAIN
ans, points = greedy()


for i in range(D):
    print(ans[i])

Measured memory_bytes: 9508
# -*- coding: utf-8 -*-
import sys

def main():
	H, W = map(int, input().split(" "))
	h, w = map(int, input().split(" "))
	
	total = H - h
	total2 = W - w
	
	print(total * total2)
			
if __name__ == "__main__":
	main()
	

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    if (s <= "2019/04/30")
        OP("Heisei");
    else
        OP("TBD");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

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

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

int main() {
	int n; scanf("%d", &n); std::vector<long double> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	
	auto dp = make_v<long double>(n + 1, n + 1); dp[0][0] = 1.;
	for(int i = 0; i < n; i++) {
		double latte = p[i], malta = (1. - p[i]);
		
		for(int j = 0; j < i + 1; j++) {
			dp[i + 1][j + 1] += dp[i][j] * latte;
			dp[i + 1][j] += dp[i][j] * malta;
		}
		for(int j = 0; j < i + 1; j++) dp[i + 1][j];
	}
	
	double ans = 0;
	for(int i = 0; i <= n; i++) if(i > n - i) ans += dp[n][i];
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int ones_place,tens_place,hundred_place,thouthand_place,tenthouthand_place;
  int Palindromic_counter = 0;
  for (int i = A; i <=B ;i++ ){
    ones_place = i%10;
    tens_place = ((i - ones_place)%100)/10;
    hundred_place = ((i - ones_place - tens_place*10)%1000)/100;
    thouthand_place = ((i - ones_place - tens_place*10 - hundred_place*100)%10000)/1000;
    tenthouthand_place = ((i - ones_place - tens_place*10 - hundred_place*100 - thouthand_place*1000)%100000)/10000;
    if ((tenthouthand_place == ones_place)&&(thouthand_place == tens_place)){
      Palindromic_counter++;    
    }
  }
  cout << Palindromic_counter << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		long m = 100;
		long X = scan.nextLong();
		int y = 0;
		scan.close();
		do {
			m = (long) (m+(m*0.01));
			y++;
		}while(m<X);
		
		System.out.println(y);

	}
}

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


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

    sort(a.begin(), a.end());

    ll w = -1, h = -1;
    for(int i = 1; i < n; i++){
        if(a[i] == a[i-1]){
            if(w == -1){
                w = a[i];
                a[i] = 0;
            }
            else{
                h = w;
                w = a[i];
                a[i] = 0;
            }
        }
    }
    if(h != -1)
        cout << w*h << endl;
    else
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
#define ll long long;
#define vi vector<int>;
#define vvi vector<vi>;
#define vll vector<ll>;

int we[300000] = {};
int main() {
    fastcin;
    int n, ans = 300001;
    string s;
    cin >> n >> s;
    rep(i, 1, n) {
        if(s[i]=='E') we[0]++;
    }
    rep(i, 1, n) {
        we[i] = we[i-1];
        if(s[i-1]=='W') we[i]++;
        if(s[i]=='E') we[i]--;
    }
    rep(i, 0, n) ans = min(ans, we[i]);
    print(ans);
    return 0;
}

Measured memory_bytes: 1812
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cctype>

using namespace std;

int to_i(const string& str) {
    int res = 0;
    for (int i = 0; i < str.size(); ++i) {
        res = res * 10 + (str[i] - '0');
    }
    return res;
}


int main(void) {

    string cards, n;
    while (true) {
        cin >> cards;
        if (cards == "-") { break; }
        cin >> n;

        int total = 0;
        for (int _ = 0, N = to_i(n); _ < N; ++_) {
            cin >> n;
            total += to_i(n);
        }
        rotate(cards.begin(), cards.begin() + total % cards.size(),
               cards.end());

        printf("%s\n", cards.c_str());
    }

    return 0;
}

Measured memory_bytes: 1188
N = int(input())

ABC = []
for _ in range(N):
  a, b, c = map(int, input().split())
  ABC.append((a, b, c))

dp = [[0] * 3 for i in range(N)]

for i, abc in enumerate(ABC):
  for k in range(3):
    if (i == 0):
      dp[i][k] = abc[k]
    else:
      max_dp_i = dp[i][k]
      for j in range(3):
        if (k == j):
          continue
        if (max_dp_i < (dp[i-1][j] + abc[k])):
          max_dp_i = (dp[i-1][j] + abc[k])
      
      dp[i][k] = max_dp_i

print(max(dp[-1]))

Measured memory_bytes: 40264
#A=int(input())
#A=list(map(int,(input().split())))
A=list(map(int,(input().split())))
N=A[0]
def dou(ans):
	for x in range(1,10):
		for y in range(1,10):
			if (x*y==ans):return True
	return False
if (dou(N)):
	print("Yes")
else:
	print("No")	

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

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

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        cin >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2 == 0) {
        cout << (b[n/2] + b[n/2-1]) - (a[n/2] + a[n/2-1]) + 1 << endl;
    }
    else {
        cout << b[n/2] - a[n/2] + 1 << endl;;
    }
    return 0;
}



Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+9;
const int mod=1e9+7;
int fac[N],inv[N];
int n,k;
vector<int>g[N];
void init(){
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(int i=2;i<N;i++)fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<N;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
int C(int x,int y){
    if(y>x)return 0;
    return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int dfs(int u,int fa){
    int x=k-2,y=g[u].size()-1;
    if(u==1)x=k-1,y=g[u].size();
    int ans=1ll*C(x,y)*fac[y]%mod;
    for(auto v:g[u]){
        if(v==fa)continue;
        ans=1ll*ans*dfs(v,u)%mod;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    init();
    cin>>n>>k;
    for(int i=1,v,u;i<n;i++)cin>>u>>v,g[u].push_back(v),g[v].push_back(u);
    cout<<1ll*dfs(1,0)*k%mod;
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll x, n; cin>>x>>n;
  if(n==0) cout<<x;
  else {
    ll a[102];
    rep(i, 102) a[i]=i;
    
    rep(i, n) {
      ll b;cin>>b;
      a[b]=200;
    }
    
    ll d=200;
    for(ll i=0; i<=102; i++) {
      d=min(d, max(x-a[i], a[i]-x));
    }
    
    if(x-d==-1)cout<<-1;
    else{
    if(a[x-d]!=200) cout<<a[x-d];
    else cout << a[x+d];
    }
  }
}

Measured memory_bytes: 3620
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;

LL L[100];

int main() {
	int n;
	cin >> n;
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= n; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[n] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main()
	{
		var abc = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var a = abc[0];
		var b = abc[1];
		var c = abc[2];
		var remains = new List<int>();

		var i = 1;
		var result = false;
		while (!result) {
			var remain = a * i % b;
			if (remain == c) {
				result = true;
			} else if (remains.Contains(remain)) {
				break;
			} else {
				remains.Add(remain);
			}

			++i;
		}

		Console.WriteLine(result ? "YES" : "NO");
	}
}


Measured memory_bytes: 13148