akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>

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

int dx[4] ={0, 1, 0, -1}; int dy[4] = {1,0,-1,0};
int i, j,k,base,island=0,X,Y;
int  map[20][20] = {};
int flag[20][20] = {};

int bfs(int x, int y){
  queue<P> que;
  que.push(P(x,y));
  flag[y][x] = 1;
  
  while(que.size()){
    P p=que.front();
    que.pop();
    
    for(k=0;k<4;k++){
      int nx = p.first+dx[k], ny = p.second+dy[k];
      if(flag[ny][nx] == 0 && nx>=0 && 11>=nx && ny>=0 && ny<=11){
	flag[ny][nx] = 1;
	if(map[ny][nx] == 1){
	  que.push(P(nx,ny));
	}
      }
    }
  }
  return 0;
}
  
  
int main(){
  while(~scanf("%1d", &map[0][0])) {
    j = 1;
    for(i = 0; i < 12; i++, j=0)
      for(;j < 12; j++) {
	scanf("%1d", &map[i][j]);
      }
    for(i=0;i<12;i++){
      for(j=0;j<12;j++){
	flag[i][j]=0;
      }
    }
  island=0;
  for(Y=0; Y<12;Y++){
    for(X=0; X<12;X++){
      if(flag[Y][X] == 0 && map[Y][X] == 1){
	bfs(X,Y);
	  island++;
      }
    }
  }
  cout <<island << endl;
  }
  return 0;
  
}

    

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		int a,b,c,i,j,k,l,n,q;
		cin>>n>>k>>q;
		int art[n];
		for(i=0;i<n;i++){
			art[i]=k;
		}
		for(i=0;i<q;i++){
			cin>>c;
			c=c-1;
			art[c]+=1;
		}
		for(i=0;i<n;i++){
			art[i]-=q;
		}
		for(i=0;i<n;i++){
			if(art[i]<=0) cout<<"No"<<"\n";
			else cout<<"Yes"<<"\n";
			
		}
	
}

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

int main()
{
  string str;
  while(cin>>str){
    int res1 = 0, res2 = 0;
    for(int i = 0; i < str.size()-2; i++){
      if(str[i+1] == 'O'&& str[i+2] == 'I'){
	if(str[i] == 'J') res1++;
	if(str[i] == 'I') res2++;
      }
    }
    cout<<res1<<endl<<res2<<endl;
  }
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main() {

string s, t;
cin >> s >> t;

sort(all(s));
sort(all(t));
reverse(all(t));

if(s < t) yes;
else no;

}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(S.size()-1) == '0' || S.at(S.size()-1) == '1' || S.at(S.size()-1) == '6' || S.at(S.size()-1) == '8'){
    cout << "pon" << endl;
  }
  else if (S.at(S.size()-1) == '3'){
    cout << "bon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}



Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int A[200000];

int main()
{
	int K, N, d = 10000000;

	cin >> K >> N;
	rep(i, N) cin >> A[i];

	d = (K - A[N - 1]) + A[0];
	rep(i, N - 1) d = max(d, A[i + 1] - A[i]);

	cout << K - d << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t 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()


const vector<int> che={6,9};

int main(){
    int n; cin>>n;
    int ans=0;
    vector<int> p(n+5,-1);
    p[0]=0;
    rep(i,n){
        vector<int> cnt;
        rep(j,2){
            int a=che[j];
            rep(k,8){
                if((i+1)<pow(a,(k+1))) break;
                if(p[i+1-pow(a,k+1)]!=-1) cnt.push_back(p[i+1-pow(a,k+1)]+1);
            }
        }
        if(p[i]!=-1) cnt.push_back(p[i]+1);
        if(!cnt.empty()){
          sort(btoe(cnt));
          p[i+1]=cnt[0];
        }
    }
    cout<<p[n]<<endl;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>X(N),Y(N),P(N);
  for(int i=0;i<N;i++)cin>>X[i]>>Y[i]>>P[i];
  int bit2=pow(2,N);
  vector<vector<int>>tate(bit2,vector<int>(N));
  vector<vector<int>>yoko(bit2,vector<int>(N));
  for(int b=0;b<bit2;b++){
    for(int i=0;i<N;i++){
      int res=abs(X[i]);
      for(int j=0;j<N;j++){
        if(((b>>j)%2))res=min(res,abs(X[i]-X[j]));
      }
      tate[b][i]=res*P[i];
    }
    for(int i=0;i<N;i++){
      int res=abs(Y[i]);
      for(int j=0;j<N;j++){
        if(((b>>j)%2))res=min(res,abs(Y[i]-Y[j]));
      }
      yoko[b][i]=res*P[i];
    }
  }
  int bit=pow(3,N);
  vector<int>ANS(N+1,LONG_MAX);
  for(int b=0;b<bit;b++){//30000
    int s=0;
    int bbb=b;
    for(int j=0;j<N;j++){
      s+=(bbb%3!=0);
      bbb/=3;
    }
    int bb=b;
    int t=0,y=0,two=1;;
    for(int j=0;j<N;j++){//10
      if(bb%3==1)t+=two;
      if(bb%3==2)y+=two;
      bb/=3;
      two*=2;
    }
    int ans=0;
    for(int i=0;i<N;i++)ans+=min(tate[t][i],yoko[y][i]);
    ANS[s]=min(ans,ANS[s]);
  }
  for(auto it:ANS)cout<<it<<endl;
  return 0;
}


Measured memory_bytes: 13388
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, a[200010];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	int e = 1;
	for (int i = 0; i + 1 < n; i++)
		e &= a[i] != a[i + 1];
	printf(e ? "YES\n" : "NO\n");
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
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; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    
    ll n,k;
    cin >> n >> k;
    int ary[n];
    rep(i,n) cin >> ary[i];

    ll uchi_tentosu = 0;
    ll soto_tentosu = 0;
    rep(i,n-1) {
        REP(j,i+1,n) {
            if (ary[i] > ary[j])
            {
                uchi_tentosu++;
            }
        }
    }


    rep(i,n) rep(j,n) {
        if (ary[i] > ary[j]) soto_tentosu++;
    }
    uchi_tentosu %= MOD;
    soto_tentosu %= MOD;
    ll ans = (((k * (k-1)/2)%MOD) * soto_tentosu)%MOD +  (k * uchi_tentosu)%MOD;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = [[int(readline()), i] for i in range(1, n + 1)]
    a.sort()

    c = 0
    for i in range(1, n + 1):
        if a[i - 1][1] % 2 != i % 2:
            c += 1
    ans = c // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85332
n, a = map(int, input().split())
x = list(map(lambda q: int(q) - a, input().split()))
X = max(max(x), a)
N = 2 * n * X
dp = [[0] * (N + 1) for i in range(n + 1)]
dp[0][n * X] = 1
for i in range(1, n + 1):
    for j in range(N + 1):
        if j - x[i - 1] < 0 or j - x[i - 1] > N:
            dp[i][j] = dp[i - 1][j]
        elif j - x[i - 1] <= N:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]]

print(dp[n][n * X] - 1)

Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FILE freopen("input.txt", "rt", stdin);freopen("output.txt", "wt", stdout);
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
const char nl = '\n';
int main(){
    FAST_IO;
    //FILE;
    int n,m;
    cin>>n>>m;
    if(m%2 ==0 && m<=n*4 && m>=n*2){
        cout<<"Yes"<<nl;
    }else
        cout<<"No"<<nl;
    return 0;
}




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

int main()
{
	string s;
	int n;
	cin >> n>> s;
	for (int i = 0; i < s.length(); i++) {
		s[i] += n;
		if (s[i] >= 'A' + 26)
			s[i] -= 26;
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  REP(i,h) {
    REP(j,w) {
      cin >> c[i][j];
    }
  }
  int ans=0;
  REP(i,pow(2,h)) {
    vi row_check;
    REP(x,h) {
      if((i>>x)&1) row_check.push_back(x);
    }
    REP(j,pow(2,w)) {
      vi column_check;
      REP(y,w) {
        if((j>>y)&1) column_check.push_back(y);
      }
      int cnt=0;
      REP(a,h) {
        REP(b,w) {
          if(find(ALL(row_check),a)==row_check.end()) continue;
          if(find(ALL(column_check),b)==column_check.end()) continue;
          if(c[a][b]=='#') cnt++;
        }
      }
      if(cnt==k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  long double a, b, h, m;
  long double pi=3.141592653589793;
  cin >> a >> b >> h >> m;
  long double H, M, r, l;
  H=h/6+(m/30*1/12);

  M=m/30;

  r=H - M;
  l=sqrt(a*a + b*b - 2*a*b*cos(r*pi));
  cout << fixed << setprecision(20) << l << endl;

  return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int n;
pair <int, int> x[200001];
int ans[200001];
int main(){
    #ifdef Kanikou
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Kanikou
    read(n);
    FOR(i, 1, n) read(x[i].first);
    FOR(i, 1, n) x[i].second=i;
    sort(x+1, x+n+1);
    int pos=n/2;
    FOR(i, 1, n){
        if(i<=pos) ans[x[i].second]=(x[pos+1].first);
        else ans[x[i].second]=(x[pos].first);
    }
    FOR(i, 1, n){
        write(ans[i]);
        putchar("\n"[0]);
    }
}

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


int main(){
    int n;
    cin >> n;
    int A[2][n];
    int sum=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin >> A[i][j];

            if(i==1){
                sum += A[i][j];
            }
        }
    }

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

string S;

int mem[100005][20];

void init(){
    for(int i=0;i<100005;++i)for(int j=0;j<20;++j)mem[i][j]=-1;
}

int solve(int n,int m){
    if(mem[n][m]!=-1)return mem[n][m];
    int res=0;
    if(n==S.size()){
        if(m==5)return 1;
        else return 0;
    }
    if(S[n]!='?'){
        int s=S[n]-'0';
        int tm=(s+10*m)%13;
        res+=solve(n+1,tm);
    }
    else {
        for(int i=0;i<=9;++i){
           int tm=(i+10*m)%13;
           res+=solve(n+1,tm);
           res%=mod;
        }
    }
    return mem[n][m]=res;
}

signed main(){
    init();
    cin>>S;
    cout<<solve(0,0)<<endl;
}


Measured memory_bytes: 22400
N = int(input())
A = list(map(int, input().split()))

odd = len(list(filter(lambda x: x % 2 != 0, A)))
even = N - odd

ans = "YES"


if odd == 1 and even == 0:
    odd = odd
elif odd % 2 == 1:
    ans = "NO"
print(ans)


Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vi a(n);
	int lastRed = 0, r = 0, w = 0;
	for (int i = 0; i < n; i++) {
		char c = s[i];
		if (c == 'W')a[i] = 0, w++;
		else a[i] = 1, r++;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'R') {
			lastRed = i;
			break;
		}
	}
	int rf = 0, ans = 0;
	if (r == 0) {
		cout << r;
		return;
	}
	rep(i, 0, n) {
		if (s[i] == 'R')rf++;
		if (s[i] == 'W') {
			swap(s[i], s[lastRed]);
			ans++;
			rf++;
			if (rf == r)break;
			for (int j = lastRed; j >= 0; j--) {
				if (s[j] == 'R')lastRed = j;
			}
		}
		if (rf >= r)break;
	}
	// trace(r)
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

int main () {
  string s;
  cin >> s;
  
  int count = 0;
  for (int i = 0; i < 6; i++) {
    if (s[i] == '1') {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5&&c==7||a==5&&c==5&&b==7||b==5&&c==5&&a==7)
		printf("YES");
		else
			printf("NO");
			return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b, c;
  cin >> n;
  c = n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    c += (b - a);
  }
  cout << c << endl;
}

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

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

	int N;
	int size=0;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	size=given.size();

	sort(given.begin(), given.end());
	given.erase(std::unique(given.begin(), given.end()), given.end());
	
	if(size==given.size()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
count = 0
nums = [int(x.strip()) for x in input().split(' ')]
num_sum = sum(nums)
tmp = num_sum / (4*M)

for num in nums:
  if not num < tmp:
    count += 1
    
if count >= M:
  print('Yes')
else:
  print('No')

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

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  long cnt;
  cnt = 0;
  for (int n = 0; n < N; n++) {
    cin >> a[n];
  }
  for (int n = 1; n < N; n++) {
    while(a[n-1] > a[n]){
      a[n] += 1;
      cnt+=1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4380
N=int(input())
A=list(map(int,input().split()))
d={}
a=0
for i in range(N):
    n=A[i]
    if i-n in d:
        a+=d[i-n]
    if n+i in d:
        d[n+i]+=1
    else:
        d[n+i]=1
print(a)

Measured memory_bytes: 40352
#include <iostream>

using namespace std;

int main(){
	long long N, x, a[100000];
	cin >> N >> x;
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}

	long long ans = 0;
	if (a[0] > x){
		ans += a[0] - x;
		a[0] = x;
	}
	for (int i = 0; i < N - 1; i++){
		if (a[i] + a[i+1] > x){
			ans += a[i + 1] + a[i] - x;
			a[i + 1] = x - a[i];
		}
	}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x = 0, fh = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
	return x * fh;
}

typedef long long ll;
const int N = 1e3;
int dp[N];
struct node {
	int a, b;
	double c;
	bool operator < (const node &rhs) const {
		return c < rhs.c;
	}
};
node lt[5];
ll ans = 0;
int main () {
	For (i, 1, 4) {
		lt[i].a = read();
		lt[i].b = (1 << (i - 1));
		lt[i].c = (double) lt[i].a / (double) lt[i].b;
	//	cout << lt[i].a << ' ' << lt[i].b << ' ' <<lt[i].c <<endl;
	}
	sort (lt + 1, lt + 5);
	ll v = (ll)read() * 4LL;
	//printf ("%d %d\n", lt[1].b, lt[1].a);
	ans = (v / (ll)lt[1].b) * (ll)lt[1].a;
	v %= lt[1].b;
	Set(dp, 0x3f);
	dp[0] = 0;
	For (i, 1, 4)
		For (j, lt[i].b, v) {
			chkmin(dp[j], dp[j-lt[i].b] + (ll)lt[i].a);
		}
	ans += dp[v];
	printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 5e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long double pi = 3.141592653589793238;
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int A,B;
        cin >> A >> B;
        A--;B--;
        uf.unite(A,B);
    }
    set<int>st;
    for(int i = 0; i < N; i++) {
        st.insert(uf.find(i));
    }
    cout << st.size()-1 << endl;
}


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

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

  LL ans = 1e9;
  for (int i = 0; i <= n - k; i ++) {
    LL tmp1 = abs(a.at(i)) + abs(a.at(i) - a.at(i + k - 1));
    LL tmp2 = abs(a.at(i + k - 1)) + abs(a.at(i + k - 1) - a.at(i));
    ans = min(ans, min(tmp1, tmp2));
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()
for i,j in zip(s,t):
  if i > j:
    print("No")
    exit()
  elif i < j:
    print("Yes")
    exit()
len_s = len(s)
len_t = len(t)
if len(s) >= len(t):
  print("No")
else:
  print("Yes")

    


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
const int N = 58;
const int M = 3e3 + 7;
int n;
int A;
int a[N];
ll dp[N][M];
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    scanf("%d%d", &n, &A);
    REP(i, 0, n) scanf("%d", &a[i]);
    dp[0][0] = 1;
    REP(i, 0, n){
        //printf("i = %d\n", i);
        FOR(j, 1, n + 1){
            //printf("j = %d\n", j);
            FOR(k, a[i], M){
                //printf("k = %d\n", k);
                dp[j][k] += dp[j - 1][k - a[i]];
                //printf("dp[j][k] = %lld\n", dp[j][k]);
            }
        }
    }
    ll res = 0;
    REP(j, 1, n + 1){
        res += dp[j][j * A];
    }
    printf("%lld\n", res);
    return 0;
}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;

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

    return 0;
}


Measured memory_bytes: 3104
# coding: utf-8

import re
from scipy import integrate
import math
from operator import itemgetter
from collections import defaultdict as dd
from collections import Counter
from collections import deque

import numpy as np
import itertools

import heapq

from copy import deepcopy as dcopy
import fractions
def main():
    global N, ma, mb
    N, ma, mb = map(int, input().split())
    shop = [list(map(int, input().split())) for n in range(N)]

    status = dd(int)
    status[(0,0)] = 0
    minimum = 100000
    for product in shop:
        # buy
        old_status = dcopy(status)
        for s, v in old_status.items():
            key = (s[0]+product[0], s[1]+product[1])
            value = v + product[2]
            if not key in status:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value
            elif status[key] > value:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value

    if minimum == 100000:
        print(-1)
    else:
        print(minimum)

def check(key):
    c = fractions.gcd(key[0], key[1])
    if key[0]/c == ma and key[1]/c == mb:
        return True
    else:
        return False

if __name__ == "__main__":# {{{
    try:
        import test
        test.test()
    except:
        main()# }}}


Measured memory_bytes: 26400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mx = 1e9+5;
int main()
{
	//freopen("in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll ar[n], dp[n];
	for(int i = 0; i<n; i++){cin>>ar[i];}
	memset(dp, mx, sizeof(dp));
	dp[0]=0;
	for(int i = 0; i<n; i++){
		for(int j: {i+1, i+2}){
			if(j<n){
				dp[j] = min(dp[j], dp[i]+abs(ar[j]-ar[i]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
def loop(a, m)
  k = 0
  x = 1
  while true
    k += 1
    x = (a * x) % m
    break if x == 1
  end

  return k
end

### main

while true
  a1, m1, a2, m2, a3, m3 = gets.chomp.split(" ").map{|s| s.to_i}
  break if (a1 | m1 | a2 | m2 | a3 | m3) == 0

  k1 = loop(a1, m1)
  k2 = loop(a2, m2)
  k3 = loop(a3, m3)

  puts k1.lcm(k2).lcm(k3)
end

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

using namespace std;

int main(void) {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (auto &v : A) cin >> v;

  int ans = A[0] + K - A[N - 1];

  for (int i = 0; i < N - 1; ++i) {
    ans = max(ans, A[i + 1] - A[i]);
  }
  ans = K - ans;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3672
#include "bits/stdc++.h"

using namespace std;

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

    int n,k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i=0; i<n; i++) {
        cin >> arr[i];
    }
    for(int i=k; i<n; i++) {
        if(arr[i-k]>=arr[i])
            cout << "No\n";
        else
            cout << "Yes\n";
    }

    return 0;
}


Measured memory_bytes: 3940
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  def repeatSquares(x: Long, n: Int, mod: Int): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2, mod)
    else
      (x * repeatSquares(x*x % mod, n/2, mod)) % mod
  }


  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  
  val _S = in.next()

  //
  val MOD = 1e9.toInt + 7

  val N = _S.length
  val S = "0" + _S.reverse

  //val a = new Array[Int](N)


  val dp = Array.ofDim[Long](N+1, 13)
  dp(0)(0) = 1

  for (i <- 1 to N) {
    val _now = S(i)
    val base = repeatSquares(10, i-1, 13)

    if (_now == '?') {
      for (now <- 0 to 9) {
        for (k <- 0 until 13) {
          if (dp(i-1)(k) > 0) {
            val hoge = ((now * base + k) % 13).toInt
            dp(i)(hoge) += dp(i-1)(k)
            dp(i)(hoge) %= MOD
          } 
        }
      }
    }
    else {
      val now = _now.toInt - '0'.toInt

      for (k <- 0 until 13) {
        if (dp(i-1)(k) > 0) {
          val hoge = ((now * base + k) % 13).toInt
          dp(i)(hoge) += dp(i-1)(k)
          dp(i)(hoge) %= MOD
        }
      }
    }
  }

  //dp.foreach(a => println(a.deep))
  println(dp(N)(5))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 62476
#include<iostream>

using namespace std;

long long calcGCD(long long a, long long b) {
	long long result = 0;

	while(result == 0) {
		if(a > b){
			a = a % b;
			if (a == 0) {
				result = b;
			}
		}
		else {
			b = b % a;
			if (b == 0) {
				result = a;
			}
		}
	} 
	return result;
}

int main() {
	long long a, b;

	while (cin >> a >> b) {

		long long gcd = calcGCD(a, b);
		long long lcm = a * b / gcd;

		cout << gcd << ' ' << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int x = parseInt(sc.next());
		sc.close();
		double v = (double)a*a*b;
		double ans = 0.0d;
		if(v/2<=x) {
			ans = atan((((v-x)/(a*a))*2)/a);
		} else {
			ans = atan((double)b/((((double)x/b)/a)*2));
		}
		out.println(toDegrees(ans));
	}
}


Measured memory_bytes: 23508
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> a[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
    }

    for (int i = 1; i < N; ++i) {
        if (a[i - 1] + a[i] > x) {
            long long diff = a[i - 1] + a[i] - x;
            ans += diff;
            a[i] -= diff;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3996
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	int H, W;
	cin >> H >> W;

	vector <string> vs(H);
	for (int y = 0; y < H; ++y)
	{
		cin >> vs[y];
	}

	vector <vector <int> > numX(H, vector <int>(W));
	vector <vector <int> > numY(H, vector <int>(W));

	for (int y = 0; y < H; ++y)
	{
		int num = 0;
		int st = 0;
		for (int x = 0; x < W; ++x)
		{
			if (vs[y][x] == '.')
			{
				num++;
			}
			else
			{
				for (int tmp=st;tmp<x;++tmp)
				{
					numX[y][tmp] = num;
				}
				st = x + 1;
				num = 0;
			}
		}

		for (int tmp = st; tmp<W; ++tmp)
		{
			numX[y][tmp] = num;
		}
	}

	for (int x = 0; x < W; ++x)
	{
		int num = 0;
		int st = 0;
		for (int y = 0; y < H; ++y)
		{
			if (vs[y][x] == '.')
			{
				num++;
			}
			else
			{
				for (int tmp = st; tmp<y; ++tmp)
				{
					numY[tmp][x] = num;
				}
				st = y + 1;
				num = 0;
			}
		}

		for (int tmp = st; tmp<H; ++tmp)
		{
			numY[tmp][x] = num;
		}
	}

	int ret = 0;

	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			if (vs[y][x] == '.')
			{
				amax(ret, numY[y][x] + numX[y][x] - 1);
			}
		}
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 35712
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = line[0];
        var b = line[1];
        var c = line[2];
        Console.WriteLine(a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0] ? "YES" : "NO");
    }
}

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

int main()
{
    string A, B;
    cin >> A >> B;
    int sizeA = A.size();
    int sizeB = B.size();
    if (sizeA > sizeB)
    {
        cout << "GREATER" << endl;
    }
    else if (sizeA < sizeB)
    {
        cout << "LESS" << endl;
    }
    else
    {
        for (int i = 0; i < sizeA; i++)
        {
            int ketaA = A[i];
            int ketaB = B[i];
            if (ketaA == ketaB)
                continue;
            else if (ketaA > ketaB)
            {
                cout << "GREATER" << endl;
                return 0;
            }
            else
            {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans=INT_MIN;
int x[4]={0,0,1,-1};
int y[4]={1,-1,0,0};
int bfs(int i,int j,vector<vector<char> > & v,vector<vector<bool> > & vis)
{
	ans=INT_MIN;
	vis[i][j]=true;
	queue<pair<int,pair<int,int>>> que;
	que.push({i,{j,0}});
	
	while(que.empty()==false){
		pair<int,pair<int,int> > one=que.front();
		vis[one.first][one.second.first]=true;
		que.pop();
		for(int k=0;k<4;k++)
		{
			int a=(one.first)-x[k],b=(one.second.first)-y[k];
			if(a>-1 && b>-1 && a<v.size() && b<v[0].size() && v[a][b]!='#' && !vis[a][b])
			{
				
					que.push({a,{b,one.second.second+1}});
					vis[a][b]=true;
					ans=max(ans,one.second.second+1);
			}
		}
	
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int n,m,a,k;
	cin>>n>>m;
	
	vector<vector<char> > v(n,vector<char>(m));
	vector<vector<bool> > vis(n,vector<bool>(m));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			char c;
			cin>>c;
			v[i][j]=c;
			//cout << c << endl;
		}
	}

	int akp=INT_MIN;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(v[i][j]=='.'){
				akp=max(akp,bfs(i,j,v,vis));
				//cout << "done" << endl;
				for(int i=0;i<n;i++)
				{
					for(int j=0;j<m;j++)
					{
						vis[i][j]=false;
					}
				}
			}
		}
	}
	
	
	cout << akp << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int n,q;
ll S[100005];
ll t;


int main(){
  cin >> n;
  rep(i,0,n)cin >> S[i];

  sort(S,S+n);

  cin >> q;
  int c=0;
  rep(i,0,q){
    cin >> t;
    int l = 0,r=n;
    while(r-l>1){
      int m = (l+r)/2;
      if(S[m] > t) r=m;
      else l=m;
    }

    if(S[l] == t) c++;
  }

  cout << c << endl;
  return 0;
}



Measured memory_bytes: 3868
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int solve(vector<int> a){
	const int n=a.size();
	int re=0;
	rep(i,n)if(((n-1)&i)==i) re+=a[i];
	return re%2;
}

int sol(string s){
	const int n=s.size();
	int f=0;
	for(char c:s)if(c=='2') f=1;
	int re;
	if(f){
		vector<int> a(n);
		rep(i,n) a[i]=s[i]%2;
		re=solve(a);
	}else{
		vector<int> a(n);
		rep(i,n) a[i]=(s[i]=='3');
		re=solve(a);
		re*=2;
	}
	return re;
}

int bf(string s){
	vector<int> re(all(s));
	while(re.size()>1){
		vector<int> nxt(re.size()-1);
		rep(i,nxt.size()) nxt[i]=abs(re[i]-re[i+1]);
		re=nxt;
	}
	return re[0];
}

int main(){
	if(0){
		rep(_,10000){
		const int n=rand()%10+2;
		string s(n,'1');
		for(char &c:s) c+=rand()%3;
		int exp=bf(s);
		int act=sol(s);
		if(exp!=act){
			out(s,exp,act,s,1);
			return 0;
		}
		}
		return 0;
	}
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	cout<<sol(s) NL;
  return 0;
}


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

int digitsum(int a){
	int b,c,d,e,f,g;
	b = a/100000;
	c = (a-b*100000)/10000;
	d = (a-b*100000-c*10000)/1000;
	e = (a-b*100000-c*10000-d*1000)/100;
	f = (a-b*100000-c*10000-d*1000-e*100)/10;
	g = a%10;
		return b+c+d+e+f+g;
	}
	
int main(){
	int n,ans;
	cin >> n;
	int i;
	ans = 99999;
	for(i=1;i<n;i++){
		ans = min(digitsum(i)+digitsum(n-i),ans);
	}
	cout << ans << endl;
}
	
		

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    if(s=="AC")
      a++;
    else if(s=="WA")
      b++;
    else if(s=="TLE")
      c++;
    else if(s=="RE")
      d++;
  }
  cout<<"AC x "<<a<<"\n";
  cout<<"WA x "<<b<<"\n";
  cout<<"TLE x "<<c<<"\n";
  cout<<"RE x "<<d<<"\n";
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
//#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
string s, t;cin >> s >> t;
vector<int> S;
vector<int> T;
for(int i = 0; i < s.size(); i++){

if(s[i] == 'a')S.push_back(0);
if(s[i] == 'b')S.push_back(1);
if(s[i] == 'c')S.push_back(2);
if(s[i] == 'd')S.push_back(3);
if(s[i] == 'e')S.push_back(4);
if(s[i] == 'f')S.push_back(5);
if(s[i] == 'g')S.push_back(6);
if(s[i] == 'h')S.push_back(7);
if(s[i] == 'i')S.push_back(8);
if(s[i] == 'j')S.push_back(9);
if(s[i] == 'k')S.push_back(10);
if(s[i] == 'l')S.push_back(11);
if(s[i] == 'm')S.push_back(12);
if(s[i] == 'n')S.push_back(13);
if(s[i] == 'o')S.push_back(14);
if(s[i] == 'p')S.push_back(15);
if(s[i] == 'q')S.push_back(16);
if(s[i] == 'r')S.push_back(17);
if(s[i] == 's')S.push_back(18);
if(s[i] == 't')S.push_back(19);
if(s[i] == 'u')S.push_back(20);
if(s[i] == 'v')S.push_back(21);
if(s[i] == 'w')S.push_back(22);
if(s[i] == 'x')S.push_back(23);
if(s[i] == 'y')S.push_back(24);
if(s[i] == 'z')S.push_back(25);

}

for(int i = 0; i < t.size(); i++){

if(t[i] == 'a')T.push_back(0);
if(t[i] == 'b')T.push_back(1);
if(t[i] == 'c')T.push_back(2);
if(t[i] == 'd')T.push_back(3);
if(t[i] == 'e')T.push_back(4);
if(t[i] == 'f')T.push_back(5);
if(t[i] == 'g')T.push_back(6);
if(t[i] == 'h')T.push_back(7);
if(t[i] == 'i')T.push_back(8);
if(t[i] == 'j')T.push_back(9);
if(t[i] == 'k')T.push_back(10);
if(t[i] == 'l')T.push_back(11);
if(t[i] == 'm')T.push_back(12);
if(t[i] == 'n')T.push_back(13);
if(t[i] == 'o')T.push_back(14);
if(t[i] == 'p')T.push_back(15);
if(t[i] == 'q')T.push_back(16);
if(t[i] == 'r')T.push_back(17);
if(t[i] == 's')T.push_back(18);
if(t[i] == 't')T.push_back(19);
if(t[i] == 'u')T.push_back(20);
if(t[i] == 'v')T.push_back(21);
if(t[i] == 'w')T.push_back(22);
if(t[i] == 'x')T.push_back(23);
if(t[i] == 'y')T.push_back(24);
if(t[i] == 'z')T.push_back(25);

}

sort(ALL(S));sort(ALL(T));
reverse(ALL(T));

bool C = 1;
if(s.size() < t.size()){

for(int i = 0; i < s.size(); i++){
if(S[i] != T[i])C = 0;
}
if(C){cout << "Yes";exit(0);}
}

for(int i = 0; i < min(s.size(), t.size()); i++){

if(S[i] == T[i])continue;
if(S[i] > T[i])break;
if(S[i] < T[i]){cout << "Yes";exit(0);}
}

cout << "No";
}


Measured memory_bytes: 3640
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 1e15;

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

  string s, t; cin >> s >> t;
  map<int, int> mp1;
  map<int, int> mp2;
  for (char c : s) ++mp1[c - 'a'];
  for (char c : t) ++mp2[c - 'a'];
  for (int i = 0; i < 26; ++i) {
    if (mp2[i] > 0 && mp1[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  int n = s.size();

  vector<vector<int64>> dis(26, vector<int64>(n, INF));
  for (char c = 'a'; c <= 'z'; ++c) {
    int cur = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (s[i] == c) {
        if (i > 0){
          dis[c - 'a'][i - 1] = 1LL;
        } else {
          dis[c - 'a'][n - 1] = 1LL;
        }
      }
    }
    for (int i = n - 2; i >= 0; --i) {
      if (dis[c - 'a'][i + 1] != INF && dis[c - 'a'][i] != 1LL) {
        dis[c - 'a'][i] = dis[c - 'a'][i + 1] + 1LL;
      }
    }
    if (dis[c - 'a'][n - 1] == INF) {
      dis[c - 'a'][n - 1] = dis[c - 'a'][0] + 1LL;
    }
    for (int i = n - 2; i >= 0; --i) {
      if (dis[c - 'a'][i + 1] != INF && dis[c - 'a'][i] != 1LL) {
        dis[c - 'a'][i] = dis[c - 'a'][i + 1] + 1LL;
      }
    }
  }

  int m = t.size();

  auto ok = [&](int64 x) -> bool {
    int64 sum = 0;
    int64 cur = 0;
    for (int64 i = 0; i < n; ++i) {
      if (s[i] == t[0]) {
        cur = i;
        break;
      }
    }
    sum += cur + 1LL;

    for (int i = 1; i < m; ++i) {
      sum += dis[t[i] - 'a'][cur];
      cur = (cur + dis[t[i] - 'a'][cur]) % static_cast<int64>(n);
    }
    return sum <= x;
  };
  
  int64 high = INF, low = -1LL;
  while (high - low > 1LL) {
    int64 mid = (high + low) / 2;
    if (ok(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << high << endl;

  return 0;
}

Measured memory_bytes: 21712
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  x <- readLn :: IO Int
  putStrLn $ "ABC" ++ show x

Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B];

    int minA, minB;
    cin >> a[0];
    minA = a[0];
    for(int i = 1; i < A; i++){
        cin >> a[i];
        if(minA > a[i]) minA = a[i];
    }
    cin >> b[0];
    minB = b[0];
    for(int i = 1; i < B; i++){
        cin >> b[i];
        if(minB > b[i]) minB = b[i];
    }

    int dismin;
    int x[M], y[M], c[M];
    cin >> x[0] >> y[0] >> c[0];
    dismin = a[x[0]-1] + b[y[0]-1] - c[0];
    for(int i = 1; i < M; i++){
        cin >> x[i] >> y[i] >> c[i];
        int dismin1 = a[x[i]-1] + b[y[i]-1] - c[i];
        if(dismin > dismin1) dismin = dismin1;
    }



    cout << ((minA + minB) > dismin? dismin: (minA + minB)) << endl;


}

Measured memory_bytes: 2176