akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX = 2100000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  long k;
  string s;
  cin >> k >> s;
  long n = s.size();
  vl d25(n+k+1,1);
  vl d26(n+k+1,1);
  rep(i,n+k){
    d25[i+1] = (d25[i] * 25) % MOD;
    d26[i+1] = (d26[i] * 26) % MOD;
  }
  long ans = 0;
  REP(i,n,n+k+1){
    long r = d25[i-n] * d26[n+k-i] % MOD;
    r = r * COM(i-1,n-1) % MOD;
    ans = (ans + r) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 84764
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N,K,i,j,mincost,cost;
    int h[100010];
    int s[100010]={};
    cin >> N >> K;
    mincost=1e9;
    for(i=1;i<=N;i++){
        cin >> h[i];
    }
    s[1]=0,s[2]=abs(h[1]-h[2]);
    for(i=3;i<=N;i++){
        mincost=1e9;
        for(j=1;j<=K;j++){
             if(i-j>0){
                cost=abs(h[i]-h[i-j]);
                mincost=min(mincost,s[i-j]+cost);
             }
        }
        s[i]=mincost;
    }/*
    for(int i=1;i<=N;i++){
        cout << s[i] << endl;
    }*/
    cout << s[N] << endl;

    
}


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

using namespace std;

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

    long double amount = 0;
    long double received; string currency;
    for (int i = 0; i < N; i++)
    {
        cin >> received >> currency;
        if (currency == "JPY")
        {
            amount += received;
        } else {
            amount += (received * 380000);
        }
    }
    
    cout.precision(10);
    cout << amount;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,m;cin>>n>>m;
    ll prod=n*m;
    if(n==1 || m==1)cout<<1;
    else{
    if(prod%2)cout<<prod/2+1;
    else cout<<prod/2;
    }
    return 0;  
} 





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

using namespace std;

typedef long long ll;

const int MAX = 100000;

int main(){
  int q; cin >> q;
  int l[q], r[q];
  for(int i=0;i<q;i++) cin >> l[i] >> r[i];
  bool found[MAX+1];
  found[1]=true;
  for(int i=2;i+i<=MAX;i++){
    if(!found[i]){
      for(int j=i+i;j<=MAX;j=j+i) found[j]=true;
    }
  }
  // for(int i=1;i<=10;i++) cout << found[i] << endl;
  int sum[MAX+1];
  sum[0]=0;
  for(int i=1;i<=MAX;i++){
    if((i %2 == 1) && !(found[i]) && !(found[(i+1)/2])){
      sum[i]=sum[i-1]+1;
    }else{
      sum[i]=sum[i-1];
    }
  }
  // for(int i=1;i<=10;i++) cout << sum[i] << endl;
  for(int i=0;i<q;i++){
    cout << sum[r[i]]-sum[l[i]-1] << endl;
  }
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";
const ll inf=9187201950435737471;
map<ll,ll> udah;
int main() {
	IOS
	ll n;
	cin>>n;
	ll res=0;
	for(ll i = 1; i*i <= n; i++) {
		if(n%i == 0) {
			ll f1=i,f2=n/i;
			ll tmp=n;
			while(tmp%f1==0 and f1!=1) {
				tmp/=f1;
			}
			if(tmp%f1==1) {
				res+=!udah[f1];
				udah[f1]=1;
//				debug(f1)
			}
			if(f2!=f1) {
				tmp=n;
				while(tmp%f2==0 and f2!=1) {
					tmp/=f2;
				}
				if(tmp%f2==1) {
					res+=!udah[f2];
					udah[f2]=1;
//					debug(f2)
				}
			}
		}
	}
	n--;
	for(ll i = 1; i*i <= n; i++) {
		if(n%i == 0) {
			ll f1=i,f2=n/i;
			if(f1>1)
			udah[f1]=1;
			if(f2>1)
			udah[f2]=1;
		}
	}
//	for(auto x : udah) debug(x.fi)
	cout<<udah.size()<<endl;
}


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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

const int maxn = 3e5 + 2;
int a[maxn];
int tree[maxn << 2];
struct seg_tree {
    int combine(int x, int y)  {
        return max(x, y);
    }
    void build(int l, int r, int node) {
        if (l == r) {
            tree[node] = a[l];
            return;
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        build(l, mid, lc);
        build(mid + 1, r, rc);
        tree[node] = combine(tree[lc], tree[rc]);
    }
    int query(int l, int r, int ql, int qr, int node) {
        if (qr < l || r < ql)
            return 0;
        if (ql <= l and r <= qr) {
            return tree[node];
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        return combine(query(l, mid, ql, qr, lc), query(mid + 1, r, ql, qr, rc));
    }
    void update(int l, int r, int pos, int val, int node) {
        if (pos < l || r < pos)
            return;
        if (l == r and l == pos) {
            tree[node] = val;
            return;
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        update(l, mid, pos, val, lc);
        update(mid + 1, r, pos, val, rc);
        tree[node] = combine(tree[lc], tree[rc]);
    }
};

void solve() {
    int n, k;
    cin >> n >> k;
    const int mx = 3e5+1;
    seg_tree ins;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ++a[i];
        int l = max(1, a[i] - k);
        int r = min(mx, a[i] + k);
        int ans = 1 + ins.query(1, mx, l, r, 1);
        // if (ans > ins.query(1, mx, a[i], a[i], 1)) {
            ins.update(1, mx, a[i], ans, 1);
        // }
    }
    for (int i = 1; i <= 10; ++i) {
        // cout << i << ' ' << ins.query(1, mx, i, i, 1) << '\n';
    }
    cout << ins.query(1, mx, 1, mx, 1) << '\n';

}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

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

int main(){
  int n, t, a;
  cin >> n >> t >> a;
  vector<double> h(n);
  
  for(int i = 0; i < n; i++){
  	cin >> h.at(i);
    h.at(i) = t-h.at(i)*0.006;
  }
  
  double minimum = 1000;
  for(int i = 0; i < n; i++){
  	minimum = min(minimum, abs(h.at(i)-a));
  }
  int ans;
  for(int i = 0; i < n; i++){
  	if(minimum == abs(h.at(i)-a)){
    	ans = i+1;
    	break;
    }
  }
  cout << ans << endl;
}

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

#define INF 987654321
#define ll long long

int N;
string s;

int main()
{
	cin >> s;
	if (s[2]==s[3] && s[4]==s[5]) cout << "Yes";
	else cout << "No";
	return 0;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	/*calculation*/
	int ans = 0;
	for(int i = 1; i <= n; i+=2){
		int judge = 0;
		for(int j = 1; j <= i; j++){
			if(i%j == 0)judge++;
		}
		if(judge == 8)ans++;
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vi A(n);
  for (int& elem: A) cin >> elem;
  vi B = A;
  sort(rall(B));
  for (int elem: A) {
    if (elem != B[0]) cout << B[0] << '\n';
    else cout << B[1] << '\n';
  }
  return (0);
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
long long a[maxn];
int main()
{
    int n;
    long long sum1=0,sum2=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]),sum2+=a[i];
    sum1=a[0],sum2-=a[0];
    long long Min=abs(sum1-sum2);
    for(int i=1;i<n-1;i++)
    {
        Min=min(Min,abs(sum1-sum2));
        sum1+=a[i];sum2-=a[i];
    }
    cout<<Min<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    string S;cin>>S;
    S[3]='8';
    cout<<S<<endl;
}

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

int main(){
  string S;
  cin >> S;
  if("ABC" == S) cout << "ARC" << endl;
  if("ARC" == S) cout << "ABC" <<endl;
}

Measured memory_bytes: 3620
N = int(input())
S1 = input()
S2 = input()

P = 1000000007
prev = None
i = 0
ans = 1
while i < N:
    split = S1[i] != S2[i]
    if prev is None:
        ans = 6 if split else 3
    elif prev:
        if split:
            ans = ans*3%P 
    else:
        ans = ans*2%P
    prev = split
    i += 2 if split else 1
print(ans)


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

int main(){
	int n,m;
	cin>>n>>m;
	int sum=0;
	int a[n];
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n) return cout<<-1<<endl,0;
	cout<<n-sum<<endl;
	return 0;
}


Measured memory_bytes: 3636
def main():
    N, L = map(int, input().split())
    apples = [i+L-1 for i in range(1, N+1)]
    app_abs = list(map(abs, apples))
    ix_min = app_abs.index(min(app_abs))

    apples.pop(ix_min)
    return sum(apples)
    
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner in;
	static PrintWriter out;
	static int n;
	static int[] A,L,R;
	
	static {
		in = new Scanner(new BufferedInputStream(System.in));
		out = new PrintWriter(new BufferedOutputStream(System.out));
	}
	
	static long merge(int[] A, int n, int left, int mid, int right) {
		/*for(int i = 0; i < n; i++) {
			out.print(A[i] + " ");
		}
		out.flush();
		out.println();*/
		int n1 = mid - left;
		int n2 = right - mid;
		L = new int[n1 + 2];
		R = new int[n2 + 2];
		for(int i = 0; i < n1; i++) L[i] = A[left + i];
		for(int i = 0; i < n2; i++) R[i] = A[mid + i];
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		long cnt = 0;
		for(int k = left; k < right; k++) {
			if(L[i] <= R[j]) {
				A[k] = L[i++];
			}else {
				A[k] = R[j++];
				cnt += n1 - i;
			}
		}
		return cnt;
	}
	
	static long mergeSort(int[] A, int n, int left, int right) {
		if(left < right - 1) {
			int mid = (left + right) / 2;
			long a = mergeSort(A, n, left, mid);
			long b = mergeSort(A, n, mid, right);
			long c = merge(A, n, left, mid, right);
			return a + b + c;
		}
		return 0;
	}
	
	public static void main(String[] args) {
		n = in.nextInt();
		A = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = in.nextInt();
		}
		long ans = mergeSort(A, n, 0, n);
		/*for(int i = 0; i < n; i++) {
			out.print(A[i] + " ");
		}
		out.flush();
		out.println();*/
		out.println(ans);
		out.flush();
		out.close();
		in.close();
	}
}


Measured memory_bytes: 103268
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto shop = new long[][](n, 10);
    auto p = new long[][](n, 11);
    foreach (ref e; shop)
    {
        e = aryread();
    }
    foreach (ref e; p)
    {
        e = aryread();
    }
    long max_bene = -INF;
    foreach (i; iota(1, 1 << 10))
    {
        long bene;
        auto bitary = i.makebitary();
        foreach (j; iota(n))
        {
            long cnt;
            foreach (k; iota(10))
                cnt += shop[j][k] & bitary[k];

            bene += p[j][cnt];
        }
        max_bene = max(bene, max_bene);
    }
    max_bene.writeln();
}

auto makebitary(long a, long disit = 10)
{
    auto bits = new long[](disit);
    long i;
    while (a > 0)
    {
        bits[i++] = a % 2;
        a = a >> 1;
    }
    return bits;
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, len;
int a[N], ans[N]; bool flag;

int main() {
	scanf("%d", &n), len = n;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = n; i; i--) {
		flag = 1;
		for(int j = len; j; j--) {
			if(a[j] != j) continue;
			for(int k = j; k < len; k++) a[k] = a[k + 1];
			ans[i] = j, --len, flag = 0; break;
		}
		if(flag) { puts("-1"); return 0; }
	}
	for(int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d%d", $n, $c, $k);
for($i = 0; $i < $n; $i++){
  $time[] = intval(fgets(STDIN));
}
sort($time);

$minT = false;
$count = 0;
$bus = 0;
foreach($time as $t){
  if($minT === false || $count == $c || $t - $minT > $k){
    $minT = $t;
    $count = 0;;
    $bus++;
  }
  $count++;
}
echo $bus;



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

int main() {
    int n, m, a;
    int item[1000];
    while (cin >> n >> m, n||m) {
        int sum  = -1;
        for (int i = 0; i < n; ++i) {
            cin >> a;
            item[i] = a;
        }

        for (int i = 0; i < n-1; ++i) {
            for (int j = i+1; j < n; ++j) {
                int tmp = item[i] + item[j];
                if (tmp <= m && tmp > sum) {
                    sum = tmp;
                }
            }
        }

        if (sum < 0) cout << "NONE" << endl;
        else cout << sum << endl;
    }
    return 0;
}


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

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

  c = a * b / 2 ;
  i = a * b / 2 ;
  
  if (c - i == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};

vector<int> g[50];
vector<pint> edges;
bool seen[50];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    pint e(a, b);
    edges.push_back(e);
  }
  int result = 0;
  for (auto&& edge : edges) {
    for (int i = 0; i < n; i++) seen[i] = false;
    queue<int> todo;
    todo.push(0);
    while (!todo.empty()) {
      int p = todo.front();
      todo.pop();
      seen[p] = true;
      for (auto&& e : g[p]) {
        if ((p == edge.first && e == edge.second) ||
            (p == edge.second && e == edge.first))
          continue;
        if (!seen[e]) todo.push(e);
      }
    }
    for (int i = 0; i < n; i++) {
      if (!seen[i]) {
        result++;
        break;
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
var
  s1,s:string;
  n,m:longint;
begin
  readln(s1);
  readln(n,m);
  readln(s);
  if pos(s,s1)=1 then dec(n)
  else if pos(s,s1)<>0 then dec(m);
  writeln(n,' ',m);
end.

Measured memory_bytes: 128
package main

import (
  "fmt"
)

func main() {
  var S, T string
  fmt.Scanf("%s %s", &S, &T)
  
  var A, B int
  fmt.Scanf("%d %d", &A, &B)
  
  var U string
  fmt.Scanf("%s", &U)
  
  if U == S {
  	A--
  } else {
    B--
  }
  
  fmt.Printf("%d %d", A, B)
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var Nx = Split.ints();
    var N = Nx[0];
    var h = Split.ints();

    var ret = new int[N];

    for(int i=1;i<N ;i++ )
    {
      if (i == 1)
      {
        ret[1] = Math.Abs(h[0] - h[1]);
      }
      else
      {
        ret[i] = Math.Min(
          Math.Abs(h[i]-h[i-1])+ret[i-1],
          Math.Abs(h[i]-h[i-2])+ret[i-2]
          );
      }

    }

    Console.WriteLine(ret[N-1]);
  }

  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{ 

  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}



Measured memory_bytes: 16864
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

n = int(input())
A = [int(i) for i in input().split()]
for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
print(A[-1])

Measured memory_bytes: 14224
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
  
#define N 100005
#define U [N]={}
map<L,L> path[N];
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,a,b,c,p,r;
char s[5];
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
    
L edgecost(L a){
    r=add[a]+add[par[a]]+cst[a];
    return r%k?r:0;
}
    
L sum(L i){
    for(r=0;i;r+=bit[i],i-=i&-i);
    return r;
}
L S(L i,L x){
    x=edgecost(x)-sum(i+1)+sum(i);
    for(i++;i<N;bit[i]+=x,i+=i&-i);
}
  
main(){
    for(cin>>n>>k;p<n-1;p++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    dfs(0);
    
    for(c=p=0;p<n;p++)
        if(!p|hev[par[p]]-p)
        for(a=p;!c|a;a=hev[a])
            pos[a]=c++,
            hl_par[a]=p,
            S(pos[a],hev[a]);
    
    for(cin>>a;cin>>s>>a>>b;)
        if(*s&2){
            for(c=0;p=hl_par[a],n=hl_par[b],p-n;a=par[p])
                dep[p]<dep[n]?swap(p,n),swap(a,b),0:0,
                c+=sum(pos[a])-sum(pos[p])+edgecost(p);
            cout<<c+abs(sum(pos[a])-sum(pos[b]))<<endl;
        }else
            add[a]+=b,
            S(pos[a],hev[a]),
            a?S(pos[a]-1,a):0;
}

Measured memory_bytes: 31988
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a + n);
    cout << a[n - 1] - a[0];
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

using namespace std;
int main() {
    int i,N,L;
    cin >> N >> L;
    string str[110];
    string concat = "";

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

    sort(str,str+N);

    for(i = 0; i < N; i++) {
        concat += str[i];
    }
    cout << concat << endl;
    return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

struct Rng{
	int l,r,i;
	bool operator<(const Rng&rng)const{
		return l<rng.l;
	}
};

int Solve(string a,string b){
	int n=a.size();
	if(b==string(n,'0')&&a!=string(n,'0'))
		return -1;
	vector<Rng> c;
	REP(i,n){
		int l,r;
		REP(x,n)if(b[(i-x+n)%n]=='1'){
			l=-x;
			break;
		}
		REP(x,n)if(b[(i+x)%n]=='1'){
			r=x;
			break;
		}
		c.PB(Rng{l,r,i});
	}
	sort(ALL(c));
	int ans=inf;
	REP(x,n){
		vector<Rng> rng;
		for(auto r:c)
			if(a[r.i]!=b[(r.i+x)%n])
				rng.PB(r);
		int s=rng.size();
		rng.PB(Rng{0,0,-1});
		int l=rng[0].l,r=x;
		const auto Update=[&](){
			chmin(ans,-l*2+x+(r-x)*2+s);
		};
		Update();
		REP(i,s){
			l=rng[i+1].l;
			chmax(r,rng[i].r);
			Update();
		}
	}
	return ans;
}

signed main(){
	string a=readString(),b=readString();
	int ans=Solve(a,b);
	reverse(ALL(a));
	reverse(ALL(b));
	chmin(ans,Solve(a,b));
	cout<<ans<<endl;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli n,ans;
	cin>>n;
	ans=1;
	while(ans*n%360!=0)
	ans++;
	cout<<ans;
	return 0;
}

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

int fac[9];

int initfac(int n){
  fac[0]=1;
  for(int i=1; i<=n; i++){
    fac[i] = i*fac[i-1];
  }
}

int main(){
  
  initfac(8);
  int n; cin >> n;
  
  vector<int> p(n+1),q(n+1);
  int pnum=1, qnum=1;
  
  for(int i=0; i<n; i++){
    cin >> p[i+1];
  }
  
  for(int i=0; i<n; i++){
    cin >> q[i+1];
  }
  
  for(int i=1; i<n; i++){
    pnum += (p[i]-1)*fac[n-i];
    qnum += (q[i]-1)*fac[n-i];
    for(int j=i+1; j<=n; j++){
      if(p[j]>p[i])p[j]--;
      if(q[j]>q[i])q[j]--;
    }
  }
  
  cout << abs(pnum - qnum) << endl;
}

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

using namespace std;

int main() {

	int n, tmp=0, min, cnt,ans;
	string s;

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == '.')
			tmp++;
	}	

	min = tmp;

	for (int i = 0; i < n; i++) {
		if (s[i] == '.')
			tmp--;
		else
			tmp++;
		if (tmp < min)
			min = tmp;
	}
  
	cout << min ;

	return 0;
}

Measured memory_bytes: 640
"use strict"

function main(input) {
  input = input.split(" ").map(v => v.charCodeAt())
  const x = input[0]
  const y = input[1]

  if (x == y) {
    console.log("=")
  } else if (x > y) {
    console.log(">")
  } else {
    console.log("<")
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
#!/usr/bin/env python3
#abc126 e

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)


Measured memory_bytes: 123664
// ABC049

// inputに入力データ全体が入る
function Main(input) {
  var S = reverse(input.split("\n")[0].toString());
  const a = reverse("dream");
  const b = reverse("dreamer");
  const c = reverse("erase");
  const d = reverse("eraser");
  var result = "YES"; //結果表示用

  while(S.length > 0) {
    if(!S.indexOf(a)){
      S = S.slice( a.length ) ;
    } else if(!S.indexOf(b)){
      S = S.slice( b.length ) ;
    } else if(!S.indexOf(c)){
      S = S.slice( c.length ) ;
    } else if(!S.indexOf(d)){
      S = S.slice( d.length ) ;
    } else {
      result = "NO";
      break;
    }
  }
  console.log(result);
}

// 文字逆さ
function reverse(s) {
  var tmp = s.split("");
  var str = "";
  for(var i=tmp.length-1;i>=0;i--) {
    str += tmp[i].toString();
  }
  return str;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

const int N = 100010;

int n;
long long a[N];
long long b[N];

int main (int argc, char const *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    a[i] += a[i - 1];
    b[i] = a[i];
  }
  long long oddpos = 0;
  long long oddneg = 0;
  long long carry;
  // odd neg
  carry = 0;
  for (int i = 1; i <= n; ++i) {
    a[i] += carry;
    if (i & 1 and a[i] >= 0) {
      oddneg += 1 + a[i];
      carry -= 1 + a[i];
    }
    if (!(i & 1) and a[i] <= 0) {
      oddneg += 1 - a[i];
      carry += 1 - a[i];
    }
  }
  // odd pos
  carry = 0;
  for (int i = 1; i <= n; ++i) {
    b[i] += carry;
    if (!(i & 1) and b[i] >= 0) {
      oddpos += 1 + b[i];
      carry -= 1 + b[i];
    }
    if (i & 1 and b[i] <= 0) {
      oddpos += 1 - b[i];
      carry += 1 - b[i];
    }
  }
  printf("%lld\n", min(oddneg, oddpos));
  return 0;
}



Measured memory_bytes: 1792
n=int(input())
a=[]
for i in range(n):
  a.append(input())
m=int(input())
b=[]
for i in range(m):
  b.append(input())


ans=[]
for i in range(len(a)):
  z=a.count(a[i])
  ans.append(z-b.count(a[i]))


ans=max(ans)  
if ans<=0:
  print(0)
else:
  print(ans)

  
              

Measured memory_bytes: 3064
#include "iostream"
#include "algorithm"
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 1000;
typedef long long ll;
ll s[maxn];

int main() {
    int n;
    //cin >> n;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &s[i]);
        s[i] = s[i]-i;
    }
    sort(s,s+n);
    sum = s[n/2];
    ll ans = 0;
    //cout<<sum<<endl;
    //ll ans2 = 0;
    for (int i = 0; i < n; i++) {
        ans = ans + abs(s[i] - sum);
        //ans2 = ans2+abs(s[i]-sum-i-1);
    }
    //cout<<s[1]<<endl;
    //cout<<sum<<endl;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(string S, string T) {
    ll n = S.size();
    ll ans = 0;

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

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  solve(S, T);
  return 0;
}


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

int main()
{
  int A, B;
  int res=0;
  cin >> A >> B;

  if(A-B>=2) res = A + A -1;
  else if(B-A>=2) res = B + B -1;
  else res = A + B;
  
  cout << res << endl;
}

Measured memory_bytes: 256
#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
#define MAX 20
int main(void)
{
	int i;
	char str[MAX + 1];
	scanf_s("%s", str, MAX);
	for (i = 0; str[i + 1] != '\0'; ++i);
	for (; i >= 0;--i){
		printf("%c", str[i]);
	}
	printf("\n");
}

Measured memory_bytes: 1100
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        String hoge;
        if (a < b) {
        	hoge = "a < b";
        }
        else if (a > b) {
        	hoge = "a > b";
        }
        else {
        	hoge = "a == b";
        }
        System.out.println(hoge);
	}

}


Measured memory_bytes: 26204
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
    const long long int mod = 1000000007,INF=50000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str[120];
    long long int n,m,a,b,now=-1;
    pair<long long int,long long int>pa[100000];
    long long int res=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        pa[i]={b,a};
    }
    sort(pa,pa+m);
    for(int i=0;i<m;i++){
        if(pa[i].second<now){continue;}
        else{
            res++;
            now=pa[i].first;
        }
    }
    cout<<res<<endl;
} 


Measured memory_bytes: 1792
import math

n, m = list(map(int, input().split()))
reg = (m / n)
k = 1
for i in range(1, int(math.sqrt(m) + 1)):
    if m % i == 0:
        a = m/i
        b = i
        if reg >= b and k < b:
            k = b
        if reg >= a and k < a:
            k = a
print(int(k))

Measured memory_bytes: 3060
N, M = map(int,input().split())
Edge = [list(map(int,input().split())) for i in range(M)]


def dfs(i):
    visited.add(i)
    for k in From[i]:
        if k not in visited:
            dfs(k)
    for k in To[i]:
        if k not in visited:
            dfs(k)

def bridge(j):
    for i in Edge:
        if i == j:
            continue
        else:
            From[i[0]-1].append(i[1]-1)
            To[i[1]-1].append(i[0]-1)
    dfs(0)
    return True if visited.__len__() != N else False
ans = 0
for j in Edge:
    From = [[] for i in range(N)]
    To = [[] for i in range(N)]
    visited = set()
    ans += bridge(j)
    #print(From)
    #print(To)
    #print(visited)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll INF=1000000000000000;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
	ll n;
	cin>>n;
	ll a[n+1],b[n+1],c[n+1];
	ll p,q,r;
	for(ll i=1;i<=n;i++)
	{
		cin>>p>>q>>r;
		a[i]=p;
		b[i]=q;
		c[i]=r;
	}
	ll dp[n+1][3];
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	dp[2][1]=a[2]+max(dp[1][1],max(dp[1][2],dp[1][3]));
	dp[2][2]=b[2]+max(dp[1][1],max(dp[1][2],dp[1][3]));
	dp[2][3]=c[2]+max(dp[1][1],max(dp[1][2],dp[1][3]));
	for(ll i=3;i<=n;i++)
	{
		dp[i][1]=dp[i][2]=dp[i][3]=0;
	}
	for(ll i=3;i<=n;i++)
	{
		dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
		// if(dp[i-1][1]==(dp[i-2][2]+a[i-1]) || dp[i-1][1]==(dp[i-2][3]+a[i-1]))
		// 	dp[i][1]=max(dp[i][1],(a[i]+dp[i-1][1]));
		dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
		// if(dp[i-1][2]==(dp[i-2][1]+b[i-1]) || dp[i-1][2]==(dp[i-2][3]+b[i-1]))
		// 	dp[i][2]=max(dp[i][2],(b[i]+dp[i-1][2]));
		dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
		// if(dp[i-1][3]==(dp[i-2][2]+c[i-1]) || dp[i-1][3]==(dp[i-2][1]+c[i-1]))
		// 	dp[i][3]=max(dp[i][3],(c[i]+dp[i-1][3]));
	}
	// for(ll i=1;i<=n;i++)
	// 	cout<<dp[i][1]<<' '<<dp[i][2]<<' '<<dp[i][3]<<endl;
	ll ans=max(dp[n][1],max(dp[n][2],dp[n][3]));
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);

int i=1;
int tmp;
while(true){
int x = sc.nextInt();
int y = sc.nextInt();
if(x==0 && y==0){break;}

if(x>y){
tmp =x;
x=y;
y=tmp;
}

System.out.println(x+" "+y);
i=i+1;

}

}
}

Measured memory_bytes: 35148
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 110;
typedef long long ll;

int main(void)
{
    ll N,K;
    cin>>N>>K;
    if(N>=K)
        N = N%K;
    ll ret = abs(N-K);
    ret = min(ret,N);
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<int,int> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(k>n*(n-1)/2-n+1){
      cout<<-1<<endl;
      return 0;
    }
    vector<P> ans;
    int now=2;
    int cnt=1;
    rep(i,n-1){
      ans.push_back(P(1,i+2));
    }
    int num=n*(n-1)/2-n+1-k;
    //cout<<num<<endl;
    rep(i,num){
      if(now+cnt<=n){
        ans.push_back(P(now,now+cnt));
        cnt++;
      }else{
        now++;
        cnt=1;
        ans.push_back(P(now,now+cnt));
        cnt++;
      }
    }
    cout<<len(ans)<<endl;
    rep(i,len(ans)){
      cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
}

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

ans = 0
for i in range(n):
    m = min(a[i], b[i])
    a[i] -= m
    b[i] -= m
    ans += m
    m = min(a[i + 1], b[i])
    a[i + 1] -= m
    b[i] -= m
    ans += m

print(ans)

Measured memory_bytes: 18624
import sys
sys.setrecursionlimit(10**8)

h,w=map(int,input().split())
a=[]
dp={}
dp[(h-1,w-1)]=1
for i in range(h):
	a.append(list(input()))

def foo(i,j):
	if i>=h or j>=w:
		return 0
	if (i,j) in dp:
		return dp[(i,j)]
	ans=0
	if i+1<h and a[i+1][j]=='.':
		ans+=foo(i+1,j)
	if j+1<w and a[i][j+1]=='.':
		ans+=foo(i,j+1)
	dp[(i,j)]=ans%(1e9+7)
	return dp[(i,j)]

print(int(foo(0,0)))


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

using namespace std;

int main(){
  
  int n, d;
  
  cin>>n>>d;
  
  if(n<10){
   
    cout<<(d + 100*(10-n));
    
  }else{
    
    cout<<d;
  }
  
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    string s;
    ll m;
    while(1){
    cin >> s >> m;
    if(s == "-") break;
    ll h[m];
    rep(i,m) cin >> h[i];
    rep(i,m){
        s=s.substr(h[i]) + s.substr(0,h[i]);
    }
    cout << s << endl;
    }
}


Measured memory_bytes: 3132
#include <stdio.h>
#include <string.h>

int main(void){
    
    char s[11];
    int C=0;
    scanf("%s",s);
    
    for(int i=1; i<strlen(s); i++){
        if(s[i]>='A' && s[i]<='Z' &&s[i]!='C')
            C=2;
        
        if(s[i]=='C' && i!=1 && i!=strlen(s)-1)
            C++;
    }
    
    if(s[0]=='A' && C==1)
        printf("AC");
    else
        printf("WA");
}


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

const int maxn=int(2e5)+100;

int n;
int a[maxn], b[maxn];

void read()
{
	scanf("%d", &n);
	for (int i=1; i<=n; ++i)
	{
		scanf("%d", &a[i]);
		b[i]=a[i];
	}
}
void solve()
{
	sort(b+1, b+1+n);
	int L=b[n/2], R=b[n/2+1];

	for (int i=1; i<=n; ++i)
		if (a[i]<=L) printf("%d\n", R);
		else printf("%d\n", L);
}
int main()
{
	read();
	solve();
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long l[100];
    for(int i = 0; i < n;i++){
        cin >> l[i];
    }
    long long count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
                        count++;
                    }
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vector<string> ans;
vector<vll> xy;
void err(){
  std::cout << -1 << '\n';
  exit(0);
}
int od = -1;
void solve(ll num){
  string tmp = "";
  ll x=xy[num][0], y=xy[num][1];
  while(true){
    if((abs(y) + abs(x)) == 1){
      if(x==-1) tmp += 'L';
      if(x==1) tmp += 'R';
      if(y==1) tmp += 'U';
      if(y==-1) tmp += 'D';
      break;
    }
    if(abs(x)%2){
      if((abs(y/2)%2)!=(abs((x+1)/2)%2)) tmp += 'L', x++;
      else if((abs(y/2)%2)!=(abs((x-1)/2)%2)) tmp += 'R', x--;
    }else{
      if((abs(x/2)%2)!=(abs((y+1)/2)%2)) tmp += 'D', y++;
      else if((abs(x/2)%2)!=(abs((y-1)/2)%2)) tmp += 'U', y--;
    }
    x/=2, y/=2;
  }
  ans.push_back(tmp);
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  re(i, n){
    ll x, y;std::cin >> x >> y;
    if(od!=-1&&od!=abs(x+y)%2) err();
    else od = abs(x+y)%2;
    if(od) xy.push_back(vll{x, y});
    else xy.push_back(vll{x+1, y});
  }
  re(i, n) solve(i);
  if(od){
    std::cout << 31 << '\n';
    re(i, 31) std::cout << (1<<i) << (i==30?"\n":" ");
    re(i, n){
      string ret = "";
      for(int j=0;j<ans[i].size()-1;j++) ret += ans[i][j];
      char las = ans[i][ans[i].size()-1];
      char rev;
      if(las=='R') rev = 'L';
      if(las=='L') rev = 'R';
      if(las=='U') rev = 'D';
      if(las=='D') rev = 'U';
      for(int j=ans[i].size()-1;j<30;j++) ret += rev;
      ret += las;
      std::cout << ret << '\n';
    }
  }else{
    std::cout << 32 << '\n';
    std::cout << 1 << " ";
    re(i, 31) std::cout << (1<<i) << (i==30?"\n":" ");
    re(i, n) {
      string ret = "L";
      for(int j=0;j<ans[i].size()-1;j++) ret += ans[i][j];
      char las = ans[i][ans[i].size()-1];
      char rev;
      if(las=='R') rev = 'L';
      if(las=='L') rev = 'R';
      if(las=='U') rev = 'D';
      if(las=='D') rev = 'U';
      for(int j=ans[i].size()-1;j<30;j++) ret += rev;
      ret += las;
      std::cout << ret << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S;
bool single(string s, int c) {
  rep(i, s.length()) {
    if (s[i] != c) return false;
  }
  return true;
}

int solve(int c) {
  string s(S);
  int ctr = 0;
  while (!single(s, c)) {
    string t = "";
    rep(i, (int)s.length()-1) {
      if (s[i] == c || s[i+1] == c) t += c;
      else t += 30;
    }
    ctr++;
    s = t;
  }
  return ctr;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  rep(i, S.length()) S[i] -= 'a';
  int m = INF;
  rep(c, 26) {
    m = min(m, solve(c));
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

int main() {
  int N;
  cin >> N;
  
  string s;
  int ac=0, wa=0, tle=0, re=0;
  rep(i,N){
    cin >> s;
    if(s=="AC") ac++;
    else if(s=="WA") wa++;
    else if(s=="TLE") tle++;
    else if(s=="RE") re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3632
import java.awt.*;
import java.util.*;

/**
 * Created by khrom on 2017/06/17.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        java.util.List<Point> rectList = new ArrayList<>();

        int h;
        int w;
        while (true) {
            h = scanner.nextInt();
            w = scanner.nextInt();
            if (h == 0 && w == 0)
                break;
            rectList.add(new Point(w, h));
        }
        boolean vibrator = false;
        for (Point point : rectList) {
            for (int i = 0; i < point.getY(); i++) {
                if (i % 2 == 1) vibrator = true;
                else vibrator = false;
                for (int j = 0; j < point.getX(); j++) {
                    if (vibrator) System.out.print(".");
                    else System.out.print("#");
                    vibrator = !vibrator;
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

string s,t;
LL ls,lt;
LL dp[3005][3005];
LL pre[3005][3005];

void output(int l,int r){
	if((!l) || (!r)) return;
	if(pre[l][r] == 1){
		output(l - 1,r - 1);
		printf("%c",s[l]);
	}
	if(pre[l][r] == 2) output(l - 1,r);
	if(pre[l][r] == 3) output(l,r - 1);
}

int main(){
	cin >> s; ls = s.length(); s = ' ' + s;
	cin >> t; lt = t.length(); t = ' ' + t;
	for(LL i = 1;i <= ls;i ++){
		for(LL j = 1;j <= lt;j ++){
			if(s[i] == t[j]){
				if(dp[i - 1][j - 1] + 1 > dp[i][j]){
					dp[i][j] = dp[i - 1][j - 1] + 1;
					pre[i][j] = 1;
				}
			}
			if(dp[i - 1][j] > dp[i][j]){
				dp[i][j] = dp[i - 1][j];
				pre[i][j] = 2;
			}
			if(dp[i][j - 1] > dp[i][j]){
				dp[i][j] = dp[i][j - 1];
				pre[i][j] = 3;
			}
		}
	}
	output(ls,lt);
	return 0;
}
//

Measured memory_bytes: 141440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;

int main(void){
    long long v,e,a[101][101],INF=1e12;
    cin>>v>>e;
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            a[i][j]=INF;
            if(i==j)a[i][j]=0;
        }
    }
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        a[s][t]=d;
    }
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            for(int k=0;k<v;k++){
                if(a[j][i]==INF||a[i][k]==INF)continue;
                if(a[j][k]>a[j][i]+a[i][k]){
                    a[j][k]=a[j][i]+a[i][k];
                }
            }
        }
    }
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            for(int k=0;k<v;k++){
                if(a[j][i]==INF||a[i][k]==INF)continue;                
                if(a[j][k]>a[j][i]+a[i][k]){
                    cout<<"NEGATIVE CYCLE"<<endl;
                    return 0;
                }
            }
        }
    }    
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(a[i][j]==INF)cout<<"INF";
            else cout<<a[i][j];
            if(j<v-1)cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3180