akhauriyash/Code-Regression huggingface dataset:
//author : Yogi79
#include<bits/stdc++.h>
using namespace std;

#define ll long long

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

    int n,m;
    cin>>n>>m;
    if(n==m)
    	puts("Yes");
    else
    	puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n,t;
  cin >> n >> t;
  vector<ll> a(n,0);

  rep(i,n) {
    cin >> a[i];
  }

  vector<ll> ans;
  ll mmax = -1, mmin = a[0];
  for (int i = 1; i < n; ++i) {
    ll tmp = a[i], dif;
    if (tmp > mmin) {
      dif = tmp - mmin;
      if (dif >= mmax) {
	ans.pb(dif);
	mmax = dif;
      } 
    } else {
      mmin = min(tmp, mmin);
    }
  }

  sorti(ans);
  
  ll res = 0;
  if (ans.size() <= 1) {
    res = (ans.empty()) ? 0 : 1;
  } else {
    ll b = ans.back();
    for (auto itr : ans) {
      if (itr == b) {
	res += 1;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    string s;
    while(cin>>s){
        ll ans=0;
        for(int i=0; i<3; ++i){
        	cout<<s[i];
        }
        cout<<endl;
    }
  return 0;
}




Measured memory_bytes: 3632
N, M = map(int, input().split())
newcount = [float('inf') for _ in range(2**N)]
newcount[0] = 0

for k in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  bit = 0
  for k in range(b):
    bit += 2**(c[k]-1)
  count = tuple(newcount)
  for k in range(2**N):
    now = bit|k
    newcount[now] = min(newcount[now], a+count[k])
count = newcount
if count[-1] < 10**6:
  print(count[-1])
else:
  print(-1)



Measured memory_bytes: 77048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            long[][] x = new long[10][10];

            for (int i = 1; i <= N; i++) {
                String s = String.valueOf(i);
                Integer a = Integer.valueOf(s.substring(0, 1));
                Integer b = Integer.valueOf(s.substring(s.length() - 1, s.length()));
                x[a][b]++;
            }

            long ans = 0;

            for (int a = 1; a <= 9; a++) {
                for (int b = 1; b <= 9; b++) {
                    ans += x[a][b] * x[b][a];
                }
            }

            System.out.println(ans);
        }
    }

}


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

int main()
{
    int N;
    int A[100010];
    int Order[100010];

    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];

    for(int i=0;i<N;i++){
        Order[A[i]-1] = i+1;
    }
    for(int i=0;i<N;i++){
        cout<<Order[i]<<" ";
    }
    cout<<endl;
}

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

using namespace std;

typedef long long ll;
const ll maxn=110;
struct node{
	ll x;
	ll y;
	double angle;
	friend bool operator<(node a,node b){
		return a.angle<b.angle;
	}
}point[maxn];
//struct node{
//	ll x;
//	ll y;
//	double angle;
//}point[maxn];
bool cmp(node a,node b){
	return a.angle<b.angle;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>point[i].x>>point[i].y;
		point[i].angle=atan2(point[i].y,point[i].x);
	}
	sort(point,point+n);
	ll ans=0;
	for(int i=0;i<n;i++){
		ll dx=point[i].x,dy=point[i].y;
		ans=max(ans,dx*dx+dy*dy);
		for(int j=(i+1)%n;j!=i;j=(j+1)%n){
			dx+=point[j].x;dy+=point[j].y;
			ans=max(ans,dx*dx+dy*dy);
		}
	}
	double res=sqrt(ans);
//	cout<<<<endl;
	printf("%.14f\n",res);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0] * M
X = [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())

for i in range(M):
    ans = 0
    ans += sum(T[:P[i] - 1])
    ans += X[i]
    ans += sum(T[P[i]:])
    print(ans)


Measured memory_bytes: 9112
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination(int, int);
};
int Combination::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination::Combination(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

void A_Round_One(void) {

	int A, B;
	cin >> A >> B;

	if		(A != 1 && B != 1)	cout << 1 << flush;
	else if (A != 2 && B != 2)	cout << 2 << flush;
	else						cout << 3 << flush;
}

void B_Strings_with_the_Same_Length(void) {

	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;

	for (int loop = 0; loop < N; loop++) cout << S[loop] << T[loop] << flush;
	return;
}

void C_Snack(void) {

	int A, B;
	cin >> A >> B;

	if (A == 1 || B == 1) {
		cout << A * B << flush;
	}
	else {
		map<int, int> Afact;
		for (int loop = 2; loop * loop <= A; loop++) {
			if (A % loop == 0) {
				A /= loop;
				Afact[loop]++;
				loop--;
				if (A == 1) break;
			}
		}
		if (A > 1) Afact[A]++;
		map<int, int> Bfact;
		for (int loop = 2; loop * loop <= B; loop++) {
			if (B % loop == 0) {
				B /= loop;
				Bfact[loop]++;
				loop--;
				if (B == 1) break;
			}
		}
		if (B > 1) Bfact[B]++;

		map<int, int> LCMfact;
		for (auto it = Afact.begin(); it != Afact.end(); it++) LCMfact[it->first] = it->second;
		for (auto it = Bfact.begin(); it != Bfact.end(); it++) LCMfact[it->first] = max(LCMfact[it->first], it->second);
		
		long long LCM = 1;
		for (auto it = LCMfact.begin(); it != LCMfact.end(); it++) LCM *= (long long)pow(it->first, it->second);
		
		cout << LCM << flush;
	}

	return;
}

void D_Brick_Break(void) {

	int N;
	cin >> N;
	vector<int> A(N);
	for (int& it : A) cin >> it;

	int flag = 0;
	int counter = 0;
	for (int loop = 1; flag < N; loop++) {
		if (A[flag] != loop) {
			loop--;
			counter++;
		}
		flag++;
	}
	cout << ((counter == N) ? -1 : counter) << flush;
	return;
}

int main(void) {

	//A_Round_One();
	//B_Strings_with_the_Same_Length();
	C_Snack();
	//D_Brick_Break();
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int x,y=0,z,a,b,sum = 0;
	scanf("%d",&x);
	for(a=1;a<=x;a+=2)
	{
		sum = 0;
		for(b=1;b<=a;b++)
		{
			if (a%b==0) sum ++;
		}
		if (sum == 8) y++;
	}
	printf("%d",y);
	return 0;
}

Measured memory_bytes: 128
n, m = [int(i) for i in input().split(" ")]
ps = []
pc = [0 for i in range(0, n + 1)]

for i in range(0, m):
    ps.append([i] + [int(i) for i in input().split(" ")] + [""])

ps = sorted(ps, key=lambda x: x[2])

for i in range(0, m):
    pc[ps[i][1]] += 1
    ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)

ps = sorted(ps, key=lambda x: x[0])

for i in range(0, m):
    print(ps[i][3])

Measured memory_bytes: 33800
I = list(map(int, input().split()))
N, Y = I[0], I[1]

x, y, z = -1, -1, -1
for a in range(N+1):
  for b in range(N-a+1):
    c = N - a - b
    X = 10000*a + 5000*b + 1000*c
    if X == Y:
      x, y, z = a, b, c
      break
print(x, y, z)

Measured memory_bytes: 3188
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  char s[H][W];
  rep(i,0,H-1) {
    rep(j,0,W-1) cin >> s[i][j];
  }

  rep(i,0,W+1) cout << '#';
  cout << endl;

  rep(i,0,H-1) {
    cout << '#';
    rep(j,0,W-1) cout << s[i][j];
    cout << '#' << endl;
  }

  rep(i,0,W+1) cout << '#';
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = (a); (i) < (b); (++(i)))
#define rep(i, n)     repd(i, (0), (n))
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

u64 f(vector<u64> l) {
  u64 ret = 1;
  u64 n = l.size();
  
  if(n == 0) {
    cerr << "はあ？？？？？？" << endl;
    return 0xFFFFFFFFFFFFFFFF;
  }
  
  if(n == 1) {
    return l.at(0);
  }
  
  vector<u64> tmp_l;
  rep(i, n) {
    l.at(i) -= 1;
    if(l.at(i) != 0) {
      tmp_l.push_back(l.at(i));
    } else {
      if(tmp_l.empty() == false) {
        ret += f(tmp_l);
        tmp_l.clear();
      }
    }
  }
  
  if(tmp_l.empty() == false) {
    ret += f(tmp_l);
    tmp_l.clear();
  }
  
  return ret;
}

int main(int argc, const char* argv[]) {
  u64 n;
  cin >> n;
  
  vector<u64> h;
  u64 ret = 0;
  rep(i, n) {
    u64 tmp;
    cin >> tmp;
    
    debug(tmp);
    
    if(tmp != 0) {
      h.push_back(tmp);
    } else {
      if(h.empty() == false) {
        ret += f(h);
        h.clear();
      }
    }
  }
  
  if(h.empty() == false) {
    ret += f(h);
    h.clear();
  }
  
  cout << ret << endl;
  
  return 0;
}


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

int main(){
    int n; cin>>n;
    char s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }

    int sum=0;

    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') sum++;
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   cin >> n;
   cout << n*n*n << endl;
   return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;

    vector<int> vw(N), ve(N);
    int cw, ce;
    cw = ce = 0;
    for(int i=0; i<N; i++){
        if(S[i] == 'W'){
            cw++;
        }
        else if(S[i] == 'E'){
            ce++;
        }
        vw[i] = cw;
        ve[i] = ce;
    }

    int imin = 0;
    int nmin = ve[N-1] - ve[0];
    for(int i=1; i<N; i++){
        int n = ve[N-1] - ve[i] + vw[i-1];
        if(n < nmin){
            imin = i;
            nmin = n;
        }
    }

    cout << nmin << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define maxn 200005
LL s[maxn],ans;
map<int,int>mp;
int main(){
	int n,x,k;scanf("%d%d",&n,&k);
	mp[0]++;
	for(int i=1;i<=n;i++){
		scanf("%d",&x),s[i]=s[i-1]+x;
		if(i>=k)mp[(s[i-k]-i+k)%k]--;
		ans+=mp[(s[i]-i)%k]++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <ctype.h>

#define LENGTH 1000000

int countDigit(char *s){
  int i;
  for(i=0;isdigit(s[i]);i++);
  return i;
}

int main()
{
  int n;
  int i;
  int j;
  int k;
  int l;
  int cnt;
  int tmp;
  
    char x[1000000]={0};
      char y[1000000]={0};
 
    while(scanf("%d",&n),n)
      {
        cnt=0;
        scanf("%s",x);
	
        while(n--)

	  {
            cnt=0;
            for(k=0;x[k]!='\0';k++)
	      {
		
                for(l=1;x[k]==x[k+l-1];l++);
                tmp=l-1;
                l--;
		
                if(l>99)
		  {
                    y[cnt++]=l/100+'0';
                    l%=100;
                    y[cnt++]=l/10+'0';
                    l%=10;
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
	
		else if(l<=9)

		  {
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
			else 

		  {
                    y[cnt++]=l/10+'0';
                    l%=10;
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
                k=k+tmp-1;
            }
            for(k=0;k<1000000;k++)

	      {
                x[k]=y[k];
                y[k]=0;
            }
        }
    printf("%s\n",x);
    }
    return 0;
}



Measured memory_bytes: 3584
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin >> a >> b;
    int ans;
    if(b%a==0)ans=a+b;
    else ans=b-a;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<deque>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n >= 64)cout << 64 << endl;
    else if(n >= 32) cout << 32 << endl;
    else if(n >= 16) cout <<16 << endl;
    else if(n >=  8) cout << 8 <<endl;
    else if (n >= 4) cout <<4 << endl;
    else if(n>=2) cout << 2 <<endl;
    else cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int N = 200000;

int n, m; ll x, _max[N];
int no_limit, unsure, limited;
bool visited[N];

inline void ck_max( ll &a, ll b ) { if( a < b ) a = b; }  

struct kruskal_edge {
	int u, v, w;
	
	bool operator < ( const kruskal_edge &rhs ) const {
		return w < rhs.w;
	}
} e[N];

int fa[N]; ll poi[N];

inline void make_set( int s ) { for( int i = 1; i <= s; i ++ ) fa[i] = i; }

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

inline void union_set( int x, int y )
{
	x = find( x );
	y = find( y );
	fa[x] = y;
}

inline void init_poi( int size )
{
	poi[0] = 1; 
	for( int i = 1; i <= size; i ++ )	
		poi[i] = ( poi[i-1] << 1 ) %MOD;
}

inline ll calc()
{
	int now = 2; ll ret = 0;
	for( int i = 1; i <= m; i ++ )
	{
		int u = e[i].u, v = e[i].v;
		if( find(u) == find(v) ) 
			continue;
			
		union_set( u, v );
		ret += e[i].w; now ++;
		if( now >= n ) break;
	}
	return ret;
}

int main()
{	
	scanf( "%d%d%lld", &n, &m, &x );

	init_poi( m );
	memset( _max, 0, sizeof( _max ) );
	
	for( int i = 1; i <= m; i ++ )
		scanf( "%d%d%d", &e[i].u, &e[i].v, &e[i].w );
	
	sort( e+1, e+1+m );
	
	make_set( n );
	int now = 1, p = 1; ll w = 0;
	while( now < n )
	{
		assert( p <= m );
		int u = e[p].u, v = e[p].v;
		if( find( u ) == find( v ) ) {
			p ++; continue;			
		}
	
		visited[p] = true;
		union_set( u, v );  
		ck_max( _max[u], e[p].w );
		ck_max( _max[v], e[p].w );
		w += e[p].w; now ++; p ++; 
	}
		
	if( w > x ) {
		puts( "0" ); return 0;
	}
	
//	printf( "w:%d\n", w );
	
	if( w < x )
		limited = n-1, no_limit = unsure = 0;
	if( w == x ) 	
		unsure = n-1, no_limit = limited = 0;
	
	for( int i = 1; i <= m; i ++ )
	{
		if( visited[i] ) 
			continue;
		
		make_set( n );
		fa[e[i].u] = e[i].v;
		ll tmp = calc() + e[i].w;
		
		if( tmp > x ) no_limit ++;
		if( tmp == x ) unsure ++;
		if( tmp < x ) limited ++;
	}
	
//	printf( "unsure:%d\nnolimit:%d\nlimited:%d\n", unsure, no_limit, limited ); 
	
	ll ans;
	if( w == x )
	{
		ans = poi[unsure] - 2;
		ans = ans * poi[no_limit] %MOD;
	}
	else 
	{
		ans = poi[unsure] -1;
		ans = ans * poi[no_limit] %MOD;
		ans = ( ans << 1 ) %MOD; 
	}
	
	printf( "%lld\n", ans );
	
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {
    int n;
    cin >> n;
    ll ans=1;
    rep(i,n){
        ll a;
        cin >> a;
        if(!a){
            cout << 0;
            return 0;
        }
        if(GetDigit(ans)+GetDigit(a)>19 && ans*a!=1000000000000000000)ans=0;
        else ans*=a;
    }
    if(!ans)ans--;
  	if(ans>1000000000000000000)ans=-1;
    cout << ans;
}



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

int main(){
    int N,ans;
    cin>>N;
    
    if(N%1000==0){
    cout<<0<<endl;
    }else{
    ans=1000-(N%1000);
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
//============================================================================
// Name        : c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int maxa=0;
	int seconda=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		maxa=max(maxa,a[i]);
	}
	int count=0;
	for(int i=0;i<n;i++){
		if(maxa==a[i]){
			count++;
		}else{
			seconda=max(seconda,a[i]);
		}

	}
	for(int i=0;i<n;i++){
		if(count==1){
			if(maxa==a[i]){
				cout<<seconda<<endl;
				continue;
			}
		}
		cout<<maxa<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
def merge(A, left, mid, right):

    n1 = mid-left
    n2 = right-mid
    #L = [0 for i in range(n1+1)]
    #R = [0 for i in range(n2+1)]
    #for i in range(n1):
    #    L[i] = A[left+i]
    #for i in range(n2):
    #    R[i] = A[mid+i]
    L = A[left:mid]
    l = len(L)
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0
    j = 0
    global cnt

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        
        else:
            A[k] = R[j]
            j = j+1
            cnt += l-i

def mergeSort(A, left, right):
    if left+1 < right:
         mid = (left+right) // 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)
    else:
        return 0

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
#print(*A)
print(str(cnt))

Measured memory_bytes: 30508
#include<stdio.h>
#include<string.h>
int main(void){

	char a[100];
	int i, n, k;

	scanf("%s",a);
	n = strlen(a);

	for(i=0; i<n-1-i; i++){
		if(a[i] != a[n-1-i]){
			puts("No");
			return 0;
		}
	}

	n = (n-1)/2;

	for(i=0; i<n-1-i; i++){
		if(a[i] != a[n-1-i]){
			puts("No");
			return 0;
		}
	}

	puts("Yes");
	return 0;
}


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

int top, S[1000];
int MAX = 1000;

void initialize() {
    top = 0;
}

int isEmpty() {
    return top == 0;
}

int isFull() {
    return top >= MAX - 1;
}

void push(int x) {
    S[top++] = x;
}

int pop() {
    return S[--top];
}

int main(void){
    // Your code here!
    int a, b = 0;
    char s[1000];
    initialize();
    
    while( scanf("%s", s) != EOF) {
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if(s[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else{
            push(atoi(&s[0]));
        }
    }
    
    printf("%d\n", pop());
}



Measured memory_bytes: 2128
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto nm = readln.chomp.split.map!(to!int);
  int n = nm.front;
  int m = nm.back;
  writeln = m * 1900 * (1 << m) + (n - m) * 100 * (1 << m);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 200001
int32_t main() {
	fast;
	char c; cin >> c;
	if (c >= 'A' and c <= 'Z') {
		cout << "A";
	}
	else {
		cout << "a";
	}









}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF ((ll)1e18)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, s, e) for (ll i = s, i##_len = (e); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

ll n, a, b, c, ans = INF;
vector<ll> l;

void dfs(vector<ll> &ls) {
  // lを0~4に分類するための数列を生成し、処理する

  if (ls.size() == n) {
    //処理
    vector<bool> f(3, false);
    REP(i, n) { f[ls[i]] = true; }
    if (!(f[0] && f[1] && f[2])) return;

    ll mp = ((ls.size() - count(ALL(ls), 3)) - 3) * 10;
    vector<ll> itg_l(3, 0);
    REP(i, 3) {
      REP(j, n) {
        if (ls[j] == i) itg_l[i] += l[j];
      }
    }

    vector<ll> t1 = {0, 1, 2};
    ll t2 = INF;
    do {
      t2 = min(
          abs(itg_l[t1[0]] - a) + abs(itg_l[t1[1]] - b) + abs(itg_l[t1[2]] - c),
          t2);
    } while (next_permutation(ALL(t1)));
    mp += t2;
    ans = min(ans, mp);
    return;
  }
  //数列生成
  for (ll i = 0; i < 4; i++) {
    ls.push_back(i);
    dfs(ls);
    ls.pop_back();
  }
}

int main() {
  cin >> n >> a >> b >> c;

  REP(i, n) {
    ll tmp;
    cin >> tmp;
    l.push_back(tmp);
  }
  vector<ll> ls;
  dfs(ls);
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int h,w;
    cin>>h>>w;
    char arr[h][w];
    for(int x=0; x<h; x++){
        for(int y=0; y<w; y++){
            cin>>arr[x][y];
        }
    }
    for(int x=0; x<w+2; x++){
        cout<<"#";
    }
    cout<<endl;
    for(int x=0;x<h; x++){
        cout<<"#";
        for(int y=0; y<w; y++){
            cout<<arr[x][y];
        }
        cout<<"#\n";
    }
    for(int x=0; x<w+2; x++){
        cout<<"#";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
class DisjointSet
  attr_reader :parent, :rank

  def initialize(ids = [])
    @parent, @rank = {}, {}
    ids.each do |id|
      @parent[id] = id
      @rank[id] = 0
    end
  end

  def make_set(x)
    @parent[x] = x
    @rank[x] = 0
  end

  def find(x)
    return x if (@parent[x] == x)
    @parent[x] = find(@parent[x])
    @parent[x]
  end

  def union(x, y)
    x, y = find(x), find(y)
    rank_x, rank_y = @rank[x], @rank[y]

    return if (x == y)

    if (rank_x > rank_y)
      @parent[y] = x
    elsif (rank_x < rank_y)
      @parent[x] = y
    else
      @parent[y] = x
      @rank[x] += 1
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

d = DisjointSet.new

n, g = gets.chop.split.map(&:to_i)

n.times do |i|
  d.make_set i
end

g.times do
  com, x, y = *gets.chop.split.map(&:to_i)
  case com
  when 0
    d.union x, y
  when 1
    puts (d.same?(x, y)) ? 1 : 0
  end
end

Measured memory_bytes: 7404
module Main where

import Control.Applicative
import Control.Monad
import Data.Char

c1 xs = head xs == 'A'

c2 xs = let ys = init $ drop 2 xs
        in filter (== 'C') ys == ['C']

c3 xs = all (isLower) $ filter (`notElem` "AC") xs

main :: IO ()
main = do
    ss <- getLine
    if and [c1 ss, c2 ss, c3 ss]
        then putStrLn "AC"
        else putStrLn "WA"

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, m;
llint cnt[505];
llint dp[505][505][505];

const int FACT_MAX = 1005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n >> m;
	llint l;
	for(int i = 1; i <= n; i++){
		cin >> l;
		cnt[l]++;
	}
	
	make_fact();
	
	dp[m+1][0][0] = 1;
	for(int i = m+1; i >= 2; i--){
		for(int j = 0; j <= m; j++){
			for(int k = 0; k <= m; k++){
				if(dp[i][j][k] == 0) continue;
				for(int x = 0; ; x++){
					llint nj = j+x, nk = k+x*(i-1);
					if(m-nk < nj-1) break;
					if(nk-nj*(i-2) < 0) continue;
					dp[i-1][nj][nk] += dp[i][j][k] * modpow(nk-nj*(i-2), cnt[i-1]) % mod * fact_inv[x] % mod;
					dp[i-1][nj][nk] %= mod;
				}
			}
		}
	}
	
	llint ans = 0;
	for(int j = 0; j <= m; j++){
		for(int k = 0; k <= m; k++){
			if((m-k)%2) ans += mod - comb(m-k+1, j) * fact[j] % mod * dp[1][j][k] % mod, ans %= mod;
			else ans += comb(m-k+1, j) * fact[j] % mod * dp[1][j][k] % mod, ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 990464
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    ll n = s.size(), m = t.size();
    ll ans = INF;
    auto calc = [&](string &u, string &v) -> ll{
        if(u.size() != v.size())return INF;
        ll res = 0;
        ll o = u.size();
        rep(i,0,o){
            res += u[i] != v[i];
        }
        return res;
    };
    rep(i,0,n){
        string u = s.substr(i, m);
        chmin(ans, calc(u, t));
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<cstring>
using namespace std;

int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<(s.size()-4);i++){
		if(s.substr(i,5)=="apple")s.replace(i,5,"peach");
		else if(s.substr(i,5)=="peach")s.replace(i,5,"apple");
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const LL INF=(LL)1<<60;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

LL cost[405][405];
LL t[405];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		t[i+1]=t[i]+a;
	}
	for(j=2;j<=n;j++){
		for(i=0;i<n;i++){
			if(i+j>n)break;
			a=INF;
			for(k=1;k<j;k++){
				a=min(a,cost[i][k]+cost[i+k][j-k]);
			}
			cost[i][j]=a+t[i+j]-t[i];
		}
	}
	cout<<cost[0][n]<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define MAX_H 1000000000 //10^9
#define MAX_W 1000000000 //10^9
#define MAX_N 100000 //10^5
#define mp make_pair
#define INF 1001001001
#define LLINF 1001001001001001001
#define llint long long int
#define ppp pair<int, pair<int,int> >
using namespace std;
#define rep(i,n) for(int i=0; i<n ; i++)
using namespace std;
llint homesx[MAX_N];
llint homesy[MAX_N];
llint homesxs[MAX_N];
llint homesys[MAX_N];
int main(void){
    // Your code here!
    llint W,H,N;
    scanf("%lld %lld %lld",&W,&H,&N);
    rep(i,N){
        llint X,Y;
        scanf("%lld %lld",&X,&Y);X--;Y--;
        homesx[i]=X;homesy[i]=Y;
        homesxs[i]=X;homesys[i]=Y;
    }
    
    //X座標について求める
    if(N==1){printf("%lld\n%lld %lld\n",0,homesx[0]+1,homesy[0]+1);return 0;}
    llint ans=LLINF;
    llint zans[2]={-1,-1};
    sort(&homesxs[0], &homesxs[N]);
    sort(&homesys[0], &homesys[N]);
    llint Center1=(llint)(N/2)-1;
    llint Center2=(llint)(N/2);
    
    llint sum=0;llint maxl=0;
    rep(i,N){
        llint leng=abs(homesx[i]-homesxs[Center1]) + abs(homesy[i]-homesys[Center1]);
        sum+=2*leng;
        maxl=max(leng,maxl);
    }
    if(ans>sum-maxl){ans=sum-maxl;zans[0]=homesxs[Center1];zans[1]=homesys[Center1];}
    sum=0;maxl=0;
    rep(i,N){
        llint leng=abs(homesx[i]-homesxs[Center1]) + abs(homesy[i]-homesys[Center2]);
        sum+=2*leng;
        maxl=max(leng,maxl);
    }
     if(ans>sum-maxl){ans=sum-maxl;zans[0]=homesxs[Center1];zans[1]=homesys[Center2];}
    sum=0;maxl=0;
    rep(i,N){
        llint leng=abs(homesx[i]-homesxs[Center2]) + abs(homesy[i]-homesys[Center1]);
        sum+=2*leng;
        maxl=max(leng,maxl);
    }
     if(ans>sum-maxl){ans=sum-maxl;zans[0]=homesxs[Center2];zans[1]=homesys[Center1];}
    sum=0;maxl=0;
    rep(i,N){
        llint leng=abs(homesx[i]-homesxs[Center2]) + abs(homesy[i]-homesys[Center2]);
        sum+=2*leng;
        maxl=max(leng,maxl);
    }
     if(ans>sum-maxl){ans=sum-maxl;zans[0]=homesxs[Center2];zans[1]=homesys[Center2];}
    printf("%lld\n%lld %lld\n",ans,zans[0]+1,zans[1]+1);
}



Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define endl "\n"
template <typename T>
void printvec(vector<T> &v, int n, int start = 0)
{
    //cout << "\nprinting vector\n";
    for (int i = start; i < n; i++)
    {
        cout << v[i] << " ";
    }
    cout << "done printing";
    cout << endl;
}
const int mod = 1e9 + 7;

void solve()
{
    int n;
    cin>>n;
    vi a(n);
    for(int &x : a) cin>>x;
    sort(all(a));
    int ans =0;
    for(int i=0;i<=n-3;i++)
    {
        for(int j=i+1;j<=n-2;j++)
        {
            for(int k=j+1;k<=n-1;k++)
            {
                if(a[i] + a[j] > a[k] && a[i] != a[j] && a[i]!=a[k] && a[j] != a[k])
                {
                    //vi t = {a[i],a[j],a[k]};
                    //printvec(t,t.size());
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
import java.util.PriorityQueue;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int H = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        System.out.println(solve(a, b, H));

        sc.close();
    }

    static int solve(int[] a, int[] b, int H) {
        PriorityQueue<Sword> pq = new PriorityQueue<>((s1, s2) -> -Integer.compare(s1.getDamage(), s2.getDamage()));
        for (int i = 0; i < a.length; ++i) {
            pq.offer(new Sword(new int[] { a[i], b[i] }, 1));
        }

        int result = 0;
        while (true) {
            Sword head = pq.poll();
            if (head.index == 0) {
                result += (H + head.getDamage() - 1) / head.getDamage();

                return result;
            }

            ++result;
            H -= head.getDamage();
            if (H <= 0) {
                return result;
            }

            --head.index;
            pq.offer(head);
        }
    }
}

class Sword {
    int[] damages;
    int index;

    Sword(int[] damages, int index) {
        this.damages = damages;
        this.index = index;
    }

    int getDamage() {
        return damages[index];
    }
}

Measured memory_bytes: 96728
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<memory.h>
#include<map>
#include<set>
#include<queue>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,k,sum[200005];
typedef long long LL;
int main()
{
	cin>>n>>k;
	LL tmp=n/k;
	LL ans=tmp*tmp*tmp;
	if(k&1)k;else
	{
		tmp=0;
		rep(i,1,n)if(i%k==k/2)tmp++;
		ans+=tmp*tmp*tmp;
	}
	cout<<ans;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n;
	ll ans = 0;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}
		
		ans += (ll)i;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
#define inf 101010

int main(void) {
    int n, m, s, g1, g2;
    while (cin>>n>>m>>s>>g1>>g2 && n) {
        vector<vector<int> > e(n+1, vector<int>(n+1, inf));
        for (int i = 0; i < m; i++) {
            int a,b,c;
            cin >> a >> b >> c;
            e[a][b] = c;
        }
        for (int i = 1; i < n+1; i++) e[i][i] = 0;
        
        for (int k = 1; k < n+1; k++) {
            for (int i = 1; i < n+1; i++) {
                for (int j = 1; j < n+1; j++) {
                    e[i][j] = min(e[i][j], e[i][k]+e[k][j]);
                }
            }
        }
        
        int ans = inf;
        for (int i = 1; i < n+1; i++) {
            ans = min(ans, e[s][i] + e[i][g1] + e[i][g2]);
        }
        cout << ans << endl;
    }
}

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

int main(){
  int K;
  cin >> K;
  vector<int> vec = {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};
  
  cout << vec.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> xs(n), ys(n);
    bool odd;
    for(int i = 0; i < n; i++){
        cin >> xs[i] >> ys[i];
        if(i == 0){
            odd = (xs[i] + ys[i]) & 1;
        }else{
            if(odd != ((xs[i] + ys[i]) & 1)){
                cout << -1 << '\n';
                return 0;
            }
        }
    }
    vector<int> nums;
    for(int j = 30; j >= 0; j--){
        nums.push_back(1 << j);
    }
    if(!odd){
        nums.push_back(1);
    }
    cout << nums.size() << '\n';
    for(auto& num : nums){
        cout << num << ' ';
    }
    cout << '\n';
    for(int i = 0; i < n; i++){
        ll x = xs[i], y = ys[i];
        for(auto num : nums){
            if(abs(x) > abs(y)){
                if(x < 0){
                    cout << 'L';
                    x += num;
                }else{
                    cout << 'R';
                    x -= num;
                }
            }else{
                if(y < 0){
                    cout << 'D';
                    y += num;
                }else{
                    cout << 'U';
                    y -= num;
                }
            }
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int k,a,b;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    int ans=0;
    int tmp=k;

    for(int i=1;i<=b;i++){
        if(tmp*i>=a){
            if(tmp*i<=b){
                ans=1;
            }else{
                break;
            }
        }else{
            ;
        }
    }

    if(ans==1){
        printf("OK");
    }else{
        printf("NG");
    }
    return 0;
}

Measured memory_bytes: 1704
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    System.out.println(
        s.contains("RRR") ? 3 : s.contains("RR") ? 2 : s.contains("R") ? 1 : 0
    );
  }
}


Measured memory_bytes: 26972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CManyMedians solver = new CManyMedians();
        solver.solve(1, in, out);
        out.close();
    }

    static class CManyMedians {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n];
            int[] sort = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                sort[i] = x[i];
            }
            Arrays.sort(sort);
            for (int i = 0; i < n; i++) {
                if (x[i] <= sort[n / 2 - 1]) {
                    out.println(sort[n / 2]);
                } else {
                    out.println(sort[n / 2 - 1]);
                }
            }

        }

    }
}



Measured memory_bytes: 92560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int a = S.size();
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < a; j++){
      if(S.at(j) == 'Z'){
        S.at(j) = 'A';
      }
      else{
        S.at(j)++;
      }
    }
  }
  
  cout << S << endl;
  
}

Measured memory_bytes: 256
N = int(input())
A = 1
ans = len(str(N))
while A**2 <= N:
    if N % A != 0:
        # Bが整数にならない
        A += 1
        continue
    B = N // A
    cur = max(len(str(A)), len(str(B)))
    ans = min(ans, cur)
    A += 1
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

def main():
    R, C, K = map(int, input().split())
    V = [[0] * C for _ in [None] * R]
    for _ in [None] * K:
        r, c, v = map(int, input().split())
        V[r - 1][c - 1] = v

    dp = [[[-1] * C for _ in [None] * R] for _ in [None] * 4]

    dp[0][0][0] = 0
    for r in range(R):
        for c in range(C):
            v = V[r][c]
            for i in range(4):
                if dp[i][r][c] > -1:
                    if r < R - 1:
                        dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c])
                    if c < C - 1:
                        dp[i][r][c + 1] = max(dp[i][r][c + 1], dp[i][r][c])
                    if i < 3 and v:
                        if r < R - 1:
                            dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c] + v)
                        if c < C - 1:
                            dp[i + 1][r][c + 1] = max(dp[i + 1][r][c + 1], dp[i][r][c] + v)

    v = V[R - 1][C - 1]
    ans = dp[3][R - 1][C - 1]
    for i in range(3):
        ans = max(ans, dp[i][R - 1][C - 1] + v)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 427728
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int X = 0,Y = 0,Z = 0;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if(a%4 == 0) {
            X++;
        }
        else if(a%2 == 0) {
            Y++;
        }
        else {
            Z++;
        }
    }
    cout << ((X+((Y >= 1)?0:1) >= Z)?"Yes":"No") << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  int res = 0;
  for (int i=0; i<N; i++) {
    while (i+1<N&&A[i]==A[i+1]) i++;
    if (i+1<N&&A[i]<A[i+1]) {
      while (i+1<N&&A[i]<=A[i+1]) i++;
    }
    else if (i+1<N&&A[i]>A[i+1]) {
      while (i+1<N&&A[i]>=A[i+1]) i++;
    }
    res++;
  }
  cout << res << endl;
}

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


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    string a;
    cin >> a;
    if(a == "AAA" || a == "BBB"){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解答写し
int main() {
  int h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h){
    cin>>s[i];
    //cout<<s[i]<<endl;
  }
  vector<vector<int>>cnt(h,vector<int>(w,0));
  rep(i,h){
    vector<int>done(w,0);
    rep(j,w){
      //cout<<i<<" "<<j;
      //cout<<" "<<s[i][j]<<endl;
      if(s[i][j]=='#')continue;
      if(done[j])continue;
      int l=0;
      while(j+l<w){
        if(s[i][j+l]=='#')break;
        //cout<<"nagasa";
        ++l;
      }
      rep(k,l){
        //cout<<"count";
        cnt[i][j+k]+=l;
        done[j+k]=1;
      }
    }
  }
  rep(j,w){
    vector<int>done2(h,0);
    rep(i,h){
      //cout<<i<<" "<<j<<" "<<s[i][j]<<endl;
      if(s[i][j]=='#')continue;
      if(done2[i])continue;
      int l=0;
      while(i+l<h){
        if(s[i+l][j]=='#')break;
        ++l;
      }
      rep(k,l){
        cnt[i+k][j]+=l;
        done2[i+k]=1;
      }
    }
  }
  int ans=0;
  rep(i,h){
    rep(j,w){
      ans=max(ans,cnt[i][j]-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 20096
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from bisect import bisect_left as bisect
    n=int(input())
    A=list(map(int,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]

    ans=INF
    for j in range(1,n):
        i=bisect(S,S[j]/2)
        k=bisect(S,(S[j]+S[-1])/2)
        ans=min(ans,max(S[i],S[j]-S[i],S[k]-S[j],S[-1]-S[k])-min(S[i],S[j]-S[i],S[k]-S[j],S[-1]-S[k]))
        ans=min(ans,max(S[i],S[j]-S[i],S[k-1]-S[j],S[-1]-S[k-1])-min(S[i],S[j]-S[i],S[k-1]-S[j],S[-1]-S[k-1]))
        ans=min(ans,max(S[i-1],S[j]-S[i-1],S[k]-S[j],S[-1]-S[k])-min(S[i-1],S[j]-S[i-1],S[k]-S[j],S[-1]-S[k]))
        ans=min(ans,max(S[i-1],S[j]-S[i-1],S[k-1]-S[j],S[-1]-S[k-1])-min(S[i-1],S[j]-S[i-1],S[k-1]-S[j],S[-1]-S[k-1]))
    print(ans)
resolve()

Measured memory_bytes: 84032