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

#define ll long long

const int mxN=2e5, mxW=2e4, M=1e9+7;
int n;
ll dp, c, h[mxN];

int qh, qt;
ll a[mxN], b[mxN];
void al(ll ai, ll bi) {
	while(qt-qh>=2&&(b[qt-1]-b[qt-2])/(a[qt-2]-a[qt-1])>=(bi-b[qt-1])/(a[qt-1]-ai))
		--qt;
	a[qt]=ai, b[qt]=bi;
	++qt;
}
ll qry(ll xi) {
	while(qt-qh>=2&&a[qh]*xi+b[qh]>=a[qh+1]*xi+b[qh+1])
		++qh;
	return a[qh]*xi+b[qh];
}

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

	cin >> n >> c;
	for(int i=0; i<n; ++i)
		cin >> h[i];
	for(int i=n-2; i>=0; --i) {
		al(h[i+1], dp+h[i+1]*h[i+1]);
		dp=h[i]*h[i]+c+qry(-2*h[i]);
	}
	cout << dp;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double r;
  cin >> r;
  
  cout << fixed << setprecision(10) << M_PI * r * r << " " << 2 * M_PI * r << '\n';
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int le = 0;
  for (int i = 0; i < n; i++) {
    int a; 
    cin >> a;
    sum += a;
    le = max(le, a);
  }
  
  if (le < sum - le) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}
    


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

const int INF = 1e9;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 1;i < N;i++){
        cin >> a[i];
    }
    vector<vector<int>> dp(N / 2 + 1, vector<int>(2, INF));
    dp[1][0] = 0;
    for(int i = 1;i < N;i++){
        vector<vector<int>> tmp(N / 2 + 1, vector<int>(2, INF));
        dp.swap(tmp);
        for(int j = 0;j <= N / 2;j++){
            dp[j][1] = min(dp[j][1], tmp[j][0] + a[i]);
            dp[j][1] = min(dp[j][1], tmp[j][1]);
            if (j < N / 2) dp[j + 1][0] = min(dp[j + 1][0], tmp[j][0]);
            if (j < N / 2) dp[j + 1][0] = min(dp[j + 1][0], tmp[j][1] + a[i]);
        }
    }
    cout << min(dp[N / 2][0], dp[N / 2][1]) << endl;
    return 0;
}



Measured memory_bytes: 3428
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] Ws = W.split(" ");

		int[] P = new int[N];

		for(int i=0;i<N;i++){
			P[i] = Integer.parseInt(Ws[i]);
		}

		int ans =0;
		int Pj =Integer.MAX_VALUE;
		for(int i=0;i<N;i++){
			if(P[i]<=Pj){
				ans++;
				Pj=P[i];
			}
		}

		System.out.println(ans);



	}


}


Measured memory_bytes: 46164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    int arr[n];

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

    int count1 = 1;

    for(int i=0; i<n-1; i++)
    {
        if(arr[i] > arr[i+1])
        {
            count1++;
        }

        else
        {
            arr[i+1] = arr[i];
        }
    }

    cout << count1;




    return 0;
}


Measured memory_bytes: 4412
#include <stdio.h>
int main(void){
char buf[10000];
char str[10000];
int count = 0;
int i;

fgets(buf, sizeof(buf), stdin);
sscanf(buf, "%s", str);

i = 0;
while(str[i] != '\0') {
    count++;
    i++;
}

if(str[count - 1] == 's') {
    printf("%ses", str);
}

else if(str[count - 1] != 's') {
    printf("%ss", str);
}
    
}


Measured memory_bytes: 2156
(setq *k* (read))
(setq *x* (read))

;与えられた範囲の連続するリストをつくる
(defun get-list (a b)
  (if (< b a)
      nil
      (cons a (get-list (1+ a) b))
      ))

(defun ans (k x)
  (let ((a (- x (1- k))) (b (+ x (1- k))))
       (setq a (max -1000000 a))
       (setq b (min 1000000 b))
       (get-list a b)
  ))

(dolist (l (ans *k* *x*))
  (format t "~a " l))

Measured memory_bytes: 7264
#include<stdio.h>

int main(void){
	int n,i;
	scanf("%d",&n);
	
	int a[n];
	long long int  k;
	scanf("%lld",&k);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int town[n][2],root[n+1];
	
	for(i=0;i<n;i++){
		town[i][0]=0;
	}
	
	for(i=0;;i++){
		if(i==0){
			root[0]=a[0];
			town[root[0]-1][0]=1;
			town[root[0]-1][1]=i+1;
		}else if(i==k){
			printf("%d",root[i-1]);
			return 0;
		}else{
			root[i]=a[root[i-1]-1];
			if(town[root[i]-1][0]==0){
				town[root[i]-1][0]=1;
				town[root[i]-1][1]=i+1;
			}else{
				//printf("break \n");
				break;
			}
		}
		//printf("%d %d\n",i+1,root[i]);
	}
	
	int temp;
	temp=((k-town[root[i]-1][1]))%(i-town[root[i]-1][1]+1)+town[root[i]-1][1];
	//printf("%d %d",town[root[i]-1][1],i-town[root[i]-1][1]+1);
	printf("%d",root[temp-1]);
	return 0;
}

/*for(i=0;;i++){
		if(i==0){
			count[0]=1;
		}
		count[i+1]=a[count[i]-1];
		printf("%d %d %d\n",count[i]-1,a[count[i]-1],count[i+1]);
		if(i==k){
			printf("%d",count[i+1]);
			return 0;
		}
	}
	
	count[0]=count[i+1];*/

Measured memory_bytes: 4640
s = input()
deff = 1
for i in range(len(s)):
  if (i % 2 == 0):
    if s[i] == 'L':
      deff = 0
  else:
    if s[i] == 'R':
      deff = 0
if deff == 1:
  print('Yes')
else:
  print('No')

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

using namespace std;

const int N=1<<5;

char s[N];
bool vis[N];
int n,l,p[N],d[N];

int main()
{
	for(;cin>>n>>l,n;)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%s%d",s,p+i);
			if(s[0]=='L') d[i]=-1; else d[i]=1;
		}

		memset(vis,0,sizeof(vis));
		for(int i=1,cnt=0;;i++)
		{
			for(int j=1;j<=n;j++)
				if(!vis[j]) p[j]+=d[j];
			for(int j=1;j<=n;j++)
				for(int k=j+1;k<=n;k++)
					if(p[j]==p[k]) d[j]=-d[j],d[k]=-d[k];

			int u=-1;
			for(int j=1;j<=n;j++)
				if(!vis[j] && p[j]==l)
					vis[j]=1,cnt++,u=j;

			for(int j=1;j<=n;j++)
				if(!vis[j] && !p[j])
					vis[j]=1,cnt++,u=j;
			if(cnt==n)
			{
				cout<<i<<" "<<u<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3052
using System;
public class Myclass{
    static public void Main (){
        String[] arr = Console.ReadLine().Split();
        int K = int.Parse(arr[0]);
        int X = int.Parse(arr[1]);
        if(K*500 >= X){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }

    }
}

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

int main() {
	vector<pair<ll,ll>> Z;
	
	ll N;
	cin >> N;
	vector<ll> X(N);
	vector<ll> Y(N);
	for (int i = 0;i < N;i++)
		cin >> X[i] >> Y[i];
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			if (X[i] == X[j])
				Z.push_back({ 0,abs(Y[i] - Y[j]) });
			else if (X[i] < X[j])
				Z.push_back({X[j] - X[i],Y[j] - Y[i]});
			else
				Z.push_back({X[i] - X[j],Y[i] - Y[j]});
		}
	}
	sort(Z.begin(), Z.end());
	int zz = Z.size();
	ll cnt = 1, tm = 1;
	for (int i = 1;i < zz;i++) {
		if (Z[i] == Z[i - 1])
			cnt++;
		else
			cnt = 1;
		tm = max(tm, cnt);
	}
	if (N == 1) cout << 1 << endl;
	else cout << N - tm << endl;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int n;
  scanf("%d",&n);

  int tmp;
  for(int i = 0; i < n; ++i){
    scanf("%d",&tmp);
    if(tmp % 2 == 0){
      if(tmp % 3 != 0 && tmp % 5 != 0){
        printf("DENIED");
        return 0;
      }
    }
  }


  printf("APPROVED");

  return 0;
}


Measured memory_bytes: 2148
import sys
import random
import time
import numpy as np

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    m = 26
    start = time.time()
    dT = 0.995
    T = 10000

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [random.randint(0, m-1) for _ in range(D)]
    sc = calc(sche)
    for _ in range(15):
        a = [random.randint(0, m-1) for _ in range(D)]
        nsc = calc(a)
        if sc < nsc:
            sche = a
            sc = nsc
    bestst = sche
    best = sc

    while time.time() - start < 1.8:
        for _ in range(300):
            d = random.randint(0, D-1)
            q = random.randint(0, m-1)
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = sc
            if random.random() < prob(sc, nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])

    return

solve()


Measured memory_bytes: 27748
#include <iostream>
#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 <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;
    cin >> N;
    vector<ll> s(5, 0);
    string ss;
    REP(i, N){
        cin >> ss;
        if (ss[0] == 'M') s[0]++;
        else if (ss[0] == 'A') s[1]++;
        else if (ss[0] == 'R') s[2]++;
        else if (ss[0] == 'C') s[3]++;
        else if (ss[0] == 'H') s[4]++;
    }

    ll ans = 0;
    ans += s[0] * s[1] * (s[2] + s[3] + s[4]);
    ans += s[0] * s[2] * (s[3] + s[4]);
    ans += s[0] * s[3] * s[4];
    ans += s[1] * s[2] * (s[3] + s[4]);
    ans += s[1] * s[3] * s[4];
    ans += s[2] * s[3] * s[4];

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int dp[3005][3005];

void chmax(int& a, int b) {
	a = max(a, b);
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int k = t.size();
	s += '&';
	t += '*';
	rep(i, n + 1)rep(j, k + 1) {
		chmax(dp[i + 1][j], dp[i][j]);
		chmax(dp[i][j + 1], dp[i][j]);
		if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
	}
	string ans;
	int i = n, j = k;
	while (i + j) {
		int x = dp[i][j];
		if (i && dp[i - 1][j] == x) {
			i--;
		}
		else if (j && dp[i][j - 1] == x) {
			j--;
		}
		else {
			i--; j--;
			ans += s[i];
		}
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define ss(s) scanf("%s",&s)
#define pi(n) printf("%d\n",n)
#define pl(n) printf("%lld\n",n)
#define newline cout << endl;
using namespace std;

ll gcd(ll a , ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}

int main(){
  clock_t tStart = clock();
  ll n,k; sl(n); sl(k);
  ll maxi = -1;
  ll ans = 0;
  for(int i=0;i<n;i++){
    ll x; sl(x);
    maxi = max(maxi, x);
    if(i==0) ans = x;
    else ans = gcd(ans,x);
  }
  if(k<=maxi && k%ans==0) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int p, q, a;

int dfs(int n, int d, int prod, int sum){
  int res = 0;
  for(int i = d; prod*i <= a; i++){
    int left = prod*p*i;
    int right = sum*i+prod;
    if(left < right * q) continue;
    if(left == right * q){ res++; continue;}
    if(n == 1) continue;
    res += dfs(n-1, i, prod*i, right);
  }
  return res;
}

int main(){
  int n;
  while(scanf("%d%d%d%d", &p, &q, &a, &n) && p+q+a+n){
    printf("%d\n", dfs(n, 1, 1, 0));
  }
  return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
int main(){
    int N,M,K;
    cin>>N>>M>>K;
    UnionFind tree(N);
    vector<set<int>> dame(N);
    for(int i=0;i<M;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        a--;b--;
        dame[a].insert(b);
        dame[b].insert(a);
        tree.merge(a,b);
    }
    int C[K];
    int D[K];
    for(int i=0;i<K;i++){
        int c,d;
        scanf("%d %d",&c,&d);
        c--;d--;
        if(!tree.issame(c,d))continue;
        dame[c].insert(d);
        dame[d].insert(c);
    }
    
    for(int i=0;i<N;i++){
        int mem = tree.size(i)-1;
        mem -= dame[i].size();
        cout<<mem<<" ";
    }

    cout<<endl;
}

Measured memory_bytes: 24704
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int K;
	Set<Integer> mods;
	int result = -1;

	Main(BufferedReader in) throws IOException {
		K = Integer.parseInt(in.readLine());
		mods = new HashSet<>();
	}

	void calc() {
		int val = 7;
		int count = 1;
		while (true) {
			if (val % K == 0) {
				break;
			}
			val %= K;

			if (mods.contains(val)) {
				count = -1;
				break;
			}
			mods.add(val);
			val *= 10;
			val += 7;
			++count;
		}
		result = count;
	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 91556
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        System.out.println(solve(a, b, c, d, e, k));

        sc.close();
    }

    static String solve(int a, int b, int c, int d, int e, int k) {
        return (e - a <= k) ? "Yay!" : ":(";
    }
}

Measured memory_bytes: 35780
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
 
def do():
    n=INT()
    a=LIST()
    temp=0
    for i in a:
        temp=temp^i
    
    b=[0]*n
    for i in range(n):
        b[i]=a[i]^temp
    print(*b)
    
        
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 31552
import sys
from collections import defaultdict
import collections

sys.setrecursionlimit(1000000)

class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[y] = x


N, M = map(int, input().split())
uf = UnionFindPathCompression(N)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A - 1, B - 1)

hoge = [uf.find(i) for i in range(N)]

#print(hoge)
hogehoge = collections.Counter(hoge).most_common()

print(hogehoge[0][1])


Measured memory_bytes: 51028
#include <iostream>

using namespace std;

int main()
{
   int a, b, c, i;
   for(i=1; i<=3000; i++)
    {
     cin >> a >> b;
     if (a==0 && b==0)
     break;
     if (a > b)
     {
      c = a;
      a = b;
      b = c;
     } 
   cout << a << " " << b << endl; 
    }
   return 0;
}


Measured memory_bytes: 3000
# coding: utf-8

l = [int(input()) for i in range(5)]

sum = 0
div = 10
for i in l:
    if i % 10 != 0:
        sum += i + 10 - (i % 10)
        if i % 10 < div:
            div = i % 10
    else:
        sum += i

if div != 10:
    sum += div - 10

print(sum)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm> 
using namespace std;
int main(){
	int n;
	long x;
	cin>>n>>x;
	int a[n+5];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<n;i++){
		if(x>=a[i]){
			x=x-a[i];	
			sum++;
		}
		
	}
	if(a[n]==x)
		sum++;
	cout<<sum<<endl;
} 

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

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

    int arr[n+1];

    for(int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    int change = 0;

    for(int i = 1; i < n; i++){
        if(arr[i] == arr[i-1]){
            arr[i] = -1;
            change++;
        }
    }

    printf("%d\n", change);

    return 0;
}


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

using namespace std;

int main(void) {

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(),greater<int>());

	if (s < t)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;
using GRAPH = vector<vector<int>>;

int main() {
	int n, q, a, b;
	cin >> n >> q;

	GRAPH g(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	int p, y;
	vector<int> x(n, 0), ans(n, 0);
	for (int i = 0; i < q; i++) {
		cin >> p >> y;
		p--;
		x[p] += y;
	}

	vector<bool> visited(n, false);
	queue<int> que;
	que.push(0);

	while (!que.empty()) {
		auto node = que.front();
		que.pop();

		if (visited[node]) {
			continue;
		}

		visited[node] = true;
		int add = x[node];
		ans[node] += add;

		for (auto z: g[node]) {
			if (visited[z]) {
				continue;
			}

			que.push(z);
			x[z] += add;
		}
	}

	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 16372
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){
  std::string s;
  std::cin >> s;

  if(s=="ARC") std::cout << "ABC" << std::endl;
  else         std::cout << "ARC" << std::endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll dp[1010][1010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vll x(n + 1), y(n + 1), z(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = 0;
    for (int a = 0; a < (1 << 3); a++) {
        int xs = a & 1 ? 1 : -1;
        int ys = a & 2 ? 1 : -1;
        int zs = a & 4 ? 1 : -1;
        vll sums(n);
        for (int i = 1; i <= n; i++) {
            ll sum = x[i] * xs + y[i] * ys + z[i] * zs;
            sums[i - 1] = sum;
        }
        sort(sums.begin(), sums.end(), greater<ll>());
        ll total = 0;
        for (int i = 0; i < m; i++) {
            total += sums[i];
        }
        ans = max(ans, total);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int x;
	int zh(string s);
	cin>>a>>b;
	x=zh(a+b);
	if(int(sqrt(x))==sqrt(x))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}
int zh(string s)
{
	int tmp=0;
	for(int i=0;i<s.size();i++)
	tmp=tmp*10+(s[i]-'0');
	return tmp;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

x = a[0]
y = sum(a[1:])
ans = abs(x - y)
for i in range(1, n-1):
   x += a[i]
   y -= a[i]
   ans = min(abs(x-y), ans)
print(ans)


Measured memory_bytes: 30592
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
constexpr int D = 365, n = 26;
int c[n]/*dec sc*/, s[D][n]/*inc_sc*/, ans = 0;
int last[D][n], held[D]; 
random_device seed;
mt19937 rnd(seed());
clock_t start;
inline void init()
{
	scanf("%*d");
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &c[i]);
	}
	for(int i = 0; i < D; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			scanf("%d", &s[i][j]);
		}
	}
	for(int i = 0; i < D; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			last[i][j] = -1;
		}
		held[i] = rnd() % n; 
	}
}
inline void score()
{
	for(int i = 0; i < D; ++i)
	{
		last[i][held[i]] = i;
		ans += s[i][held[i]];
		for(int j = 0; j < n; ++j)
		{
			ans -= c[j] * (i - last[i][j]);
		}
	}
}
void local_search()
{
	for(int d, t, _ans = ans; (clock() - start) * 10 < 19 * CLOCKS_PER_SEC; )
	{
		d = rnd() % D;
		t = rnd() % n;
	}		
}
inline void output()
{
	for(int i = 0; i < D; ++i)
	{
		printf("%d\n", held[i] + 1);
	}
}
signed main()
{
	start = clock();
	init();
	score();
	local_search();
	output();
}


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

int main() {
	int n, x, count;
	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		count = 0;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				for (int k = j + 1; k <= n; k++)
					if (i + j + k == x) count++;
		cout << count << endl;
	}
}

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

bool is_palindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end()); // tを左右逆にする
  return s == t; // 左右逆にしたものと等しければ回文
}

int main() {
  string s;
  cin >> s;
  if (is_palindrome(s) and is_palindrome(s.substr(0, s.size()/2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  vector<int> v(3);
  for (auto &e : v) cin >> e;

  sort(v.begin(), v.end(), [](int a, int b) { return a > b; });

  cout << v[0] * 10 + v[1] + v[2] << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (v.empty() ? 0 : v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define fi first
#define se second
#define pb push_back
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 500005
const int INF = 1e18;
typedef pair<int, int> pii;

signed main() {
    boostIO;
    string s;
    cin >> s;
    if(s[0] == 'R' and s[1] == 'R' and s[2] == 'R'){
        cout << "3\n";
    }
    else if((s[0] == 'R' and s[1] == 'R' and s[2] == 'S') or (s[0] == 'S' and s[1] == 'R' and s[2] == 'R')){
        cout << "2\n";
    }
    else if(s[0] == 'S' and s[1] == 'S' and s[2] == 'S'){
        cout << "0\n";
    }
    else{
        cout << "1\n";
    }
    return 0;
}
// XD

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
    int i, j, a[3], tmp;

    scanf("%d %d %d",&a[0],&a[1],&a[2]); 

    for (i=0; i<2; i++) {
        for (j=0; j<2; j++) {
            if(a[j] >= a[j+1])
            {
                tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
            }
        }
    }
    printf("%d %d %d\n", a[0], a[1], a[2]);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define fio(s) freopen(s".inp","r",stdin)
#define foo(s) freopen(s".out","w",stdout)
#define task "test"
using namespace std;
typedef long long LL;
const LL N=100009,OO=1e9+7;
LL n,f[N][3],a[N][3],ans;
int main(){
    //fio(task); foo(task);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    For(i,1,n)
        For(j,0,2) cin>>a[i][j];
    For(j,0,2) f[1][j]=a[1][j];
    For(i,2,n)
        For(j,0,2){
            f[i][j]=0;
            For(k,0,2)
                if(k!=j) f[i][j]=max(f[i][j],f[i-1][k]+a[i][j]);
        }
    For(j,0,2) ans=max(ans,f[n][j]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int n,I,IO,IOI,cnt;
char ch;

int main(){
  while(scanf("%c",&ch)!=EOF){
    if(ch=='J')I++;
    else if(ch=='O'){
      if(I)I--,IO++;
      else if(IOI)IOI--,IO+=2,cnt+=2;
    }else if(ch=='I'){
      if(IO)IO--,cnt=min(cnt,IO),IOI++;
      else I++;
    }
  }
  cout<<IOI+cnt/2<<endl;
  return 0;
}

Measured memory_bytes: 1160
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]
end

[<EntryPoint>]
let main _ =
    let sc = Scanner()
    let n = sc.NextI32()
    let y = sc.NextI32()

    let res = seq {
        for i in 0 .. n do
            for j in 0 .. n - i do
                let k = n - i - j
                if i * 10000 + j * 5000 + k * 1000 = y then yield (i, j, k)
    }
    if Seq.exists(fun (t, g, s) -> t >= 0 && g >= 0 && s >= 0) res then
        let a, b, c = Seq.head res
        printfn "%d %d %d" a b c
    else
        printfn "-1 -1 -1"
    0


Measured memory_bytes: 14160
#include <iostream>
using namespace std;
const int MAX = 1000000;

int parent(int i){ return i/2 ;}
int left(int i){return 2*i;}
int right(int i){return 2*i +1;}

int main(){
    int H,i,A[MAX+1];
    cin >> H;
    for (int i = 1; i <= H ; ++i) {
        cin >> A[i];
    }
    for (int i = 1; i <= H ; ++i) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << 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;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  int ans = 0;
  rep (i, k) {
    ans += v[i];
  }
  P(ans);


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//namespaces
using namespace __gnu_pbds; 
using namespace std;

//MACROS
#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long 
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Fod(i,s,e) for (int i=(s); i>=(e); i--)
#define pii pair<ll,ll>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define mp make_pair
#define int ll

//debug
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//Templates
template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

//globals
ll const prime1 = 304933;
ll const prime2 = 15486277;
ll const mod = 1e9+7;
ll const inf = 1e18;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE
bool check(int x){
    // cout <<sqrt(x) + 1 << endl;
    for (int i = 2; i < (int)(sqrt(x) + 1); ++i)
    {
        if(x%i == 0) return false;
    }
    // cout <<x  << endl;
    return true;
}
signed main(){
    IOS
    int x;cin >> x;
    while(!check(x)){
        x++;
    }
    cout << x << endl;
    return 0;
}


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

using namespace std;
const int MAXN=10005;
int P=1e9+7,d,len;
char k[MAXN];
long long a[MAXN],dp[10005][105];

long long dfs(int pos,int tot,bool lim)
{
//	cout<<pos<<' '<<tot<<' '<<lim<<endl;
	if(pos==len+1)
	{
		if(tot==0)	return 1;
		return 0;
	} 
	if(!lim&&dp[pos][tot]!=-1) return dp[pos][tot];
	
	long long ret=0 ,  up=lim?a[pos]:9  ;
	
	for(int i=0;i<= up  ;++i)
	{
		ret=(ret+dfs(pos+1,(tot+i)%d, lim&&i==a[pos] ))%P;
		
		//(ret+=dfs(pos+1,(tot+i)%d, lim&&i==a[pos] ) )%=P;
	}
	
	if(!lim) dp[pos][tot]=ret;
	return ret;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%s",k+1);
	scanf("%d",&d);
	len=strlen(k+1);
	for(int i=1;i<=len;++i)
	{
		a[i]=k[i]-'0';
	}
	
	long long ans=(dfs(1,0,1)-1+P)%P;  
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

const auto NMAX = 100000 + 5;
int dp[NMAX][3] = {};

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

    int a[3];
    for (int i = 0; i < N; i++) {
        cin >> a[0] >> a[1] >> a[2];
        for (int j = 0; j < 3; ++j) {
            dp[i + 1][j] = a[j] +
                           max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]);
        }
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
  
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  char a, b, c, d; std::cin >> a >> b >> c >> d;
  a -= '0'; b -= '0'; c -= '0'; d -= '0';
  char op1 = '+', op2 = '+', op3 = '+';
  for(;;) {
    if(a+b+c+d==7) break;
    op3 = '-';
    if(a+b+c-d==7) break;
    op2 = '-';
    if(a+b-c-d==7) break;
    op3 = '+';
    if(a+b-c+d==7) break;
    op1 = '-';
    if(a-b-c+d==7) break;
    op3 = '-';
    if(a-b-c-d==7) break;
    op2 = '+';
    if(a-b+c-d==7) break;
    op3 = '+';
    if(a-b+c+d==7) break;
  }
  a += '0'; b += '0'; c += '0'; d += '0';
  std::cout << a << op1 << b << op2 << c << op3 << d << "=7\n";
  return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
l=[["."]*(b+2)]+[["."]+list(input())+["."] for _ in range(a)]+[["."]*(b+2)]
for i in range(1,a+1,1):
  for j in range(1,b+1,1):
    if l[i][j]!="#":
      l[i][j]=str(sum(l[x][y]=="#" for x in [i-1,i,i+1] for y in [j-1,j,j+1]))
for i in range(1,a+1,1):
  print("".join(l[i][1:-1]))

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

struct P{
  double x, y;
};

int N;
vector<P> p;

double dist(P a, P b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double maxdist(P a){
  double res = 0.0;
  REP(i, N) chmax(res, dist(a, p[i]));
  return res;
}
double f(double x){
  double l = 0.0, r = 4000.0;
  REP(i, 100){
    double c1 = (l*2+r)/3;
    double c2 = (l+r*2)/3;
    if(maxdist((P){x, c1}) > maxdist((P){x, c2})) l = c1;
    else r = c2;
  }
  return maxdist((P){x, l});
}

signed main() {
  cin >> N;
  p = vector<P>(N);
  REP(i, N) cin >> p[i].x >> p[i].y;

  double r = 4000.0;
  double l = 0.0;
  REP(_, 100){
    double c1 = (l*2+r)/3;
    double c2 = (l+r*2)/3;

    if(f(c1) > f(c2)) l = c1;
    else r = c2;
  }

  printf("%.15f\n", f(l));

  return 0;
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  string s;
  cin >> s;	
  
  ll n = s.size();
  bool ok = true;
  
  rep(i, 0, n){	//(1)
    if(s.at(i) != s.at(n-1-i)){
      ok = false;
      break;
    }
  }
  
  if(ok){
    //cout << 2 << endl;
    rep(i,0,n/4){
      if(s.at(i) != s.at(n/2-1-i)){
        ok = false;
        //cout << i << endl;
        break;
      }
    }
  }
  
  if(ok){
    //cout << 3 << endl;
    rep(i,(n+1)/4,n){
      if(s.at(i) != s.at(n-1-i)){
        ok = false;
        break;
      }
    }
  }
  
  cout << ((ok)? "Yes" : "No") << endl;
}

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; ++i)cin>>a[i];
  
  sort(a.begin(), a.end());
  if(n%2==0){
    bool ans=true;
    for(int i=0; i<n; i+=2){
      if(a[i]!=i+1)ans=false;
      if(a[i+1]!=i+1)ans=false;
    }
    if(ans){
      int res=1;
      for(int i=0; i<n/2; ++i){
        res*=2;
        if(res>=1000000007)res-=1000000007;
      }
      cout<<res<<endl;
    }else cout<<0<<endl;
  }else{
    bool ans=true;
    if(a[0]!=0)ans=false;
    for(int i=1; i<n; i+=2){
      if(a[i]!=i+1)ans=false;
      if(a[i+1]!=i+1)ans=false;
    }
    if(ans){
      int res=1;
      for(int i=0; i<n/2; ++i){
        res*=2;
        if(res>=1000000007)res-=1000000007;
      }
      cout<<res<<endl;
    }else cout<<0<<endl;
  }
}


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

int main() {
  int A, B, C; cin >> A >> B >> C;
  int mmax = max(max(A, B), C);
  int sum = A+B+C;
  int ans = 0;
//    cout << "mmax" << mmax << endl;
  while ( sum%3 != 0 || sum/3 < mmax ){
    sum += 2;
    ans++;
 //   cout << sum << endl;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int isprime(int n) {
	int i;
	for(i = 2; i * i <= n; i++) {
		if(n % i == 0) return 0;
	}
	return 1;
}

int main(){
	int n,i,k;
	int max = 2;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i = n;i > 2;i--){
			if(isprime(i)==1 && isprime(i-2)==1){
				max = i;
				break;
			}
		}
		printf("%d %d\n",max-2,max);
		max = 2;
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int[] pasta = new int[3];
		int[] juice = new int[2];
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<pasta.length; i++) pasta[i]=sc.nextInt();
		for(int i=0; i<juice.length; i++) juice[i]=sc.nextInt();
		
		int min=pasta[0]+juice[0]-50;
		for(int i=0; i<pasta.length; i++){
			for(int j=0; j<juice.length; j++){
				if(min>pasta[i]+juice[j]-50)
					min=pasta[i]+juice[j]-50;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 17172
N=int(input())
S_dict={'M':0,'A':0,'R':0,'C':0,'H':0}

for n in range(N):
    S = list(input())[0]
    try:
        S_dict[S]+=1
    except:
        pass
S_dict

from itertools import combinations
ans=0
for c_ in combinations(S_dict.keys(),3):
    ans+=S_dict[c_[0]]*S_dict[c_[1]]*S_dict[c_[2]]
print(ans)

Measured memory_bytes: 74680
using Base.Collections
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	P=PriorityQueue(Int,Int)
	id=0
	for a=map(x->parse(Int,x),split(readline()))
		P[id+=1]=-a
	end
	for _=1:M
		id,a=peek(P)
		dequeue!(P)
		P[id]=-((-a)>>1)
	end
	ans=0
	while !isempty(P)
		id,a=peek(P)
		ans-=a
		dequeue!(P)
	end
	println(ans)
end
main()

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

namespace abc144_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadInt();
      var b = CIn.ReadInt();
      var x = CIn.ReadInt();

      if (x <= (double)(a * a * b) / 2)
      {
        var rad = Math.Atan((double)(a * b * b) / (2 * x));
        Console.WriteLine(rad * 180 / Math.PI);
      }
      else
      {
        var rad = Math.Atan2(2 * b - (double)(2 * x) / a / a, a);
        Console.WriteLine(rad * 180 / Math.PI);
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 11220
l = "abcdefghij"


def dfs(a, mx):
    if len(a) == n:
        print(a)
        return
    for i, s in enumerate(l):
        if i == mx+1:
            dfs(a+s, mx+1)
            break
        else:
            dfs(a+s, mx)


n = int(input())
dfs("a", 0)


Measured memory_bytes: 4340
def partition(array, p, r)
  x = array[r]
  i = p - 1
  (p..r-1).each do |index|
    if (array[index] <= x) then
      i += 1
      array[i], array[index] = array[index], array[i]
    end
  end
  array[i+1], array[r] = array[r], array[i+1]
  return i+1
end

n = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
pivot = array[n-1]
partition(array, 0, n-1)

found = false
array = array.reverse.map do |item|
  if (!found && item == pivot) then
    found = true
    "[#{item}]"
  else
    item.to_s
  end
end
puts array.reverse.join(' ')

Measured memory_bytes: 24224
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

vector <int> edges[10000];
int incoming[10000];
bool used[10000];
vector <int> order;

void dfs(int cur){
    used[cur] = true;
    for(int i = 0; i < edges[cur].size(); i++){
        if(!used[edges[cur][i]]){
            dfs(edges[cur][i]);
        }
    }
    order.push_back(cur);
    return;
}

int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int s;
        int t;
        cin >> s >> t;
        edges[s].push_back(t);
        incoming[t] ++;
    }
    vector <int> sources;
    for(int i = 0; i < N; i++){
        if(incoming[i] == 0){
            sources.push_back(i);
        }
    }
    for(int i = 0; i < sources.size(); i++){
        dfs(sources[i]);
    }

    for(int i = 0; i < N; i++){
        cout << order[N - 1 - i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string s;
  cin >> s;
  int ans =0;
  rep(i,s.size()){
    if(s[i] == '+')ans++;
    else ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int [N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		int min = A[N-1]-A[0];
		for(int j=1;j<N;j++) {
			min = Math.min(min, K-A[j]+A[j-1]);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 78680
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;
int f[100006];
ll dp[100006];
int main() {
	ll n, m,a,b=-2;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		f[a] = 1;
		if (b + 1 == a) {
			cout << 0 << endl;
			return 0;
		}
		else {
			b = a;
		}
	}
	dp[0] = 1;
	if (f[1] == 0)dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (f[i] == 0)dp[i] = (dp[i - 1] + dp[i - 2])%1000000007;
	}
	cout << dp[n]%1000000007 << endl;
	return 0;
}

Measured memory_bytes: 1408
N,A,B=[int(i) for i in input().split(" ")]
delta=abs(A-B)
if delta%2==0:
    print(delta//2)
else:
    #use1
    use1=A+(B-A-1)//2
    useN=N-B+1+(delta-1)//2
    print(min(use1,useN))


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

int main(){
   string s;
   cin>>s;
   int tot=0;
   for(int i=0;i<s.size()/2;++i){
       if(s[i]!=s[s.size()-i-1]) tot+=1;
   }
   cout << tot <<endl;
}

Measured memory_bytes: 256