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



signed main(){
    string s,base="";cin>>s;
    ll ns=siz(s),nb,ans=0;
    rep(i,ns){
        if(s[i]!='x'){
            base+=s[i];
        }
    }
    
    nb=siz(base);
    for(int i=0;i < nb-1-i;i++)
    {
        if(base[i]!=base[nb-1-i]){
            cout<<-1<<endl;
            return 0;
        }
    }

    ll posf=0,posb=ns-1;

    while(posb-posf>0){
        if(s[posf]==s[posb]){
            posf++;
            posb--;
        }else{
            if(s[posf]=='x'){
                posf++;
            }else{
                posb--;
            }
            ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
def bounding(n, x, lli):

    ans = 1
    count = 0

    for i in lli:
        count += i
        if count <= x:
            ans += 1

    return ans
def main():
    n, x = map(int, input().split())
    lli = list(map(int, input().split()))
    print(bounding(n, x, lli))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
vector<int >adj[100007] ;
int dp[100007] ;
int dfs(int src){
	if(adj[src].size()==0)
		return 0 ;
	if(dp[src] != -1)
		return dp[src] ;

	for(auto i:adj[src])
			dp[src] = max(dp[src],1+dfs(i)) ;
	
	return dp[src] ;
}

int main(){
	fast ;
int n,m,x,y ;
cin >> n >> m ;
for(int i=0;i<m;i++){
	cin >> x >> y;
	adj[x].emplace_back(y) ;
}
int res = INT_MIN ;
memset(dp,-1,sizeof(dp));

for(int i=1;i<=n;i++)
	res = max(res,dfs(i) ) ;
cout << res << endl ;
}



Measured memory_bytes: 7424
#include<iostream>
#include<string>
using namespace std;
string s;
int a,b;
bool months(int x){
  if(x>=1&&x<=12) return true ; else return false;
}
int main(){
  cin>>s;
  for(int i=0;i<2;i++) a=a*10+s[i]-'0';
  for(int i=2;i<4;i++) b=b*10+s[i]-'0';
  if(months(a) &&months(b) ){
    cout<<"AMBIGUOUS";
  }else if(months(a) &&!months(b) ){
    cout<<"MMYY";
  }else if(!months(a) &&months(b) ){
    cout<<"YYMM";
  }else{
    cout<<"NA";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int i,j,x,tousa,atom,nn;
    int n,flg;
    int nae[114],cp[114];
    while(cin>>n&&n) {
		nn=n+1;
        for(i=0;i<nn;i++) cin>>nae[i];
        for(i=0;i<nn;i++) {
            atom=nae[i];    
            x=tousa=flg=0;;
            for(j=0;j<nn;j++) {
                if(i!=j){
                    cp[x]=nae[j];
                    x++;
                }
            }
            for(j=0;j<n-1;j++) {
                if(j==0) tousa=cp[j+1]-cp[j];
                else if(tousa!=cp[j+1]-cp[j]) flg=1;
            }
            if(flg==0) break;
        }
        cout<<atom<<endl;
    }
}

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

int H, W;
vector<string> s;
vector<vector<int>> seen;
queue<pair<int, int>> to_visit;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int main() {
    cin >> H >> W;
    s.resize(H);
    seen.assign(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++) {
        cin >> s.at(i);
    }
// bfs
    pair<int, int> p = make_pair(0, 0);
    to_visit.push(p);
    seen.at(0).at(0) = 0;

    while (to_visit.size() > 0) {
        p = to_visit.front();
        to_visit.pop();
        int x = p.first, y = p.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx.at(i), ny = y + dy.at(i);
            if(nx >= 0 && nx < H && ny >= 0 && ny < W && seen.at(nx).at(ny) == -1 && s.at(nx).at(ny) == '.') {
                seen.at(nx).at(ny) = seen.at(x).at(y) + 1;
                to_visit.push(make_pair(nx, ny));
            }
        }
    }

    int num_white = 0;
    for (int i = 0; i < H; i++) {
        num_white += count(s.at(i).begin(), s.at(i).end(), '.');
    }
    int num_step = seen.at(H - 1).at(W - 1);

    if (num_step == -1) {
        cout << num_step << endl;
    }
    else {
        cout << num_white - num_step - 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		
		int[] A = new int[n];
		for(int i=0;i<n;i++){
			A[i]= Integer.parseInt(sc.next());
		}
		
		for (int i=1; i<n;i++){
			for(int k=0;k<n-1;k++){
				System.out.print(A[k]+" ");
			}
			System.out.println(A[n-1]);
			
			int key = A[i];
			int j=i-1;
			while(j>=0 && A[j]>key){
				A[j+1]=A[j];
				j--;
			}
			A[j+1]=key;
		}
		
		for(int k=0;k<n-1;k++){
			System.out.print(A[k]+" ");
		}
		System.out.println(A[n-1]);


	}

}

Measured memory_bytes: 31184
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
// int H[N]; rep(i,N) scanf("%d", &H[i]);
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int N,T; cin>>N>>T;
    int c[N],t[N];
    rep(i,N) cin >> c[i] >> t[i];
    int min_c = 1010;
    rep(i,N){
        if(t[i]<=T){
            if(c[i]<=min_c) min_c = c[i];
        }
    }
    if(min_c!=1010) cout << min_c << endl;
    else cout << "TLE" << endl;
    
}



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

namespace cswork {
    class Program {
        static void Main (string[] args) {
            Q2 ();
        }

        public static void Q2 () {
            List<int> line = GetListInt (Read (), " ");
            int n = line[0];
            int k = line[1];

            bool[] array = new bool[n];
            for (int i = 0; i < k; i++) {
                int d = ReadInt ();
                List<int> list = GetListInt (Read (), " ");
                for (int j = 0; j < list.Count; j++) {
                    array[list[j] - 1] = true;
                }
            }

            int count = 0;
            for (int i = 0; i < n; i++) {
                if (!array[i]) {
                    count++;
                }
            }

            Write (count);
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string Read () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> GetList (string str, string delim) {
            return new List<string> (str.Split (delim));
        }

        public static List<int> GetListInt (string str, string delim) {
            List<string> list = new List<string> (str.Split (delim));
            return list.ConvertAll (x => int.Parse (x));
        }
    }
}

Measured memory_bytes: 27972
/*
 * atcoder/abc169/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int a, b;
void solve() {
  cin >> a >> b;
  cout << a * b << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = [int(a) for a in input().split()]
I = 0
J = 0
K = 0
for a in A:
    if a == 1:
        J += 1
        K += 1
    elif a == 2:
        K += 1

X = [[[0.0] * (j+1) for j in range(k+1)] for k in range(N+1)]

for k in range(N+1)[::-1]:
    for j in range(k+1)[::-1]:
        for i in range(j+1)[::-1]:
            if i == N:
                X[k][j][i] = 0
            else:
                X[k][j][i] = N/(N-i)
                if i < j:
                    X[k][j][i] += X[k][j][i+1] * (j-i) / (N-i)
                if j < k:
                    X[k][j][i] += X[k][j+1][i] * (k-j) / (N-i)
                if k < N:
                    X[k][j][i] += X[k+1][j][i] * (N-k) / (N-i)

print(X[K][J][I])

Measured memory_bytes: 82908
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int  n=0,m=0,c=0,d=0,i=0,j=0;
    cin >> n >> m;
    int a[100][100]={};
    int b[100]={};
    int ans[100]={};

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> c;
            a[i][j]=c;
        }
    }
    for(j=0;j<m;j++){
        cin >> d;
        b[j]=d;
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            ans[i]+=  a[i][j]* b[j];

        }
    }
    for (i=0;i<n;i++){
        cout << ans[i] << endl;
    }



    //cout << endl;

return 0;

}

Measured memory_bytes: 1208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	int n=read(),nowx=0,nowy=0,last=0;
	for(int i=1;i<=n;i++)
	{
		int t=read(),x=read(),y=read();
		int sum=abs(nowx-x)+abs(nowy-y);
		
		if(sum<=t-last&&(t-last-sum)%2==0)
		{
			nowx=x,nowy=y;
		}
		else 
		{
			puts("No");
			return 0;
		}
		last=t;
	}
	puts("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
int h,w,k;
ll dp[1000][110];
int s[] = {1,1,2,3,5,8,13,21};
 
int main(int argc, char const *argv[])
{
	cin>>h>>w>>k;
	if(w == 1)
		{
			printf("1\n");
			return 0;
		}
	dp[0][0] = 1;
	rep(i,0,h)
		rep(j,0,w)
		{
			dp[i][j] %= mod;
			if(j == 0)
			{
				dp[i+1][j+1] += dp[i][j] * s[max(0,w - j - 2)];
				dp[i+1][j] += dp[i][j] * s[w - j - 1];
			}
			else if(j != 0)
			{
				dp[i+1][j+1] += dp[i][j] * s[j] * s[max(0,w - j - 2)];
				dp[i+1][j] += dp[i][j] * s[j] * s[w - j - 1];
				dp[i+1][j-1] += dp[i][j] * s[max(0,j-1)] * s[w-j-1];
			}
		}		
	cout<<dp[h][k-1]%mod<<endl;	
	return 0;
}

Measured memory_bytes: 384
H, W = list(map(int, input().split()))
N = int(input())
A = []
a = list(map(int, input().split()))
for i in range(N):
    A += [i + 1] * a[i]

L = [[0 for i in range(W)] for j in range(H)]
for i in range(H * W):
    if int((i // W)) % 2 == 0:
        L[int((i // W))][i % W] = A[i]
    else:
        L[int((i // W))][-1 - i % W] = A[i]

for i in range(H):
    L[i] = list(map(str, L[i]))


for i in range(H):
    print(" ".join(L[i]))

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main() {
    string S;
    cin >> S;
    ll res = 0;
    ll ans = 0;
    while(res < S.size() && S[res] == '>') {
        res++;
    }
    if (res == S.size()){
        cout << ((res*(res+1))/2) << endl;
    } else {
        ll l = 0;
        ans += ((res*(res+1))/2);
        REP(i, res, S.size()){
            if (S[i] == '<') {
                ans = ans + l;
                l++;
            } else {
                ll l2 = 0;
                while(i < S.size() && S[i] == '>'){
                    l2++;
                    i++;
                }
                ans = ans + ((l2*(l2-1))/2);
                if (l2 > l){
                    ans = ans + l2;
                } else {
                    ans = ans + l;
                }
                l = 0;
                i--;
            }
//            cout << ans << endl;
        }
//        cout << ans << endl;
        if (l > 0){
            ans = ans + l;
        }
        cout << ans << endl;
    }

}

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

int main() {
int a, b, c;
  cin >> a >> b >> c;
  if(a == c && a!= b) cout << b << endl;
  else if (a == b && a!=c) cout << c << endl;
  else if(b == c && a!= c) cout << a << endl;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	int n;
	cin >> n;
	int a = 0, b = 0, c = 0, x;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x % 4 == 0) {
			b++;
		} else if (x % 2 == 0) {
			c++;
		} else {
			a++;
		}
	}
	if (a > b + 1 || (a == b + 1 && c)) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
	return 0;
}



Measured memory_bytes: 256
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        ll n,W;cin>>n>>W;
        vector<ll> dp(n*1e3+1,LLONG_MAX);//dp[i]->minimum weight to achieve value exactly i
        dp[0]=0;
        forn(j,n)
        {
            ll w,v;cin>>w>>v;
            ford(i,dp.size()-v)
            {
                if(dp[i]==LLONG_MAX)continue;
                dp[i+v]=min(dp[i+v],dp[i]+w);
            }
        }
        ll ans=0;
        forn(i,dp.size())
        {
            if(dp[i]!=LLONG_MAX&&dp[i]<=W)
            {
                ans=i;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}

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

#define FOR(i,x) for(int i=0; i<x; i++)
#define FORic(i,y,x) for(int i=y; i<=x; i++)
#define FORdc(i,y,x) for(int i=y; i>=x; i--)

vector<string> all;
int w, h, l, r;
int masu[12];
bool check[62][12];

void tadoru(int i, int j){
	if(all[i][j] == '.') return;
	if(check[i][j]) return;
	else check[i][j] = true;
	masu[j]++;
	tadoru(i-1, j);
	if(all[i][j]==all[i][j-1]) tadoru(i, j-1);
	if(all[i][j]==all[i][j+1]) tadoru(i, j+1);
	if(all[i][j]==all[i+1][j]) tadoru(i+1, j);
}

void siraberu(int i, int j){
	if(all[i][j] == '.' || all[i][j] == '#') return;
	if(check[i][j]) return;
	else check[i][j] = true;
	if(all[i+1][j] != all[i][j]){
		if(all[i+1][j] != '.'){
			l = min(l, j);
			r = max(r, j);
		}
	}
	if(all[i][j]==all[i-1][j]) siraberu(i-1, j);
	if(all[i][j]==all[i][j-1]) siraberu(i, j-1);
	if(all[i][j]==all[i][j+1]) siraberu(i, j+1);
	if(all[i][j]==all[i+1][j]) siraberu(i+1, j);
}

void init_check(){
	FOR(i2, h+2) {FOR(j2, w+2) check[i2][j2] = false;}
}

int main(){
	while(cin>>w>>h){
		if(!w&&!h) break;
		all.clear();
		string buf, tmpue, tmpsita;
		FOR(i, w+2) tmpue += '.';
		all.push_back(tmpue);
		FOR(i,h){
			cin>>buf;
			string tmp = '.' + buf + '.';
			all.push_back(tmp);
		}
		FOR(i, w+2) tmpsita += '#';
		all.push_back(tmpsita);
		bool dame = false;
		FORdc(i, h, 1){
			FORic(j, 1, w){
				if(all[i][j]!='.'){
					FOR(n,12) masu[n] = 0;
					l = 15;
					r = -1;
					init_check();
					tadoru(i, j);
					init_check();
					siraberu(i, j);
					int g=0;
					int sum=0;
					FORic(n,1,w){
						g += (2*n-1)*masu[n];
						sum += masu[n];
					}
					if(g<=(l-1)*2*sum || r*2*sum<=g){
						dame = true;
						break;
					}
				}
			}
			if(dame) break;
		}
		if(dame) cout<<"UNSTABLE"<<endl;
		else cout<<"STABLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,C,D,ans;
    bool F=true;
int main(){
    cin>>A;
    cout<<24-A+24;
    return 0;

}


Measured memory_bytes: 256
N = int(input())
A = input().split()
B = input().split()
C = input().split()

ans = 0
for i in range(N):
    ans+= int(B[i])

for i in range(N-1):
    if int(A[i])+1 ==int(A[i+1]):
        ans+=int(C[int(A[i])-1])

print(ans)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    ll k;
    cin >> k;
    if(l==1){
        cout << (ll)k/2LL << endl;
        return 0;
    }
    vint cg(l,0);
    ll cnt = 0LL;
    REP(i,l-1){
        if(cg[i]==1)continue;
        if(s[i]==s[i+1]){
            cg[i+1]=1;
            cnt++;
        }
    }
    ll ans = cnt*k;
    int f = 1;
    char now=s[0];
    for(int i=1;i<l;++i){
        if(s[i]!=now)break;
        f++;
    }
    int b=0;
    for(int i=l-1;i>=0;--i){
        if(s[i]!=now)break;
        b++;
    }
    if(f+b>=l){
        cout << (l*k)/2 << endl;;
        return 0;
    }
    if(f%2==1&&b%2==1)ans+=(k-1);
    cout << ans << 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;

int main() {
    int a,b; cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10){
            cnt++;
        }
    }
    cout << cnt;
}

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

using namespace std;

int main(){
	int S = 0;
	int W = 0;
	cin >> S;
	cin >> W;
	if(S > W){
		cout <<"safe"<< endl;
	}else{
		cout <<"unsafe"<<endl;	
	}
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

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

    int count = 0;

    rep(i,3){
        if(s[i] == t[i]) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
10000x+5000y+1000（N-x-y）==Y
x,y,z范围自己确定。越小越好。循环重数越少越好；
x：0-N
y：0-N
要判定的条件：
10000x+5000y+1000（N-x-y）==Y
N-x-y》=0
*/
int main(){
	int x,y,z,N,Y;
	cin>>N>>Y;
	int flag=0;
	for(x=0;x<=N;x++){
		for(y=0;y<=N-x;y++){
			z=N-x-y;
			if(10000*x+5000*y+1000*z==Y){
				flag=1;
				break;
			}
		}
		if(flag==1) break;
	}
	if(flag==1) cout<<x<<" "<<y<<" "<<z;
	else cout<<"-1 -1 -1";
	return 0;
}


Measured memory_bytes: 256
class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end

  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

mod = 998244353

n, m, k = gets.to_s.split.map{|e|e.to_i}

ans = 0
f = Facts.new(mod)
t = m * (m-1).pow(n-1-k, mod)

k.downto(0) do |i|
  ans += f.cmb(n-1, i) * t % mod
  ans %= mod if ans >= mod
  t = t * (m-1) % mod
end

puts ans


Measured memory_bytes: 19488
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int N, M, S;
typedef long long int ll;
int DP[2001][3001];
int MOD = 100000;
int main()
{
	while (true){
		scanf("%d%d%d", &N, &M, &S);
		if (N == 0 && M == 0 && S == 0)break;
		for (int i = 0; i <= N*N; i++)for (int j = 0; j <=S; j++)DP[i][j] = 0;
		DP[0][0] = 1;
		for (int i = 1; i <= M; i++){
			for (int j = S; j >= 0; j--){
				if (j + i <= S){
					for (int k = 1; k <= N*N; k++){
						DP[k][j + i] = (DP[k][j + i] + DP[k - 1][j]) % MOD;
					}
				}
			}
		}
		int ans = 0;
		printf("%d\n", DP[N*N][S]%MOD);
	}
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string S; cin >> S;
	string T; cin >> T;
	for (int i = 0; i < (int)S.size(); i++) {
		if (S[i] != T[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3576
h,w,n=map(int,input().split())
r,c=map(int,input().split())
s=input()
t=input()
xr=xl=xd=xu=yr=yl=yd=yu=0
for i in range(n):
    xr+=s[i]=='R'
    xl+=s[i]=='L'
    xd+=s[i]=='D'
    xu+=s[i]=='U'
    if w-c-(xr-yl)<0 or c-1-(xl-yr)<0 or h-r-(xd-yu)<0 or r-1-(xu-yd)<0:
        print('NO')
        break
    yr+=t[i]=='R'
    yr-=w-c-(yr-xl)<0
    yl+=t[i]=='L'
    yl-=c-1-(yl-xr)<0
    yd+=t[i]=='D'
    yd-=h-r-(yd-xu)<0
    yu+=t[i]=='U'
    yu-=r-1-(yu-xd)<0
else:
    print('YES')

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

int main() {
    int n,m,ans;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];
    for(int i=0; i<m; i++) cin>>c[i]>>d[i];
    
    for(int i=0; i<n; i++) {
        ll dis, tmp = 2e9;
        for(int j=0; j<m; j++) {
            dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(dis < tmp) {
                tmp = dis;
                ans = j+1;
            }
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, d, count = 0;
  cin >> a >> b >> c >> d;
  while(c > 0 && a > 0)
  {
    if(count % 2 == 0)
    {
      c -= b;
      count++;
    }
    else
    {
      a -= d;
      count++;
    }
  }
  if(a <= 0)
  {
    cout << "No\n";
  }
  else if(c <= 0)
  {
    cout << "Yes\n";
  }
  return 0;
}


Measured memory_bytes: 3636
num = [1, 1, 1, 2, 1, 2, 1, 5,
       2, 2, 1, 5, 1, 2, 1, 14,
       1, 5, 1, 5, 2, 2, 1, 15,
       2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

N = K - 1

print(num[N])

Measured memory_bytes: 2940
import Control.Applicative
import Control.Monad
main = do
  n <- (read::String->Int) <$> getLine
  v <- replicateM n (map read . words <$> getLine)
  mapM_ (putStrLn . show . aux) v

aux :: [Double] -> Int
aux [xa,ya,ra,xb,yb,rb]
  | ab > ra + rb = 0
  | ab + rb < ra = 2
  | ab + ra < rb = -2
  | otherwise = 1      
  where ab = sqrt((xb-xa)^2 + (yb-ya)^2)

Measured memory_bytes: 4348
#include <stdio.h>
 
int main(void){
	int i;
	while(1){
		int x,y;
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}
		if(x>y){
			printf("%d %d\n",y,x);
		}
		else{
			printf("%d %d\n",x,y);
		}
	}	
}

Measured memory_bytes: 1680
package main

import (
	"fmt"
)

func main() {
	var n, m, l int
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Scan(&l)

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	b := make([][]int, m)
	for i := 0; i < m; i++ {
		b[i] = make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&b[i][j])
		}
	}
	c := make([][]int, n)
	for i := 0; i < n; i++ {
		c[i] = make([]int, l)
	}

	for k := 0; k < n; k++ {
		for j := 0; j < l; j++ {
			for i := 0; i < m; i++ {
				c[k][j] += a[k][i] * b[i][j]
			}
		}
	}
	for _, v := range c {
		for j := 0; j < len(v)-1; j++ {
			fmt.Printf("%d ", v[j])
		}
		fmt.Println(v[len(v)-1])
	}
}



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

long long a[200010];

int main() {
	int n;
	cin >> n;
	long long all = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		all += a[i];
	}
	long long sunuke = 0;
	long long ans = 10000000000 * 200010;;
	for (int i = 0; i < n - 1; i++) {
		sunuke += a[i];
		ans = min(ans, abs((all - sunuke) - sunuke));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

/*
   input:
       3
       5
       11
       7
       8
       19
       0

   output:
       Case 1: 3
       Case 2: 5
       Case 3: 11
       Case 4: 7
       Case 5: 8
       Case 6: 19
*/

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int i = 1, a;
    while (true) {
      a = scan.nextInt();
      if (a == 0) break;
      System.out.printf("Case %d: %d\n", i++, a);
    }
  }
}


Measured memory_bytes: 65924
from bisect import bisect
def grade(rate,breakpoints=[400,800,1200,1600,2000,2400,2800,3200],grades=["gray","brown","green","light blue","blue","yellow","orange","red","anything"]):
    i = bisect(breakpoints,rate)
    return grades[i]

n = int(input())
a = [int(i) for i in input().split()]
colors = [grade(r) for r in a]
anything_count = colors.count("anything")
ans = len(set(colors))
print(*(ans,ans) if anything_count == 0 else (ans-1+(1 if ans == 1 else 0),ans-1+anything_count))

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

double UW,UH,A,B,AB;
double radius(double S){
    return sqrt(S/M_PI);
}

double distance(){
    double rA=radius(A), rB=radius(B);
    double lb=0, ub=rA+rB, d;
    for(int i=0;i<50;i++){
        d = (lb+ub)/2;
        double thetaA = acos((d*d+rA*rA-rB*rB)/(2*rA*d));
        double thetaB = acos((d*d+rB*rB-rA*rA)/(2*rB*d));
        double S = A*thetaA/M_PI + B*thetaB/M_PI - d*rA*sin(thetaA);
        if(S<AB){
            ub = d;
        }else{
            lb = d;
        }
    }
    return d;
}

int main(){
    while(cin>>UW>>UH>>A>>B>>AB,UW){
        double RA=radius(A),RB=radius(B), d=distance();
        double D = hypot(UW-RA-RB,UH-RA-RB);
        if(AB==0) d=RA+RB+0.001;
        if(D<d||UW-RA-RB<0||UH-RA-RB<0||min(UW,UH)<2*max(RA,RB)){
            cout<<"impossible"<<endl;
        }else{
            double XA,YA,XB,YB;
            if(RA>RB){
                XA=YA=RA+0.001;
                XB=XA+(UW-RA-RB)*(d/D);
                YB=YA+(UH-RA-RB)*(d/D);
            }else{
                XB=YB=RB+0.001;
                XA=XB+(UW-RA-RB)*(d/D);
                YA=YB+(UH-RA-RB)*(d/D);
            }
            // cout<<d<<' '<<M_PI*RA*RA<<' '<<M_PI*RB*RB<<endl;
            cout<<fixed;
            cout.precision(9);
            cout<<XA<<' '<<YA<<' '<<RA<<' '<<XB<<' '<<YB<<' '<<RB<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3508
#include <ctype.h>
#include <stdio.h>
#include <string.h>

char
toswap(char c)
{
	if (islower(c)) return toupper(c);
	if (isupper(c)) return tolower(c);
	return c;
}

int
main()
{
	char s[1200];
	fgets(s, sizeof(s), stdin);

	int s_i;
	int s_len = strlen(s);
	for (s_i = 0; s_i < s_len; s_i++)
	{
		char c = toswap(s[s_i]);
		putchar(c);
	}
}

Measured memory_bytes: 920
#include <stdio.h>

int main()
{
    int card[205];
    int work[205];

    int n;
    int m;
    int k;

    scanf("%d", &n);
    scanf("%d", &m);
    for (int i = 0; i < 2 * n; i++) {
        card[i] = i + 1;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &k);

        if (k == 0) {
            int idx = 0;
            for (int j = 0; j < n; j = j + 1) {
                work[idx] = card[j];
                work[idx + 1] = card[j + n];

                idx = idx + 2;
            }
        } else {
            int idx = 0;
            for (int j = k; j < 2 * n; j = j + 1) {
                work[idx] = card[j];
                idx++;
            }
            for (int j = 0; j < k; j++) {
                work[idx] = card[j];
                idx++;
            }
        }

        for (int j = 0; j < 2 * n; j++) {
            card[j] = work[j];
        }
    }

    for (int i = 0; i < 2 * n; i++) {
        printf("%d\n", card[i]);
    }

    return 0;
}



Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
 
int main(){
	int n;
	cin>>n;
	map<int,int> d;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		d[a]++;
	}
	
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int b;
		cin>>b;
		d[b]--;
		if(d[b]<0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	cout<<"YES"<<endl;
	
	
	return 0;
}

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

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

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

#define INF 1e9

int main(int, char**)
{
  int n;
  string s;
  cin >> n >> s;

  int l = 0, r = s.size()-1;
  int ans = 0;

  while(true) {
    while (s[l]=='R') l++;
    while (s[r]=='W') r--;
    if (l >= r) break;
    swap(s[l],s[r]);
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

// a^n mod を計算する
//ただしmとaが互いにその時のみ
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
ll N;
cin >> N;
ll P;
cin >> P;
string S;
cin >> S;
ll ans=0;
if(P!=2&&P!=5){
vector<ll> counter(P,0);
vector<ll> ikop(N,0);
counter[0]=1;
ll k=S[N-1]-'0';
ikop[N-1]=k%P;
counter[k%P]++;
ans+=counter[0]-1;
for(ll i=N-2;i>=0;i--){
  ll k=S[i]-'0';
  ikop[i]=(ikop[i+1]+k*modpow(10,N-i-1,P))%P;
  counter[ikop[i]]++;
  ans+=counter[ikop[i]]-1;
;}
}
else if(P==2){
  for(ll i=0;i<N;i++){
    ll k=S[i]-'0';
    if(k%2==0){ans+=i+1;}
  ;}
}
else if(P==5){
  for(ll i=0;i<N;i++){
    ll k=S[i]-'0';
    if(k%5==0){ans+=i+1;}
  ;}
}
cout<<ans<<endl;

return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N), count(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    while (vec.at(i) % 2 == 0) {
      vec.at(i) /= 2;
      count.at(i)++;
    }
  }
  
  sort(count.begin(), count.end());
  cout << count.at(0);
}


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

const long long int MAX_=1000000;
vector<long long int> prime;
bool is_prime[MAX_];

void sieve(){
	fill(is_prime,is_prime+MAX_,true);
	is_prime[0]=is_prime[1]=false;
	for(long long int i=2; i<MAX_; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(long long int j=i*2; j<MAX_; j+=i){
				is_prime[j]=false;
			}
		}
	}
}

long long int gcd(long long int a,long long int b){
	while(b!=0){
		long long int tmp=a%b;
		a=b;
		b=tmp;
	}
	return a;
}

vector<long long int>* divisor(long long int x){
	static vector<long long int> result;
	result.clear();
	for(long long int i=1; i*i<=x; ++i){
		if(x%i==0){
			result.push_back(i);
			long long int tmp=x/i;
			if(i!=tmp) result.push_back(tmp);
		}
	}
	sort(result.begin(),result.end());
	return &result;
}

map<long long int,long long int>* prime_factor(long long int n){
	static map<long long int,long long int> result;
	result.clear();
	for(auto it=prime.begin(); (*it)*(*it)<=n&&it!=prime.end(); ++it){
		while(n%(*it)==0){
			++result[(*it)];
			n/=(*it);
		}
	}
	if(n!=1) result[n]=1;
	return &result;
}

int solve(long long int l){
	int ans=0;
	vector<long long int> v=(*divisor(l));
	map<long long int,long long int> table=(*prime_factor(l));
	for(auto it=v.begin(); it!=v.end(); ++it){
		/*
		for(auto it_=v.begin(); (*it_)<=(*it)&&it_!=v.end(); ++it_){
			if((*it)*(*it_)/gcd((*it),(*it_))==l) ++ans;
		}
		*/
		map<long long int,long long int> table_=(*prime_factor(*it));
		long long int tmp=1;
		for(auto it_=table.begin(); it_!=table.end(); ++it_){
			if(table_[it_->first]==it_->second) tmp*=it_->second+1;
			//cout << it_->second << endl;
		}
		//cout << tmp << endl;
		ans+=tmp;
	}
	ans=(ans+1)/2;
	return ans;
}

int main(){
	sieve();
	long long int L;
	while(cin >> L&&L){
		cout << solve(L) << endl;
	}
	return 0;
}

Measured memory_bytes: 2964
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	int N;
	int a[2000];
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int amin = 99999;
	int amax = -1;
	for (i = 0; i < N; ++i) {
		if (amin > a[i]) {
			amin = a[i];
		}
		if (amax < a[i]) {
			amax = a[i];
		}
	}
	cout << amax - amin << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

s = deque(lc())
lens = len(s)

ok = True
ans = 0

while len(s):
    if len(s) == 1:
        s.pop()
    
    elif s[0] == s[-1]:
        s.pop()
        s.popleft()
        
    else:
        if s[0] == "x":
            s.append("x")
            ans += 1
        elif s[-1] == "x":
            s.appendleft("x")
            ans += 1
        else:
            ok = False
            break
    
if ok:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 4916
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	s := make([]int, 64)
	f := 1

	if n<0 {
		f = 0
		n = -n
	}

	for i := 0; i < 64; i++ {
		s[i] = n%2
		n/=2
		if n == 0 {
			break
		}
	}

	p := 0

	for i := 0; i < 63; i++ {
		s[i+1] += s[i]/2
		s[i] %= 2

		if i%2 == f && s[i] == 1 {
			s[i+1]++
		}

		if s[i+1] == 1 {
			p = i+1
		}
	}

	for i := p; i >= 0; i-- {
		fmt.Fprint(wr, s[i])
	}
	fmt.Fprintln(wr)
	wr.Flush()

}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;
  rep(i, n) { cout << s.substr(i, 1) << t.substr(i, 1); }
  cout << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

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


    int m;
    cin >> m;
    vector<ll> b(m);
    rep(i, m) cin >> b[i];

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

    vector<ll> results;
    set_union(a.begin(), a.end(), b.begin(), b.end(), inserter(results, end(results)));

    for(ll i : results) {
        cout << i << endl;
    }

}



Measured memory_bytes: 10192
#include<stdio.h>
#define MAX 300

int main(){

    int A[MAX];
    int i,h,k,pk,lk,rk;

    scanf("%d",&h);
    for(i=1;i<=h;i++){
        scanf("%d",&A[i]);
    }

    for(i=1;i<=h;i++){
        k=A[i];
        pk=A[i/2];
        lk=A[i*2];
        rk=A[i*2+1];
        if(i>1) printf("\n");
        printf("node %d: key = %d, ",i,A[i]);
        if(i/2 > 0){
        printf("parent key = %d, ",pk);
        }
        if(h >= i*2){
            printf("left key = %d, ",lk);
        }
        if(h >= i*2+1){
            printf("right key = %d, ",rk);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    ans = 0
    for i, ai in enumerate(a):
        if (i%2 == 0) and (ai % 2 ==1): ans+=1
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

int main(){
  ll N, K;
  cin >> N >> K;

  vector<ll> h(N);
  for(ll i = 0; i < N; i++){
    cin >> h[i];
  }

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

  ll ans = 1000000000;
  for(ll i = K-1; i < N; i++){
    ans = min(ans, h[i]-h[i-K+1]);
  }
  
  cout << ans << endl;
  
  return 0;

}

Measured memory_bytes: 1024
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val N = nextInt()
    val A = nextIntList()
    val B = A.mapIndexed { i, a -> Array(a) { "${i + 1}" }.join(" ") }.join(" ").split(" ").chunked(W)
    for (h in 0 until H) {
        println(if (h % 2 == 0) B[h].join(" ") else B[h].reversed().join(" "))
    }
}

fun <T> List<T>.chunked(size: Int) = windowed(size, size) { it }

fun <T, R> List<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): List<R> {
    return (0..this.size - size step step).map { i ->
        transform(this.slice(i until i + size))
    }
}

Measured memory_bytes: 41544
#include<stdio.h>
#define ll long long
int flag[200005],town[200005];
int main()
{
    ll N,K;ll i;
    scanf("%lld%lld",&N,&K);

    for(i=1;i<=N;i++)
        scanf("%d",&town[i]);
    /***********************************************寻找第一个重复出现的镇************************************************/
    flag[1]=1;ll now=1;
    for(i=1;i<=K;i++)
    {
        if(flag[town[now]]==1)    //到达第一个重复的镇，走了i步；
            break;
        flag[town[now]]=1;         //将经历i步首次到达的镇标1 ；
        now=town[now];
    }
    ll SpTown=town[now];           //记录此镇编号，注意now指代其上一个镇；
    ll pre_sum=i;    // 记录已完成第一次循环加开头的步数；
    /***********************************************计算第一次走到该特殊镇的步数及环步数************************************************/
    i=0;now=1;
    while(now!=SpTown)
    {
        now=town[now];
        i++;
    }
    ll pre=i;ll y;//y指代一次循环的步数；
    y=pre_sum-pre;
/***********************************************分情况计算结果************************************************/
    now=1;
    if(K<=pre)       //所走K步未达到第一次环；
         while(K--)
            now=town[now];
    else             //至少进入第一个环；
    {
        K-=pre;
        K%=y;
        now=SpTown;
        while(K--)
            now=town[now];
    }
/***********************************************输出结果************************************************/

    printf("%lld",now);
    return 0;
}


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

int main(){
	int D, N;
	cin >> D >> N;

	if(D==0){
		if(N==100){
			cout << "101" << endl;
		}
		else{
			cout << N << endl;
		}
	}
	else if (D==1) {
		if(N==100){
			cout << "10100" << endl;
		}
		else{
			cout << 100*N << endl;
		}
	}
	else if (D==2) {
		if(N==100){
			cout << "1010000" << endl;
		}
		else{
			cout << 10000*N << endl;
		}
	}
}


Measured memory_bytes: 256
import math

l = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

k1 = 0
for i in range(1,l):
  n = 1
  for m in a[:i]:
    if m < a[i-1]:
      n = n+1
  k1 = k1 + (a[i-1]-n)*(math.factorial(l-i))

k2 = 0
for i in range(1,l):
  n = 1
  for m in b[:i]:
    if m < b[i-1]:
      n = n+1
  k2 = k2 + (b[i-1]-n)*(math.factorial(l-i))

    
print(abs(k1 - k2))

Measured memory_bytes: 3064