akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=100005;

vi adj[N+1];
int dp[N+1][2];

void dfs(int u,int p)
{
dp[u][0]=1;
dp[u][1]=1;
for(int v:adj[u])
{
    if(v!=p)
    {
        dfs(v,u);
        dp[u][0]=(dp[u][0]*(dp[v][0]+dp[v][1])%hell)%hell;
        dp[u][1]=(dp[u][1]*dp[v][0])%hell;
    }
}



}

    
void solve()
{
int n;
cin>>n;
int u,v;
for(int i=0;i<n-1;i++)
{
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
}
dfs(1,0);
cout<<(dp[1][0]+dp[1][1])%hell<<endl;
}

int32_t main()
{
    //IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 17364
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  int k = 1;
  while (k <= n) {
    k *= 2;
  }
  cout << k/2 << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
H = np.array(list(map(int, input().split())))

counter=0
while(len(H[H>0]) >0):
  starti=0
  endi=0
  for i in range(N):
    if H[i]>0:
      starti=i
      break
  for i in range(starti, N):
    if H[i]>0:
      endi=i
    else:
      break
  H[starti:endi+1]-=1
  counter+=1
  
print(counter)





Measured memory_bytes: 12508
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        StringBuilder ret = new StringBuilder();
        
    	for (char c : line.toCharArray()) {
			if(c >= 'A' && c <= 'Z') {
				ret.append((char)(c + 32));
			} else if(c >= 'a' && c <= 'z') {
				ret.append((char)(c - 32));
			} else {
			    ret.append(c);
			}
		}

        System.out.println(ret.toString());
    }
}




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

#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int, int> pr;

int n, m;
const int maxn = 5e5 + 5;
struct node{
    int l, r, id, ans;
}q[maxn];
int neck[maxn];
int sum[maxn << 2];
const int maxnum = 1e6 + 5;
int pos[maxnum];

bool cmp(node a, node b)
{
    return a.r < b.r;
}

bool cmp1(node a, node b)
{
    return a.id < b.id;
}


void add(int rt, int val)
{
    while(rt <= n){
        sum[rt] += val;
        rt += (rt & -rt);
    }
}

int query(int rt)
{
    int ans = 0;
    while(rt){
        ans += sum[rt];
        rt -= (rt & -rt);
    }
    return ans;
}

int main()
{

    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++){
        scanf("%d", &neck[i]);
    }
    for(int i = 0; i < m; i++){
        scanf("%d%d", &q[i].l, &q[i].r);
        q[i].id = i;
    }
    sort(q, q + m, cmp);

    int nxt = 1;
    for(int i = 0; i < m; i++){
        int r = q[i].r;
        for(int j = nxt; j <= r; j++){
            if(pos[neck[j]]){
                add(pos[neck[j]], -1);
            }
            add(j, 1);
            pos[neck[j]] = j;
        }
        nxt = r + 1;
        q[i].ans = query(q[i].r) - query(q[i].l - 1);
    }
    sort(q, q + m, cmp1);
    for(int i = 0; i < m; i++){
        printf("%d\n", q[i].ans);
    }
    return 0;
}

Measured memory_bytes: 17408
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


}





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

class aizu_judge
{
    static void Main()
    {
        while(true)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            
            if (n == 0)
                break;

            List<string[]> cnvList = new List<string[]>();

            for(int i = 0; i < n; i++)
            {
                cnvList.Add(Console.ReadLine().Split());
            }

            int n2 = Convert.ToInt32(Console.ReadLine());

            StringBuilder sb = new StringBuilder();

            for(int j = 0;j < n2;j++)
            {
                string chr = Console.ReadLine();

                foreach(string[] cnv in cnvList )
                {
                    if(chr.Equals(cnv[0]))
                    {
                        chr = cnv[1];
                        break;
                    }
                }
                sb.Append(chr);
            }
            Console.WriteLine(sb.ToString());
            
        }
    }
}

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

int main() {
        int n;
        cin >> n;
        string s;
        cin >> s;
        rep(i, s.size()) {
                cout << (char) ('A' + ((s[i] - 'A' + n) % 26));
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353
ll fun(vi &a,ll index,ll sum,bool selected,vector <vv> &dp)
{
    ll n=a.size();
    if(sum<0)
        return 0;
    if(sum==0)
        return index+2;
    if(index==0)
    {
        if(a[0]==sum)
            return 1;
        return 0;
    }
    if(selected)
    {
        if(dp[index][sum][1]!=-1)
            return dp[index][sum][1];
        dp[index][sum][1]=fun(a,index-1,sum,true,dp)+fun(a,index-1,sum-a[index],true,dp);
        dp[index][sum][1]%=modulo;
        return dp[index][sum][1];
    }
    else
    {
        if(dp[index][sum][0]!=-1)
            return dp[index][sum][0];
        dp[index][sum][0]=fun(a,index-1,sum,false,dp)+(fun(a,index-1,sum-a[index],true,dp)*(n-index))%modulo;
        dp[index][sum][0]%=modulo;
        return dp[index][sum][0];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,s;
    cin>>n>>s;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    vector <vv> dp(n,vv (3001,vi(2,-1)));
    ans=fun(a,n-1,s,false,dp);
    cout<<ans<<"\n";
}


Measured memory_bytes: 495232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    clock_t start = clock();
    int N; cin >> N;
    string s; int p[101];
    vector<pair<pair<string,int>,int>> vp(0);
    if(N == 1){
        int t;
        cin >> s >> t;
        cout << 1 << endl;
        return 0;
    }


    for(int i = 0; i < N; i++){
        cin >> s >> p[i];
        vp.push_back(make_pair(make_pair(s,(-1)*p[i]),i+1));
    }
    sort(vp.begin(),vp.end());
    for(int i = 0; i < N; i++){
        cout << vp[i].second << endl;
    }
}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut written = HashSet::new();
    for _ in 0..n {
        let num = read::<i64>();
        if written.contains(&num) {
            written.remove(&num);
        } else {
            written.insert(num);
        }
    }
    println!("{}", written.len());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

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

  //まずはいちばん上のふち
  for(int i = 0 ; i < W + 2 ; ++i){
    cout << "#";
  }
  cout << endl;

  //中身
  for(int i = 0 ; i < H ; ++i){
    cin >> str;
    cout << "#" << str << "#" << endl;
  }

  //いちばん下のふち
  for(int i = 0 ; i < W + 2 ; ++i){
    cout << "#";
  }
  cout << endl;

}


Measured memory_bytes: 256
#ABC170c

p = []
x, n = map(int, input().split())
p = list(map(int, input().split()))

ans = 999
min = 999

if x not in p:
    ans = x
else:
    i = 1
    while min == 999:
        if x+i in p:
            i += 1
        else:
            min = i
            ans = x + i

    j = min
    while j != 0:
        if x-j not in p:
            ans = x - j
            j -= 1
        else:
            j -= 1

print(ans)


Measured memory_bytes: 9204
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979311600
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int q=2e5+5;
#define x first
#define y second
const int INF = 1e9;

void done() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n+1);
    for(int i =1;i <= n;i++) {
        cin >> a[i];
    }
    vector<int>pos;
    int ok = 0;
    for(int i =2;i < n;i++) {
        if(a[i] > a[i-1] && a[i] > a[i+1])pos.push_back(i);
    }
    int cnt = 0, d = 1, ans = 1;
    for(int i=0, j=0;i < pos.size();i++) {

        int q = pos[i];
        while((pos[j]-q)+2 <= k && j < pos.size()) {
            j++;
        }
        if(j-i > d) {
            ans = pos[i]-1;
            cnt = j-i+1;
            d = j-i;
            ok = 1;
        }
    }
    cout << cnt << " " << ans << '\n';

}
void solve() {
    int n, m;
    cin >> n >> m;
    int k;cin >> k;
    char a[n][m];
    int cnt = 0;
    for(int i=0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cin >> a[i][j];
            if(a[i][j]=='#')cnt++;
        }
    }
    int ave = cnt-k;
    if(ave < 0) {
        cout << 0 << '\n';
        return;
    }
    if(ave==0) {
        cout << 1 << '\n';
        return;
    }





}
void another() {
    int n, m, k;
    cin >> n >> m >> k;
    string s[6];
    for(int i=0;i < n;i++) {
        cin >> s[i];
    }
    int cnt =0;
    for(int i=0;i < (1 << n);i++) {
        for(int j = 0;j < (1 << m);j++) {
            int d = 0;
            for(int r = 0;r < n;r++) {
                for(int l = 0;l < m;l++) {
                    if((i >> r)& 1 && (j >> l) & 1 && s[r][l]=='#')d++;
                }

            }
            if(d==k)cnt++;
        }
    }
    cout << cnt << '\n';

}
void test_case() {
    int t;
    cin >> t;
    while( t--)done();
}
int main() {

     fast;
    another();

}



Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=16005;
bool ok[nmax],ne[nmax];
bool ans;
string s;
int v[nmax];
int n,i,j,idx,x,y,nr;
void ruc(int val)
{
    for(idx=0;idx<=2*n;idx++)
         ne[idx]=0;
    for(idx=0;idx<=2*n;idx++)
        if(ok[idx])
    {
        if(idx-val>=0) ne[idx-val]=1;
        if(idx+val<=2*n) ne[idx+val]=1;
    }
    for(idx=0;idx<=2*n;idx++)
        ok[idx]=ne[idx];
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>s;
    cin>>x>>y;
    ans=1;
    n=s.size();
    nr=1;
    for(i=0;i<n;i++)
    {
        if(s[i]=='T') ++nr;
        else v[nr]++;
    }
    for(i=0;i<=2*n;i++)
        ok[i]=ne[i]=0;
    ok[n+v[1]]=1;
    for(i=3;i<=nr;i+=2)
        ruc(v[i]);
    ans&=ok[n+x];
    for(i=0;i<=2*n;i++)
        ok[i]=ne[i]=0;
    ok[n]=1;
    for(i=2;i<=nr;i+=2)
        ruc(v[i]);
    ans&=ok[n+y];
    if(ans) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Solution().solve(in, out);
		out.close();
	}

	static class Solution {
		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long[] a = new long[n];
			long[] b = new long[n];
			for (int i = 0; i < n; ++i) {
				a[i] = nextLong(in);
				b[i] = nextLong(in);
			}
			if (n % 2 == 1) {
				Arrays.sort(a);
				Arrays.sort(b);
				out.println(b[n / 2] - a[n / 2] + 1);
			} else {
				Arrays.sort(a);
				Arrays.sort(b);
				out.println((b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1);
			}
		}

		private long nextLong(InputReader in) {
			return Long.parseLong(in.next());
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException();
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 51036
S = input()
if len(S) % 2 != 0:
  print("No")
else:
  N = len(S)
  p = 0
  for i in range(0, N, 2):
    if S[i:i+2] != 'hi':
      p += 1
  if p == 0:
    print("Yes")
  else:
    print("No")

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A > B) swap(A, B);
  int diff = B - A;
  if (diff % 2 == 0) {
    cout << A + diff / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
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 M = sc.nextInt();
		int As[] = new int[A];
		int Bs[] = new int[B];
		for(int i = 0 ; i < As.length ; ++i){
			As[i] = sc.nextInt();
		}
		for(int i = 0 ; i < Bs.length ; ++i){
			Bs[i] = sc.nextInt();
		}
		int ret = As[0] + Bs[0];
		for(int i = 0 ; i < M ; ++i){
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			int c = sc.nextInt();
			int v = As[x] + Bs[y] - c;
			ret = Math.min(ret, v);
		}
		Arrays.sort(As);
		Arrays.sort(Bs);
		ret = Math.min(ret, As[0] + Bs[0]);
		System.out.println(ret);
	}
}


Measured memory_bytes: 152548
S = input()
lost = 0
win = 0
for i in S:
    if i == "x":
        lost +=1
    else:
        win += 1

if lost >= 8:
    print("NO")
else:
    if 15 - len(S) + win >= 8:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 2940
#include <stdio.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

int n, m;
char f[16][16];
int g[32][16][16];

bool completed(int (*g)[16]) {
    rep (i, n) rep (j, m) if (g[i][j] != g[0][0]) return false;
    return true;
}

void rec(int (*g)[16], int x, int y, int from, int to) {
    if (g[x][y] != from) return ;
    g[x][y] = to;
    if (x > 0) rec(g, x-1, y, from, to);
    if (x < n-1) rec(g, x+1, y, from, to);
    if (y > 0) rec(g, x, y-1, from, to);
    if (y < m-1) rec(g, x, y+1, from, to);
}

bool iddfs(int dep, int cur) {
    if (dep == cur) return completed(g[cur]);
    rep (k, 3) if (k != g[cur][0][0]) {
        rep (i, n) rep (j, m) g[cur+1][i][j] = g[cur][i][j];
        rec(g[cur+1], 0, 0, g[cur][0][0], k);
        if (iddfs(dep, cur+1)) return true;
    }
    return false;
}

int solve() {
    rep (i, n) rep(j, m) {
        if (f[i][j] == 'R') g[0][i][j] = 0;
        if (f[i][j] == 'G') g[0][i][j] = 1;
        if (f[i][j] == 'B') g[0][i][j] = 2;
    }
    rep (i, 32) if (iddfs(i, 0)) return i;
    assert(false);
    return -1;
}

int main() {
    for (;;) {
        scanf("%d%d", &m, &n);
        if (n == 0 && m == 0) return 0;
        rep (i, n) rep (j, m) scanf(" %c", f[i]+j);
        printf("%d\n", solve());
    }
}

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

int main(void){
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int n = stoi(c);
    int nn = sqrt(n);
    if((nn*nn)==n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;

namespace abc066_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int i;
            for (i = s.Length / 2 - 1; s.Substring(0, i) != s.Substring(i, i); i--) ;
            Console.WriteLine(i * 2);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
#include <set>
#include <deque>
using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MAGIC_PRIME{ 1000000000 + 7 };
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> w(n);
    for (int& x : w)
        cin >> x;

    vector<int> ww(n + 1);

    for (int i = 0; i < n; i++) {
        ww[i + 1] = w[i] + ww[i];
    }

    int min_diff = INF;
    for (int i = 1; i < n; i++) {
        const int diff = abs((ww[i] - ww[0]) - (ww[n] - ww[i]));
        min_diff = min(diff, min_diff);
    }

    cout << min_diff << endl;

}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
long long int mod = 1e9 + 7;

int main(){
  cin >> n;
  long long int ans = 1;
  REP(i,n){
    ans = ans * (long long int) (i+1);
    ans = ans % mod;
    //cout << mod << endl;
    //cout << ans << " " << i << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// AOJ ITP1_11_A Dice I
// 2018.4.29 bal4u
 
#include <stdio.h>
 
int rot[5][7] = {
{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];      // サイコロの1～6の各面に割り当てる数字
int tr['Z'];
 
void dice_init(int *a)
{
    int i;
    int t[5] = {0,'N','E','W','S'};
    for (i = 1; i <= 6; i++) assign[i] = a[i];
    for (i = 1; i <= 4; i++) tr[t[i]] = i;
}
 
char s[102];
int main()
{
    int i, k1, k2;
    int a[7], dice[2][7];
    char *p;
 
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    dice_init(a);
    scanf("%s", p=s);
    for (i = 1; i <= 6; i++) dice[0][i] = rot[0][i];
    for (k1 = 0, k2 = 1; *p; k1 = k2, k2 = !k2) {
        for (i = 1; i <= 6; i++) dice[k2][i] = dice[k1][rot[tr[*p]][i]];
        p++;
    }
    printf("%d\n", assign[dice[k1][1]]);
    return 0;
}


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

int main(){
  ll n;
  cin>>n;
  vector<int> v(n-1);
  rep(i,n-1){
    cin>>v.at(i);
  }
  v.push_back(1e5+1);
  vector<int> a(n);
  a.at(0) = v.at(0);
  
  for (int i = 1; i<n;i++){
    int minnum= min(v.at(i),v.at(i-1));
    a.at(i) = minnum;
  }
  int sum=0;
  rep(i,n){
    sum+=a.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

string pad0(int A, int B) // 自然数 A を B 桁にする '0' からなる文字列
{
  string S;
  int N = log10(A) + 1;
  for (int i = 0; i < B - N; i++) S += '0';
  return S;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<vector<int>> PY(N + 1);
  for (int i = 0; i < M; i++)
  {
    cin >> P.at(i) >> Y.at(i);
    PY.at( P.at(i) ).push_back( Y.at(i) );
  }
  
  for (int i = 0; i < N + 1; i++)
  {
    sort(PY.at(i).begin(), PY.at(i).end());
  }
     
  for (int i = 0; i < M; i++)
  {
    auto it = lower_bound
      (PY.at( P.at(i) ).begin(), PY.at( P.at(i) ).end(), Y.at(i));
    int j = it - PY.at( P.at(i) ).begin() + 1;
    cout << pad0(P.at(i), 6) << P.at(i) 
      << pad0(j, 6) << j << endl;
  }
}

Measured memory_bytes: 7808
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string s;
    cin >> s;
    int cnt1 = 0,cnt2 = 0;
    rep(i,s.size()){
      //cout << s[i]<<endl;
        if(i%2 == 0){
          //cout <<"even";
            if(s[i] == '0')cnt1++;
            if(s[i] == '1')cnt2++;
        }
        else{
            if(s[i] == '1')cnt1++;
            if(s[i] == '0')cnt2++;
        }
      //cout << cnt1 << " " << cnt2 << endl;
    }
    cout << min(cnt1,cnt2)<<endl;
}

Measured memory_bytes: 512
q = int(input())
A = []
for i in range(q):
    query = [int(i) for i in input().split()]
    if query[0] == 0:
        A.append(query[1])
    elif query[0] == 1:
        print(A[query[1]])
    elif query[0] == 2:
        A.pop(len(A)-1)



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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 998244353;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    int SUM = 0;
    int tempsum = 0;
    vector<int> m(N);
    vector<int> s(N);
    vector<PII> plus;
    vector<PII> minus;
    vector<bool> used(N);
    REP(i,N){
        string S; cin >> S;
        int n = S.length();
        int sum = 0;
        int mini = 0;
        REP(k,n){
            if (S[k] == '(') sum++;
            else sum--;
            chmin(mini,sum);
        }

        tempsum += sum;
        if (sum >= 0) plus.push_back(MP(-mini,sum));
        else minus.push_back(MP(-mini+sum,-sum));
    }

    if (tempsum != 0){
        puts("No");
        return 0;
    }

    sort(ALL(plus));
    sort(ALL(minus));

    REP(i,plus.size()){
        int m = plus[i].first;
        int s = plus[i].second;
        if (SUM - m < 0){
            puts("No");
            return 0;
        }
        SUM += s;
    }
    int x;
    x = SUM;
    SUM = 0;
    REP(i,minus.size()){
        int ms = minus[i].first;
        int s = minus[i].second;
        if (SUM - ms < 0){
            puts("No");
            return 0;
        }
        SUM += s;
    }
    if (x == SUM) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    int e=0,w=0,s=0,n=0;
    cin>>str;
    int siz=str.size();
    for(int i = 0; i<siz; i++)
    {
        if(str[i]=='E')
            ++e;
        else if(str[i]=='W')
            ++w;
        else if(str[i]=='S')
            ++s;
        else if(str[i])
            ++n;
    }
    bool f=true;;
    if(min(s,n)==0&&max(s,n)!=0) f = false;
    if(min(e,w)==0&&max(e,w)!=0) f = false;
    if(f)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3572
import math
a,b,c = map(float,raw_input().split())
print "%.8f" %float(a*b*math.sin(math.radians(c))/2)
print "%.8f" %float(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c))))
print "%.8f" %float(b*math.sin(math.radians(c)))

Measured memory_bytes: 6624
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n;
int p[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  return true;
}

int q[maxn];
int d[maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    q[p[i]] = i;
  }
  d[0] = 1;
  int res = n - 1;
  for (int i = 1; i < n; i++) {
    if (q[i - 1] < q[i]) {
      d[i] = d[i - 1] + 1;
    } else {
      d[i] = 1;
    }
    res = min(res, n - d[i]);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    int m, k;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        m = int.Parse(input[0]);
        k = int.Parse(input[1]);
        int b = (int)Math.Pow(2, m);
        if (k >= b)
        {
            Console.WriteLine(-1);
            return;
        }
      	if (m == 1 && k == 1){
          	Console.WriteLine(-1);
            return;
        }
        if (k == 0)
        {
            for (int i = 0; i < b; i++)
            {
                Console.Write(i + " " + i + " ");
            }
            return;
        }

        int c = 0;
        int[] x = new int[b];
        int[] y = new int[b];
        bool[] z = new bool[b];
        z[0] = true;
        z[k] = true;

        for (int i = 1; i < b; i++)
        {
            if (!z[i])
            {
                z[i] = true;
                z[k ^ i] = true;

                x[c] = i;
                y[c] = k ^ i;

                c++;
            }
        }
        for (int i = 0; i < c; i++)
        {
            Console.Write(x[i] + " ");
        }
        Console.Write(0 + " ");
        Console.Write(k + " ");
        for (int i = 0; i < c; i++)
        {
            Console.Write(x[c - 1 - i] + " ");
        }
        for (int i = 0; i < c; i++)
        {
            Console.Write(y[i] + " ");
        }
        Console.Write(k + " ");
        Console.Write(0 + " ");
        for (int i = 0; i < c; i++)
        {
            Console.Write(y[c - 1 - i] + " ");
        }




    }


    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 17740
#include <stdio.h>

int main(void)
{
	int n, i, j, k;
	int b, f, r, v;
	int num[4][3][10] = {0};
	scanf("%d", &n);

	while(n>0){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		num[b-1][f-1][r-1] += v;
		n--;
	}
	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k<10; k++){
				printf(" %d", num[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)
			printf("####################\n");
	}
	return 0;
}

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

using namespace std;

void dfs(int u, int h, const vector<vector<int>> &g, vector<int> &vis,
            vector<vector<int>> &lvl) {
    vis[u] = 1;
    lvl[h].push_back(u);
    for (int v : g[u]) {
        if (!vis[v]) {
            dfs(v, h + 1, g, vis, lvl);
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<vector<int>> g(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }
    vector<int> c(N);
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
    }
    sort(begin(c), end(c));
    vector<vector<int>> lvl(N);
    vector<int> vis(N, 0);
    dfs(0, 0, g, vis, lvl);
    vector<int> d(N);
    for (int i = N - 1, j = 0; i >= 0; --i) {
        for (int u : lvl[i]) {
            d[u] = c[j++];
        }
    }
    cout << accumulate(begin(c), begin(c) + N - 1, 0LL) << "\n";
    for (int x : d) {
        cout << x << " ";
    }
    cout << "\n";

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> a(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  long long ans = 0;
  ans += max((long long) 0, a[0] - x);
  a[0] -= ans;
  for(int i = 1; i < n; i++)
  {
    long long sum = a[i] + a[i - 1];
    if(sum > x)
    {
      ans += sum - x;
      a[i] -= sum - x;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-03 17:35:02
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
#define y1 gfvtydvtd
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, m;
    cin >> n >> m;
    if (n == 1 || m == 1) {
        cout << 1 << "\n";
        return 0;
    }
    cout << (n + 1) / 2 * ((m + 1) / 2) + (n / 2) * (m  / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX=100;
const int INFTY=(1<<21);
const int WHITE=0;
const int GRAY=1;
const int BLACK=2;

int M[MAX][MAX];
int n;

int prim(){
    int u,minv;
    int color[MAX],d[MAX],p[MAX];

    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }

    d[0]=0;

    while(true){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i] and color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK and M[u][v]!=INFTY){
                if (d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1)sum+=M[i][p[i]];
    }

    return sum;
}

int main()
{
    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e; cin>>e;
            M[i][j]= (e==-1)? INFTY:e;
        }
    }
    cout<<prim()<<endl;
}


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

int main(){
  int d;
  cin>>d;
  if(d==25){
    cout<<"Christmas"<<endl;
  }else if(d==24){
    cout<<"Christmas Eve"<<endl;
  }else if(d==23){
    cout<<"Christmas Eve Eve"<<endl;
  }else if(d==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}

Measured memory_bytes: 256
S = input()
num=len(S)
ans=""
judge=False
if("keyence" in S):
    judge=True
for i in range(0,num):
    for j in range(i,num):
        ans=S[:i]+S[j:]
        if(ans=="keyence"):
            judge=True
if(judge):
    print("YES")
else:
    print("NO")

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

int main(){
  string S;
  cin >> S;
  int64_t N=S.size();
  vector<int> ans(N,0);
  map<int,int> m;
  int64_t n=0;
  m[0]=1;
  for(int64_t i=1;i<N;i++){
    if(S.at(i)=='R'){
      if(m.count(i%2)){
        m.at(i%2)++;
      }else{
        m[i%2]=1;
      }
    }else{
      if(m.size()>0){
        ans.at(i)++;
        ans.at(i-1)+=m.at((i-1)%2);
        if(m.count(i%2)){
          ans.at(i)+=m.at(i%2);
        }
        m.clear();
        n=i;
      }else{
        if(n%2==i%2){
          ans.at(n)++;
        }else{
          ans.at(n-1)++;
        }
      }
    }
  }
  for(int64_t i=0;i<N;i++){
    cout << ans.at(i);
    if(i==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n, k, x, y;
    scanf("%d%d%d%d", &n, &k, &x, &y);
    int cost = 0;
    for(int i=1; i<=n; i++){
        if(i <= k){
            cost += x;
        }else{
            cost += y;
        }
    }
    printf("%d", cost);
    
    return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        if k != 0:
            count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 37152
void main() {
	auto ip = readAs!(int[]), N = ip[0], X = ip[1];
	auto x = readAs!(int[]).map!(i => i - X).map!(i => i.abs);
	auto c = x[0];
	foreach(i; x[1..$]) {
		if(i%c != 0 && c%i != 0) c = gcd(i, c);
		else if(i%c != 0) c = i;
		//c.writeln;
	}
	c.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4404
using System;

namespace AOJ0060
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] num = input.Split(' ');

                bool[] card = new bool[11];
                for (int i = 1; i <= 10; i++)
                {
                    card[i] = true;
                }
                for (int i = 0; i < num.Length; i++)
                {
                    card[int.Parse(num[i])] = false;
                }

                int mycard = int.Parse(num[0]) + int.Parse(num[1]);
                int count = 0;
                for (int i = 1; i <= 10; i++)
                {
                    if (card[i])
                    {
                        
                        if (mycard + i <= 20)
                        {
                            count++;
                        }
                    }
                }

                if (count * 100 / 7 >= 50)
                {
                    Console.WriteLine("YES");
                } else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 8884
#include<bits/stdc++.h>
using namespace std;
const int maxm = 333;
int m;
int f[maxm];

int main()
{
    cin>>m;
    m*=2;
    for(int i=1;i<=m;i++)
        cin>>f[i];
    sort(f+1,f+m+1);
    int ans =  0;
    for(int i=1;i<=m;i+=2)
        ans+=f[i];
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
def countingSort(A):
    minA = min(A)
    maxA = max(A)
    C = [0]*10001

    for x in A:
        C[x] += 1
    for x in range(1,10001):
        C[x] += C[x-1]
    B = [0]*(len(A)+1)

    for j in range(len(A)-1,-1,-1):
        B[C[A[j]]]=A[j]
        C[A[j]]-=1
    return B

if __name__ == '__main__':
    n = (int)(input())
    A = list(map(int,input().split()))

    B = countingSort(A)
    print(*B[1:])

Measured memory_bytes: 233664
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T>inline void read(T &x){
	int p=1;x=0;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<3)+(x<<1)+(c^'0');
		c=getchar();
	}
	x*=p;
}
int A,B;
int c[111][111];
bool f;
int main(){
	read(A),read(B);
	for(int i=1;i<=50;++i) for(int j=1;j<=100;++j) c[i][j]=1;
		for(int i=51;i<=100;++i) for(int j=1;j<=100;++j) c[i][j]=0 ;
	cout<<100<<" "<<100<<endl;
	A--,B--;
	int x,y;
	x=1,y=1;
	while(A){
		c[x][y]=0;
		if(y+2<=100) y+=2;
		else x+=2,y=1;
		A--;
	}
	x=52,y=1;
	while(B){
		c[x][y]=1;
		if(y+2<=100) y+=2;
		else x+=2,y=1;
		B--;
	}
	for(int i=1;i<=100;++i){
		for(int j=1;j<=100;++j)
			if(c[i][j]==1) cout<<"#";
			else printf(".");
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

def solve(x, y, z, N, M):
    a1 = x + y + z
    a1.sort()
    ppp = a1[N - M:].sum()
    mmm = 0 - a1[:M].sum()
    a2 = x - y + z
    a2.sort()
    pmp = a2[N - M:].sum()
    mpm = 0 - a2[:M].sum()
    a3 = x + y - z
    a3.sort()
    ppm = a3[N - M:].sum()
    mmp = 0 - a3[:M].sum()
    a4 = x - y - z
    a4.sort()
    pmm = a4[N - M:].sum()
    mpp = 0 - a4[:M].sum()
    return max(ppp, mmm, pmp, mpm, ppm, mmp, pmm, mpp)


pin = np.fromstring(sys.stdin.buffer.read(), dtype=np.int64, sep=' ')
N = pin[0]
M = pin[1]
xyz = pin[2: 2 + 3*N].reshape(N, 3).T
ans = solve(xyz[0], xyz[1], xyz[2], N, M)
print(ans)


Measured memory_bytes: 12504
import java.util.*;
import static java.lang.System.out;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int tmp = 0;
        tmp = a;
        a = b;
        b = tmp;
        tmp = a;
        a = c;
        c = tmp;
        System.out.println(a + " " + b + " " + c);

    }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  ll x;
  cin >> x;

  ll ans = 0;
  ans += (ll)(x / 11) * 2;


  if (x % 11 == 0) {}
  else if (x % 11 <= 6) ans++;
  else ans += 2;

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

Measured memory_bytes: 256
#include<stdio.h>

#define INF (1<<21)
#define X -1
#define Y -2
 
typedef struct{
  int d;
  int con;
}tree;
 
int main(){

  int e, i, j, k, n, u[101], a[101][101], sum = 0;
  tree d[101];

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){

      scanf("%d", &e);

      a[i][j] = (e == -1)?INF:e;
      d[i].con = Y;

      if(i == 0)d[i].d = 0;

      else d[i].d = INF;
    }
  }

  u[0] = 0;
  d[0].con = X;

  for(k = 1;k < n;k++){
    for(i = 0;i < k;i++){
      for(j = 0;j < n;j++){

	if(d[k].d > a[u[i]][j] && d[j].con != X){
	  d[k].d = a[u[i]][j];
	  u[k] = j;
	}

      }
    }

    d[u[k]].con = X;  
    sum += d[k].d;
  }

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

  return 0;
}




Measured memory_bytes: 2056
//abc120_a.cpp
//Tue Mar  5 20:17:31 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	cout << min(c, b/a)<< endl;
}

Measured memory_bytes: 256