akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define N 50
#define M 10
using namespace std;

class Point{
public:
  int x;
  int y;
};

main(){
  int n, sm;
  Point moto[2][M];
  Point motolen[2][M];
  Point in[N][M];
  Point inlen[N][M];
  int m[N];

  while(1){
    cin >> n;
    if(n==0) break;

    cin >> sm;
    for(int i=0;i<sm;i++){
      cin >> moto[0][i].x >> moto[0][i].y;
    }

    for(int i=0;i<sm;i++){
      moto[1][i].x=moto[0][sm-i-1].x;
      moto[1][i].y=moto[0][sm-i-1].y;
    }

    for(int i=0;i<n;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++){
        cin >> in[i][j].x >> in[i][j].y;
      }
    }

    for(int i=0;i<sm-1;i++){
      motolen[0][i].x=moto[0][i+1].x-moto[0][i].x;
      motolen[0][i].y=moto[0][i+1].y-moto[0][i].y;
      motolen[1][i].x=moto[1][i+1].x-moto[1][i].x;
      motolen[1][i].y=moto[1][i+1].y-moto[1][i].y;
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<m[i]-1;j++){
        inlen[i][j].x=in[i][j+1].x-in[i][j].x;
        inlen[i][j].y=in[i][j+1].y-in[i][j].y;
      }
    }

    for(int i=0;i<n;i++){
      if(sm!=m[i]) continue;
      bool flag1=true;
      bool flag2=true;
      for(int j=0;j<sm-1;j++){
        if(motolen[0][j].x!=inlen[i][j].x || motolen[0][j].y!=inlen[i][j].y){
          flag1=false;
        }
        if(motolen[1][j].x!=inlen[i][j].x || motolen[1][j].y!=inlen[i][j].y){
          flag2=false;
        }
      }
      if(flag1 || flag2){
        printf("%d\n", i+1);
        continue;
      }
      flag1=flag2=true;
      for(int j=0;j<sm-1;j++){
        if((motolen[0][j].x*-1)!=inlen[i][j].x || (motolen[0][j].y*-1)!=inlen[i][j].y){
          flag1=false;
        }
        if((motolen[1][j].x*-1)!=inlen[i][j].x || (motolen[1][j].y*-1)!=inlen[i][j].y){
          flag2=false;
        }
      }

      if(flag1 || flag2){
        printf("%d\n", i+1);
        continue;
      }

      flag1=flag2=true;
      for(int j=0;j<sm-1;j++){
        if(motolen[0][j].y!=inlen[i][j].x || (motolen[0][j].x*-1)!=inlen[i][j].y){
          flag1=false;
        }
        if(motolen[1][j].y!=inlen[i][j].x || (motolen[1][j].x*-1)!=inlen[i][j].y){
          flag2=false;
        }
      }

      if(flag1 || flag2){
        printf("%d\n", i+1);
        continue;
      }

      flag1=flag2=true;
      for(int j=0;j<sm-1;j++){
        if((motolen[0][j].y*-1)!=inlen[i][j].x || motolen[0][j].x!=inlen[i][j].y){
          flag1=false;
        }
        if((motolen[1][j].y*-1)!=inlen[i][j].x || motolen[1][j].x!=inlen[i][j].y){
          flag2=false;
        }
      }



      if(flag1 || flag2){
        printf("%d\n", i+1);
      }
    }


    printf("+++++\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
    char ch[4];

    scanf("%[^\n]",ch);

    if(ch[0]==ch[1]&&ch[2]==ch[3]&&ch[0]!=ch[2]||
            ch[0]==ch[3]&&ch[1]==ch[2]&&ch[0]!=ch[1]||
            ch[0]==ch[2]&&ch[1]==ch[3]&&ch[0]!=ch[1])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(3*n);
    rep(i,3*n) cin >> a[i];
    sort(all(a));
    ll cnt = 0;
    ll index = 3*n-2;
    ll ans = 0;
    while(cnt < n){
        ans += a[index];
        index -= 2;
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
       
     if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
         System.out.println("Yes");
     }
     else
      {
       System.out.println("No"); 
      }
        
    }
}


Measured memory_bytes: 26236
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int a[128];
int main(void){
	int n=nextint();
	int m=nextint();
	char c;
	while((c=getchar())!=EOF) a[c]++;
	int b1=0, b2=0;
	for(char c='a'; c<='z'; c++){
		if(a[c]&2) b2++;
		if(a[c]&1) b1++;
	}
	bool f;
	if(n%2==0&&m%2==0){
		f=(b1==0&&b2==0);
	}else if(n%2==0){
		f=(b1==0&&b2<=n/2);
	}else if(m%2==0){
		f=(b1==0&&b2<=m/2);
	}else{
		f=(b1<=1&&b2<=(n+m)/2-1);
	}
	puts(f?"Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> from(n, vector<int>());
  vector<vector<int>> to(n, vector<int>());
  rep(i, n+m-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    from.at(b).push_back(a);
    to.at(a).push_back(b);
  }
  vector<int> co(n, 0);
  vector<int> ans(n);
  int st = 0;
  rep(i, n){
    if(from.at(i).size() == 0){
      ans.at(i) = -1;
      st = i;
    }
  }
  queue<int> q;
  q.push(st);
  while(!q.empty()){
    int now = q.front(); q.pop();
    for(int nx : to.at(now)){
      if(from.at(nx).size() - 1 != co.at(nx)){
        co.at(nx)++;
      }else{
        q.push(nx);
        ans.at(nx) = now;
      }
    }
  }
  rep(i, n){
    cout << ans.at(i)+1 << endl;
  }
  return 0;
}

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

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

    double ans = 0;
    for(int i = 0; i < N; i++)
    {
        double x;
        string u;

        cin >> x >> u;

        if(u == "JPY")
        {
            ans += x;
        }

        else
        {
            ans += (x * 380000.0);
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  int max =0;
  int max_num;
  int ans=0;
  cin >> n;
  vector<int> price(n);
  for(int i=0;i<n;i++){
    cin >> price[i];
  }
  for(int j = 0;j < n;j++) {
    if(max<price[j]){
      max = price[j];
      max_num = j;
    }
  }
  for(int k = 0; k < n; k++) {
    if(k!=max_num){
      ans+=price[k];
      continue;
    }
    ans+=(price[k]/2);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, W;
int v[110]; int w[110];
int V[110][10010];

int main() {
  cin >> N >> W;
  for (int i = 1; i <= N; i++)
    cin >> v[i] >> w[i];
  for (int i = 0; i <= N; i++) {
    for (int c = 0; c <= W; c++) {
      if (i == 0 || c == 0)
        V[i][c] = 0;
      else if (c-w[i] < 0)
        V[i][c] = V[i-1][c];
      else {
        int a[3] = {v[i] + V[i][c-w[i]],v[i] + V[i-1][c-w[i]], V[i-1][c]};
        V[i][c] = *max_element(a, a+3);
      }
    }
  }
  cout << V[N][W] << endl;
}



Measured memory_bytes: 7052
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

const long long MOD = 998244353;

long long dp[3001];

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

	int N, S;
	cin >> N >> S;

	vector<long long> numlist(N + 1, 0);
	for (int i = 1; i <= N; i++)
	{
		cin >> numlist[i];
	}

	long long result = 0;
	for (int i = 1; i <= N; i++)
	{
		for (int j = S; j >= numlist[i]; j--)
		{
			if (j == numlist[i])
				dp[j] = (dp[j] + i) % MOD;
			else
				dp[j] = (dp[j] + dp[j - numlist[i]]) % MOD;
		}

		result = (result + dp[S]) % MOD;
	}

	cout << result;

	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int ans = 0;

    if(1<=n && n<=9) ans=n;
    if(10<=n && n<=99) ans=9;
    if(100<=n && n<=999) ans=9+(n-99);
    if(1000<=n && n<=9999) ans=909;
    if(10000<=n && n<=99999) ans=909+(n-9999);
    if(n==100000) ans=90909;

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) { 
    char suitsAry[4];
    suitsAry[0] = 'S';
    suitsAry[1] = 'H';
    suitsAry[2] = 'C';
    suitsAry[3] = 'D';
    
    int cards[4][14] = {0}; 
    int c_num;
    scanf("%d",&c_num);

    char suit;
    int rank,index,i,j;
    for(i=0;i<2*c_num;i++) {
        scanf("%c %d",&suit,&rank);
        for(j=0;j<4;j++){
            if(suitsAry[j] == suit){
                cards[j][rank]=1;
                break;
            }           
        }
    }
    
    int i_suit,i_rank;
    for(i_suit=0;i_suit<4;i_suit++){
        for(i_rank=1;i_rank<=13;i_rank++){
            if(cards[i_suit][i_rank]==0) printf("%c %d\n",suitsAry[i_suit],i_rank);
        }
    }

    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y,z;
    int k;
    cin >> x >> y >> z >> k;
    int MAX = max(x,max(y,z));
    for(int i = 0;i < k;i++){
        MAX *= 2;
    }
    cout << x + y + z + MAX - max(x,max(y,z)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/

long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b){
    return (a < b)? b/gcd(a,b)*a: a/gcd(a,b)*b;
}
int main()
{
    ll A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    //同じ座標にいないと捕まえられない
    //そもそも追いつくのが無理な場合
    if(W >= V){
        fin("NO"); return 0;
    }
    //座標の差を求める
    ll diff = abs(A-B);
    if(diff/abs(V-W) < T){
        fin("YES");
    }else if(diff/abs(V-W) == T){
        if(diff%abs(V-W)){
            fin("NO");
        }else{
            fin("YES");
        }
    }
    else{
        fin("NO");
    }
    
    return 0;
}

Measured memory_bytes: 3128
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    s = input()
    ans = 0
    for i in range(n-2):
        if s[i:i+3] == "ABC":
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 2e5 + 10;
lli nums[2*N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int k, n;
	cin >> k >> n;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	
	lli ans = 0;
	for(int i = 2; i <= n; i++)
		ans = max(ans, nums[i] - nums[i-1]);
	ans = max(ans, nums[1] + (k - nums[n]));
	cout << k-ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
res = sum(i for i in map(int, input().split()))
C = list(map(int, input().split()))
for i in range(N - 1):
    if A[i + 1] - A[i] == 1:
        res += C[A[i] - 1]
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

signed main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	puts((b * 10 + c) % 4 == 0 ? "YES" : "NO");
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  int ans = 1000;
  for(int i=0; i<S.length()-T.length()+1; ++i){
    for(int j=0; j<T.length(); ++j){
      if(T[j]!=S[i+j]) ++count;
    }
    ans = min(ans, count);
    count = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const int MAXANS=45;
const int MAXN=100000;
int n,ans;
bool dp[MAXANS+5][MAXN+5],memo[MAXANS+5][MAXN+5];
bool possible(int sisa,int angka){
	if(sisa==0&&angka==0)
		return true;
	if(memo[sisa][angka])
		return dp[sisa][angka];
	memo[sisa][angka]=true;
	bool &ret=dp[sisa][angka];
	ret=false;
	for(int i=1;i<=9;i++)
	{
		if(sisa>=i)
			ret|=(possible(sisa-i,(angka*10+i)%n));
	}
	ret|=possible(sisa,(angka*10)%n);
	return ret;
}
int main()
{
	memset(memo,false,sizeof(memo));
	scan(n);
	for(ans=1;ans<=MAXANS;ans++)
	{
		if(possible(ans,0))
			break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11008
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)

using namespace std;

int N;
int A[200005]; //1-indexed
int L[200005]; //1〜i-1までの最大値
int R[200005]; //i〜Nまでの最大値


void solve() {

	L[1] = -1;
	REP(i, 2, N + 1) {
		if ( A[i] > L[i - 1] ) L[i] = A[i - 1];
		else L[i] = L[i - 1];
	}

	R[N] = A[N];
	R[N + 1] = -1;
	REVREP(i, N - 1, 0) {
		if ( A[i] > R[i + 1] ) R[i] = A[i];
		else R[i] = R[i + 1];
	}

	REP(i, 1, N + 1) {
		printf("%d\n", max(L[i], R[i + 1]));
	}

}

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

    REP(i, 1, N + 1) scanf("%d", &A[i]);

    solve();

	return 0;
}


Measured memory_bytes: 3968
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    x,y=1,1
    for _ in range(n):
        a,b=map(int,input().split())
        k=max((x-1)//a+1,(y-1)//b+1)
        x,y=k*a,k*b
    print(x+y)
resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

template<typename T>
class SegTree {
public:
  int n;
  vector<T> data;
  SegTree(int n_){
    n=1;
    while(n<n_) n*=2;
    data.resize(2*n, INF);
  }
  inline T query(int l, int r){
    T ret = INF;
    for(l+=n, r+=n; l<r; l/=2, r/=2){
      if(l&1) ret = min(ret, data[l++]);
      if(r&1) ret = min(ret, data[--r]);
    }
    return ret;
  }
  inline void update(int k, T a){
    k+=n;
    data[k]=a;
    while(k>0){
      k = k/2;
      data[k] = min(data[k*2], data[k*2+1]);
    }
  }
};


int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i], vec[i]--;
  vector<int> pos(n);
  rep(i,n) pos[vec[i]] = i;
  SegTree<int> even(n+1), odd(n+1);
  rep(i,n){
    if(i%2) odd.update(i, vec[i]);
    else even.update(i, vec[i]);
  }

  vector<int> ans;

  using P = pair<int,int>;
  priority_queue<pair<int,P>, vector<pair<int,P>>, greater<pair<int,P>>> pq;
  pq.push(mp(even.query(0,n),mp(0,n)));

  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int l = p.se.fi, r = p.se.se;//dbg(l,r);
    int p1 = pos[p.fi];
    int p2;
    bool sw = false;
    if(p1%2==0){
      if((p1-l)%2==0) p2 = odd.query(p1, r);
      else sw=true,p2 = odd.query(l, p1);
      assert(p2!=INF);
      p2 = pos[p2];
      odd.update(p2, INF);
      even.update(p1, INF);
    }
    else {
      if((p1-l)%2==0) p2 = even.query(p1, r);
      else sw=true, p2 = even.query(l, p1);
      assert(p2!=INF);
      p2 = pos[p2];
      even.update(p2, INF);
      odd.update(p1, INF);
    }
    if(sw) swap(p1,p2);
    ans.pb(vec[p1]);ans.pb(vec[p2]);

    auto ins = [&](int a, int b){
      if(a==b) return;
      int x;
      if(a%2==0) x = even.query(a,b);
      else x = odd.query(a,b);
      pq.push(mp(x, mp(a,b)));
    };
//    dbg(p1,p2);
    ins(l,p1);
    ins(p1+1,p2);
    ins(p2+1,r);
  }

  rep(i,n) cout << ans[i]+1 << " \n"[i==n-1];

  return 0;
}


Measured memory_bytes: 8616
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

N = int(input())
count = 0

for i in range(1,N+1,2):
    if len(divisor(i)) == 8:
        count += 1


print(count)

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> A(N);
    vector<llint> a(N + 1, 0);

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

        a[A[i]] ++;
    }
    llint sum = 0;

    for(int i = 1; i <= N; i ++){
        sum += a[i] * (a[i] - 1) / 2;
    }
    for(int i = 0; i < N; i ++){
        cout << sum - a[A[i]] * (a[A[i]] - 1) / 2 + (a[A[i]] - 1) * (a[A[i]] - 2) / 2 << endl;
    }
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll N, K;
vector<ll> A;

bool isokk(ll x, ll i,ll key){
  if(A[x]*A[i]<key) return true;
  else return false;
}
// A[0]~A[i-1]でA[i]との積が x未満の個数
ll binsch2(ll i, ll x){
  if(i==0) return 0;
  // set value
  ll ok,ng;
  if(A[i]>=0) {
    if(A[i]*A[0]>=x) return 0;
    ok = 0; ng = i;
    while(abs(ok-ng)>1){
      ll mid = (ok+ng)/2;
      if(isokk(mid, i, x)) ok = mid;
      else ng = mid;
    }
    return ok+1;
  }
  else {
    if(A[i]*A[i-1]>=x) return 0;
    ok = i-1; ng = -1;
    while(abs(ok-ng)>1){
      ll mid = (ok+ng)/2;
      if(isokk(mid,i,x)) ok = mid;
      else ng = mid;
    }
  }
  return i-ok;
}

// x未満の数はkey個未満か
bool isok(ll x, ll key){
  ll cnt = 0;
  rep(i,N){
    // A[i]にかけてx未満になるA[i-1]までの要素の個数
    cnt += binsch2(i,x);
  }
  if(cnt<key) return true;
  else return false;
}
//自身未満がK個未満の数
ll binsch(ll key){
  // set value
  ll ng =1e18+1; ll ok = -1e18;
  while(abs(ok-ng)>1){
    ll mid = (ok+ng)/2;
    if(isok(mid, key)) ok = mid;
    else ng = mid;
  }
  return ok;
}


// 自身未満がK個未満の最大
int main(){
  cin >> N >> K;
  A.resize(N); rep(i,N) cin >> A[i];
  sort(all(A));
  cout << binsch(K) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    if (N == 7 || N == 5 || N == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
b = input()
rud_list = ['R','U','D']
lud_list = ['L','U','D']
flg = True

for idx,i in enumerate(b):
    if (idx + 1)%2 ==0 and (i not in lud_list):
        print('No')
        flg = False
        break
    elif (idx + 1)%2 == 1 and (i not in rud_list):
        print('No')
        flg = False
        break
    else:
        pass
        
if flg:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n, x, y;
ll dx[N], dy[N];
vector<ll> G[N];
void dfsx(ll v , ll par = 0) {
	for (auto u : G[v])
		if (u != par)
			dx[u] = dx[v] + 1, dfsx(u , v);
}
void dfsy(ll v , ll par = 0) {
	for (auto u : G[v])
		if (u != par)
			dy[u] = dy[v] + 1, dfsy(u, v);
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n >> x >> y;
    for (int i = 0 ; i <n - 1; i ++) {
    	ll v, u;
    	cin >> v >> u;
    	G[v].pb(u);
    	G[u].pb(v);
	}
	dfsx(x);
	dfsy(y);
	ll ans = 0 ;
	for (int i = 1; i <= n ; i ++) {
		ll res = 0;
		if (dx[i] >= dy[i]) continue;
		res = dy[i] - 1;
		ans = max(ans, res);
	}
	cout << ans<< endl;
    
    return (0) ;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;


int main()
{
  ll K; scanf("%lld", &K);
  int N = 50;
  ll d = K / N;
  vector<ll> A(50);
  for (int i = 0; i < N; ++i) {
    A[i] = i + d;
  }
  for (int i = 0; i < K % N; ++i) {
    A[i] += N + 1;
    for (int j = 0; j < N; ++j) {
      --A[j];
    }
  }

  printf("%d\n", N);
  printf("%lld", A[0]);
  for (int i = 1; i < N; ++i) {
    printf(" %lld", A[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;cin>>a;
    ll int sum = 0;
    sum +=a ;
    sum += (ll)a*a ;
    sum += (ll)((ll)a*a)*a;
    cout<<sum;
    return 0;
}


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

int main(){
  string t;
  cin >> t;
  int n = t.size();

  for (int i = 0; i < n; i++)
  {
    if(t[i]=='?')t[i]='D';
  }
  cout << t << endl;  
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N = gets.to_i

ans = 0
(N+1).times do |n|
  next if n % 2 == 0
  ctr = 0;
  n.times do |i|
    ctr += 1 if n%(i+1) == 0
  end
  ans += 1 if ctr == 8
end

print ans, "\n"


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

#define time_assert(x) if(!(x))while(true)

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n, d, a;
	cin >> n >> d >> a;
	vector<pair<int,int>> monsters;
	for(int i = 0; i < n; i++) {
		int x, h;
		cin >> x >> h;
		h = (h + a - 1) / a;
		monsters.emplace_back(x, h);
	}
	sort(monsters.begin(), monsters.end());
	time_assert((int) monsters.size() == n);
	
	int base = 1;
	while(base < n) {
		base *= 2;
	}
	vector<long long> tree(2 * base);
	for(int i = 0; i < n; i++) {
		tree[base+i] = monsters[i].second;
	}
	auto get_health = [&](int i) {
		int total = 0;
		for(int j = base + i; j >= 1; j /= 2) {
			total += tree[j];
		}
		return total;
	};
	auto add_interval = [&](int L, int R, int x) {
		L += base;
		R += base;
		tree[L] += x;
		if(L != R) {
			tree[R] += x;
		}
		while(L + 1 < R) {
			if(L % 2 == 0) {
				tree[L+1] += x;
			}
			if(R % 2 == 1) {
				tree[R-1] += x;
			}
			L /= 2;
			R /= 2;
		}
	};
	
	long long answer = 0;
	for(int i = 0; i < n; i++) {
		int my_health = get_health(i);
		if(my_health <= 0) { // already killed
			continue;
		}
		// find the last monster still hit by a bomb starting here
		int low = i, high = n - 1;
		int ok = -1;
		while(low <= high) {
			int mid = (low + high) / 2;
			if(monsters[mid].first <= monsters[i].first + 2LL * d) {
				ok = mid;
				low = mid + 1;
			}
			else {
				high = mid - 1;
			}
		}
		time_assert(ok != -1);
		add_interval(i, ok, -my_health);
		answer += my_health;
	}
	cout << answer << endl;
}

Measured memory_bytes: 6000
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int N,K,W[100000];

class TR{
public:
    int mP;
    int K;
    
    void init(int P){
        mP = P;
    }
    
    bool load(int p){
        if (mP < p) {
            return true;
        }else{
            mP -= p;
            return false;
        }
    }
};

bool rec(int P){
    int i = 0;
    REP1(j,K){
        TR Truck;
        Truck.init(P);
        while (i < N) {
            if(Truck.load(W[i])) break;
            i++;
        }
    }
    if (i > N-1) {
        return true;
    }else{
        return false;
    }
}

int binary(int l,int r){
    if (r-l == 1) return r;
    int mid = (l+r)/2;
    if (rec(mid)) {
        return binary(l,mid);
    }else{
        return binary(mid,r);
    }
}

int main(){
    INPUT(N);INPUT(K);
    REP1(i,N) INPUT(W[i]);
    
    cout << binary(0,1000000000) << endl;
    return 0;
}

Measured memory_bytes: 1596
//
//  main.cpp
//  tester
//
//  Created by Happiness on 2017/06/06.
//  Copyright © 2017年 Happiness. All rights reserved.
//


#include<iostream>
using namespace std;
int main(){
    int r,g,b,ans;
    cin >> r >> g >> b;
    ans = r*100+g*10+b;
    if(ans%4 != 0)cout << "NO" << "\n";
    else cout << "YES" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int b[2008];
int main()
{
   	ios :: sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin >> n >> x >> y;
	int k;
	
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
		{
			k=min ( min ( abs(j-i), abs(i-x)+1+abs(j-y)), abs(i-y)+1+abs(j-x));
			b[k]++;
		}
	
	for(int i=1; i<=n-1; i++)
		cout << b[i] << endl;
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    cin >> N;

    vs32 p(N);
    rep (i, N) { cin >> p[i]; --p[i]; }

    int ans = 0;
    rep (i, N)
    {
        if (p[i] == i)
        {
            if (i == 0)
            {
                swap(p[i], p[i + 1]);
                ++ans;
            }
            else if (i == N - 1)
            {
                swap(p[i], p[i - 1]);
                ++ans;
            }
            else
            {
                if (p[i + 1] == i + 1)
                {
                    swap(p[i], p[i + 1]);
                }
                else
                {
                    swap(p[i], p[i - 1]);
                }
                ++ans;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+12;
int a[N];
int main()
{
//	freopen("a.in","r",stdin);
	
	int n,k;
	scanf("%d%d",&n,&k);
	int now=1;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
	}
	int ans=0;
	while(now<n) now+=k-1,ans++;
	
	printf("%d\n",ans);	
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  vector<ll>sum(n+1),num(n+1,0);
  rep(i,0,n){
    ll a;cin>>a;
    sum[i+1]=sum[i]+a;
    num[i+1]=num[i]^a;
  }

  ll ans=0;
  for(int i=1,j=1;i<=n;++i){
		for(;j<=n&&sum[j]-sum[i-1]==(num[j]^num[i-1]);++j);
		ans+=j-i;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 3328
N = int(input())
Dl = []
for i in range(N):
  D = list(map(int, input().split()))
  Dl.append(D)
cn = 0
df = False
for i in range(len(Dl)):
  D = Dl[i]
  D0 = D[0]
  D1 = D[1]
  if D0 == D1:    
    cn += 1
  else:
    cn = 0
  if cn == 3:
    df = True
    break
if df == True:
  print('Yes')
else:
  print('No')

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

int main() {
	int w,a,b;
	cin >> w >> a >> b;
	if (b<a){
		swap(a,b);
	}
	if (a+w>b){
		cout << 0;
	}else{
		cout << b-a-w;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] t = new int[N];
  int sum = 0;
  for(int i = 0;i < N;i++){
    t[i] = sc.nextInt();
    sum += t[i];
  }
  int M =sc.nextInt();
  int[] p = new int[2*M];
  for(int i = 0;i < 2*M;i += 2){
    p[i] = sc.nextInt();
    p[i+1] = sc.nextInt();
    System.out.println(sum - t[p[i]-1] + p[i+1]);
  }
}}


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

int main()
{
  int N; // モンスターの数
  int K; // モンスターのHPを0にする必殺技の回数
  cin >> N >> K;

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

  sort(H, H + N);

  long long result = 0;
  for (int i = 0; i < N - K; i++)
  {
    result += H[i];
  }
  cout << result << endl;
}

Measured memory_bytes: 1024
N = int(input())
a = input().split()
a = list(map(int,a))
n = 0
p = N
while p == N:
  p = 0
  for i in range(N):
    if a[i]%2 == 0:
      p = p + 1
    else:
      break
  if p == N:
    a = list(map(lambda x: x/2,a))
    n = n + 1
print(n)

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


int main() {
  int N, M;
  int K;
  cin >> N >> M >> K;
  vector<int64_t> A(N + 1);
  vector<int64_t> B(M + 1);
  A.at(0) = 0;
  B.at(0) = 0;
  for(int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    A.at(i) = A.at(i - 1) + a;
  }
  for(int i = 1; i <= M; i++) {
    int b;
    cin >> b;
    B.at(i) = B.at(i - 1) + b;
  }
  int ans = 0;
  int keep = M;
  for(int i = 0; i <= N; i++) {
    for(int j = keep; j >= 0; j--) {
      if(A.at(i) + B.at(j) > K) {
        continue;
      }
      else {
        keep = j;
        if(i + j > ans) {
          ans = i + j;
        }
        break;
      }
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n){
        if(a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)){
            puts("DENIED");
            return 0;
        }
    }
    puts("APPROVED");
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception{
		Scanner cin= new Scanner(System.in);
		int a= cin.nextInt();
		int b= cin.nextInt();
		
		int L= 2*(a+b);
		int S= a*b;
		
		System.out.println(S+" "+L);
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, C;
    cin >> N >> C;
    vec<int> s(N), t(N), c(N);
    rep(i, N) cin >> s[i] >> t[i] >> c[i];

    vec<vec<int>> imos(31, vec<int>(2 * 1e5 + 20, 0));
    rep(i, N) {
        ++imos[c[i]][s[i] * 2 - 1];
        --imos[c[i]][t[i] * 2];
    }

    int ans = 0;
    for (int i = 1; i <= 2 * 1e5 + 10; ++i) {
        int sm = 0;
        rep(j, 31) {
            imos[j][i] = imos[j][i - 1] + imos[j][i];
            if(imos[j][i]>=1) ++sm;
        }
        ans = max(ans,sm);
    }
    cout << ans << endl;
}

Measured memory_bytes: 26496
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
k = ri()
ans = 0
for i in rl():
    ans += min(i, abs(k-i))
print(ans*2)












Measured memory_bytes: 26984
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V(100007);

int main(){
  cin >> N >> M;
  rep(i,N){
    A+=pow(10,i)*M;
  }
  rep(i,M){
    B+=pow(10,i)*N;
  }
  if(N>M){
    cout << A << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A;
    ll prev = inf;
    rep(i, N){
        ll a;
        cin >> a;
        if(prev != a) A.pb(a);
        prev = a;
    }
    
    if(N <= 2) {
        output(1);
        return 0;
    }
    int ans = 1;
    rep(i, A.size() - 2){
        if((A[i + 1] - A[i]) * (A[i + 2] - A[i + 1]) < 0){
            ans++;
            i++;
        }
    }
    output(ans);
    
    
    
    
    return 0;
}

Measured memory_bytes: 1400
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll X, Y;
    cin >> X >> Y;
    if (X % Y == 0) print(-1);
    else print(X);
    return 0;
}


Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def unite(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.weight[px] = w - self.weight[x] + self.weight[y]
            else:
                self.par[py] = px
                self.weight[py] = -w - self.weight[y] + self.weight[x]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
LRD = [list(map(int, input().split())) for i in range(M)]

graph = WeightedUnionFind(N)
for l, r, d in LRD:
    l -= 1
    r -= 1
    if graph.are_same(l, r):
        if graph.diff(l, r) != d:
            print("No")
            break
    else:
        graph.unite(l, r, d)
else:
    print("Yes")

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

string lcs(string s, string t)
{
    vvi v(s.size()+1, vi(t.size()+1));

    for(int i = 0; i <=(int)t.size();i++)
    {
        v[0][i]=0;
    }

    for(int i = 0; i <=(int)s.size();i++)
    {
        v[i][0]=0;
    }

    for(int i=1;i<=(int)s.size();i++)
    {
        for(int j=1;j<=(int)t.size();j++)
        {
            //cout << t[i] << ' ' << s[j] << '\n';
            if(s[i-1]==t[j-1])
            {
                v[i][j]=v[i-1][j-1]+1;
            }

            else
            {
                v[i][j]=max(v[i-1][j],v[i][j-1]);
            }
        }
    }

    string resenje = "";

    int i = (int)s.size();
    int j = (int)t.size();

//    for(int i=0;i<=(int)s.size();++i)
//    {
//        for(int j=0;j<=(int)t.size();++j)
//        {
//            cout <<v[i][j]<< ' ';
//        }
//
//        cout <<'\n';
//    }

    while(i > 0 && j > 0)
    {
        //cout << s[i-1] << ' ' << t[j-1] << '\n';
        if(s[i-1]==t[j-1])
        {
            resenje+=s[i-1];
            i--;
            j--;
        }

        else if(v[i-1][j]>v[i][j-1])
        {
            i--;
        }

        else
        {
            j--;
        }
    }

    reverse(all(resenje));
    return resenje;
}

int main()
{
    string s, t;
    cin >> s >> t;
    cout << lcs(s, t) << '\n';

    return 0;
}


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

int main(){
    int n;int a[100];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    int max=0;int tmp;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            tmp=abs(a[i]-a[j]);
            if(tmp>=max) max=tmp;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	static long[] dp;
	  
	public static long minCost(long[] arr, int pos){
	  	if(pos<0) return 0;
	    if(dp[pos]!=-1) return dp[pos];
	    return dp[pos] = 
	      Math.min(minCost(arr, pos-1)+Math.abs(arr[Math.max(pos, 0)]-arr[Math.max(pos-1, 0)]),
	               minCost(arr, pos-2)+Math.abs(arr[Math.max(pos, 0)]-arr[Math.max(pos-2, 0)]));
	}
	  
	public static void main(String[] args) throws Exception{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());
	    long[] arr = new long[n];
	    dp = new long[n];
	    String[] str = br.readLine().split(" ");
	    for(int i=0; i<n; i++) {
	    	arr[i] = Long.parseLong(str[i]);
	    	dp[i] = -1;
	    }
		System.out.println(minCost(arr, n-1));
		//for(int i=0; i<n; i++) System.out.print(dp[i]+" ");
	}
}


Measured memory_bytes: 53644
//double太大了精度会丢
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>

typedef long long ll;

const int MAX_M = 200000 + 7;

using namespace std;
ll c[MAX_M];
ll d[MAX_M];

int main(){
    ios::sync_with_stdio(0);

    /*
    int n;
    cin>>n;
    ll Sum = 0,num = 0;
    for(int i = 1;i <= n;++i){
        ll a,b;
        cin>>a>>b;
        Sum += a*b;
        num += b;

    }
    num = num - 1 + (Sum - 1) /9;
    cout<<num<<endl;
    */

    int m;
    cin >> m;
    ll digit_sum=0;
    ll byte = 0;
    for (int i = 1; i <= m; i++){
        ll a, b;
        cin >> a >> b;
        digit_sum += a*b;
        byte += b;
    }
    /*
    int k1 = digit_sum / 9;   
    if(digit_sum % 9 == 0){
        k1--;
    }
    */

    /*
    int k1 = (digit_sum - 1) / 9;
    int k2 = byte - 1;
    */
    byte = byte - 1 + (digit_sum - 1) / 9;
    cout << byte << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; ++i) {
        cout << S[i] << T[i];
    }
    return 0;
}

Measured memory_bytes: 256
def iskaibun(s):
    ans = True
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            ans = False
            break
    return ans




def main():
    S = input()
    N = len(S)

    ans = 'Yes'
    if not iskaibun(S): ans = 'No'
    if not iskaibun(S[:N//2]): ans = 'No'
    if not iskaibun(S[N//2+1:]): ans = 'No'
    print(ans)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064