akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> v(n);
	for(auto& x:v)
		cin>>x;
	sort(v.begin(), v.end());
	string d = "YES";
	for(int i=1; i<n; i++)
		if(v[i]==v[i-1])
			d="NO";
	cout<<d<<endl;
}

Measured memory_bytes: 1024
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

a = list(map(int,input().split()))
a.sort()
if a[0] == 5 and a[1] == 5 and a[2] == 7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
string s,t;
int dp[3001][3001],n,m;
pair<int,int> path[3001][3001];
string ans;
void findpath(int i,int j){
	while(i>0&&j>0){
		if(s[i]==t[j]){
			ans+=s[i];
			i--;j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1])	i--;
			else						j--;
		}
	}
}
int main(){
	cin>>s>>t;
	s=" "+s;t=" "+t;
	for(int i=1;i<s.size();i++)
		for(int j=1;j<t.size();j++){
			if(s[i]==t[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	findpath(s.size()-1,t.size()-1);
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;


int main(){
	int a,b,c,d; cin >> a >> b >> c >> d;
    while(1){
      c -= b;
      if(c <= 0){
      	cout << "Yes" << endl;  return 0;
      }
      a -= d;
      if(a <= 0){
        cout << "No" << endl; return 0;
      }
    }
  	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll a[105];
ll sum;
int main(){FAST;
	cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll i=0;i<n;i++){
		sum+=a[i];
	}
	ll x = sum/n;
	ll y = (sum+n-1)/n;
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans+=(a[i]-x)*(a[i]-x);
	}
	ll tmp = 0;
	for(ll i=0;i<n;i++){
		tmp+=(a[i]-y)*(a[i]-y);
	}
	cout<<min(ans,tmp);
return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - String Equivalence
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 10;

/* typedef */

/* global variables */

int ds[MAX_N];

/* subroutines */

void rec(int u, int n, int maxd) {
  if (u >= n) {
    for (int i = 0; i < n; i++) putchar('a' + ds[i]);
    putchar('\n');
    return;
  }

  for (int i = 0; i <= maxd; i++) {
    ds[u] = i;
    rec(u + 1, n, max(i + 1, maxd));
  }
}

/* main */

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

  rec(0, n, 0);
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;
    int tmp = 1;
    
    for(int i = 0;i < n;i++){
        tmp = min(tmp*2,tmp+k);
    }

    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };


int main(void) {
	int a, b;

	cin >> a >> b;

	if (a*b % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n,m;

    cin >> n >> m ;

    int a[m];

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

    int sum = 0;

    for(int i = 0;i<m; i++){
        sum += a[i];
    }

    if(sum <= n){
        cout << n - sum << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 3236
n = int(input())
a = list(map(int, input().split()))
cnt = 0

for i in range(len(a)):
    if a[i]%2 == 0:
        a[i] = int(a[i]/2)
        cnt += 1
    else:
        a[i] = 0

while len(a) != a.count(0):
    for i in range(len(a)):
        if a[i]%2 == 0 and a[i] != 0:
            a[i] = int(a[i]/2)
            cnt += 1
        else:
            a[i] = 0

print(cnt)

Measured memory_bytes: 4148
#include <iostream>
#include<stdio.h>
#define MAXSIZE 10000
#define PI 3.141592653589
using namespace std;
int main(){
  int n;
  std::cin >> n;
  int a[MAXSIZE];

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

  for(int i=n-1;i>0;i--){
    std::cout << a[i] <<" " ;
  }
  std::cout << a[0] << '\n';

}

Measured memory_bytes: 3104
#include <iostream>
#include <unordered_set>
#include <algorithm>
using namespace std;

int dx[8]={1, 1, 1, 0, 0,-1,-1,-1};
int dy[8]={1, 0,-1, 1,-1, 1, 0,-1};

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h==0) break;
        
        char c[10][20];
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> c[i][j];
            }
        }
        unordered_set<string> spell;
        string ans = "0";
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                for(int d=0; d<8; d++){
                    string str(1,c[i][j]);
                    int y=(i+dy[d]+h)%h;
                    int x=(j+dx[d]+w)%w;
                    while(y!=i || x!=j){
                        str += c[y][x];
                        auto itr = spell.find(str);
                        if(itr != spell.end()){
                            if(str.length()>ans.length() ||
                               (str.length()==ans.length() && str<ans)){
                                ans = str;
                            }
                        }else{
                            spell.insert(str);
                        }
                        y = (y+dy[d]+h)%h;
                        x = (x+dx[d]+w)%w;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 35000
module abc148
  sub main()
    dim a as integer, b as integer
    dim ans as integer
    dim i

    a = Console.ReadLine()
    b = Console.ReadLine()

    For i = 1 to 3
      if not (a = i Or b = i) then
        ans = i
        Exit For
      end if
   next

   Console.WriteLine(ans)

  end sub
end module

Measured memory_bytes: 19920
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
	string s;
	cin >> s;
	int hantei=1;
	for( int i=0; i<5; i++ ){
		if( s[2*i] == 0 && s[2*i+1] ==0) break;
		else if( s[2*i]=='h' && s[2*i+1]=='i' ) hantei *= 1;
		else hantei *=0;
	}
	if( hantei == 1 && s[10]==0 && s[1] == 'i'&& s[0] == 'h') cout << "Yes" << endl;
	else cout << "No";
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
string s;
int q;
int main(){
	cin>>s;
	read(q);
	int now=1;
	while(q--){
		int op1,op2;
		string c;
		read(op1);
		if(op1==1){
			now^=1;
		}
		else{
			read(op2);cin>>c;
			if(op2==1){
				if(now==1)s.insert(0,c);
				else s+=c;
			}
			else{
				if(now==1)s+=c;
				else s.insert(0,c);
			}
		}
	}
	if(now==1)
		cout<<s<<endl;
	else {
		for(int i=s.length()-1;i>=0;i--)cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 1028
// Problem : A - Darker and Darker
// Contest : AtCoder - AtCoder Grand Contest 033
// URL : https://atcoder.jp/contests/agc033/tasks/agc033_a
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
	int H,W;
  bool isValid(int x,int y)
 {
 	if(x>=0 && x<H && y>=0 && y<W)
 		return true;
 	return false;
 }
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>H>>W;
	vi vis[H],sps[H];
	queue<pi> st;
	vi v[H];
	F0R(x,H)
	{
		string str;
		cin>>str;
		F0R(y,W)
		{
			if(str[y]=='#')
				st.push({x,y}),v[x].pb(1);
			else
				v[x].pb(0);
			vis[x].pb(0);
			sps[x].pb(0);
		}
	}
	while(sz(st)!=0)
	{
		pi S=st.front();
		st.pop();
		F0R(x,4)
		{
			pi val={S.f+dx[x],S.s+dy[x]};
			if(isValid(val.f,val.s) && !vis[val.f][val.s] && !v[val.f][val.s])
			{
				vis[val.f][val.s]=1;
				sps[val.f][val.s]=1+sps[S.f][S.s];
				st.push({val.f,val.s});
			}
		}
	}
	int mx=INT_MIN;
	F0R(x,H)
	{
		F0R(y,W)
		{
			ckmax(mx,sps[x][y]);
		}
	}
	cout<<mx;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 24000
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

struct edge{long long  to, cost;};
typedef pair<long long,long long> P;

long long INF = 1e15;
struct graph{
  long long V;
  vector<vector<edge> > G;
  vector<long long> d;

  graph(long long n){
      init(n);
  }
  void init(long long n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(long long i = 0; i < V; i++){
        d[i] = INF;
    }
  }
  void add_edge(long long s, long long t, long long cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }
  void dijkstra(long long s){
    for(long long i = 0; i < V; i++){
        d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      long long v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};


int main(){
    long long n, m;
    cin >> n >> m;

    graph g(n);

    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        g.add_edge(a-1, b-1, 1);
        g.add_edge(b-1, a-1, 1);
    }
    g.dijkstra(0);

    if(g.d[n-1] == 2) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}

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

int  main()
{
	int n; cin >> n;
	vector <int> l(n);
	int sum = 0;
	rep(i, n)
	{
		cin >> l[i];
		sum += l[i];/* 全ての長さの合計 */
	}
	sort(l.begin(), l.end());
	sum -= l.back(); //辺の長さの合計 - 最長の辺
	if (l.back() < sum)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict


class PrimeFactor():

    def __init__(self, n):                  # エラトステネス　O(N loglog N)
        self.n = n
        self.table = list(range(n+1))
        self.table[2::2] = [2]*(n//2)
        for p in range(3, int(n**0.5) + 2, 2):
            if self.table[p] == p:
                self.table[p * p::2 * p] = [p] * ((n - p * p - 1) // (2 * p) + 1)

    def is_prime(self, x):  # 素数判定　O(1)
        if x < 2:
            return False
        return self.table[x] == x

    def prime_factors(self, x):             # 素因数分解 O(logN)
        res = []
        if x < 2:
            return res
        while self.table[x] != 1:
            res.append(self.table[x])
            x //= self.table[x]
        return res

    def prime_counter(self, x):             # 素因数分解（個数のリスト）
        res = defaultdict(int)
        if x < 2:
            return res
        while self.table[x] != 1:
            res[self.table[x]] += 1
            x //= self.table[x]
        return res

    def prime_gcd(self, X):                 # n個の最大公約数　X:n個のリスト
        exponents = self.prime_counter(X[0])
        for x in X[1:]:
            Y = self.prime_counter(x)
            for prime, exp in exponents.items():
                if Y[prime] < exp:
                    exponents[prime] = Y[prime]
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp)
        return res

    def prime_lcm(self, X, mod=None):       # n個の最小公倍数　X:n個のリスト
        exponents = defaultdict(int)
        for x in X:
            for prime, exp in self.prime_counter(x).items():
                if exp > exponents[prime]:
                    exponents[prime] = exp
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
table = PrimeFactor(10**6)
num = table.prime_lcm(A,mod)

res = 0
for a in A:
    res += num * pow(a, mod - 2, mod)

print(res % mod)

Measured memory_bytes: 57220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

int ans = inf;
int n, m, x;
int cost[15];
int arr[15][15];

bool check()
{
	for (int i = 0; i < m; i++)
	{
		int sum = 0;
		for (int j = 0; j < n; j++)
		{
			sum += arr[j][i];
		}
		if (sum < x)
			return false;
	}
	return true;
}

int calculate(int temp)
{
	int score[m];
	memset(score, 0, sizeof(score));
	int c = 0;
	int cnt = 0;
	while (temp)
	{
		if (temp & 1)
		{
			for (int i = 0; i < m; i++)
				score[i] += arr[cnt][i];
			c += cost[cnt];
		}
		cnt++;
		temp = temp >> 1;
	}
	bool yes = true;
	for (int i = 0; i < m; i++)
	{
		if (score[i] < x)
			yes = false;
	}
	if (yes)
		return c;
	else
		return inf;
}


void solve()
{
	cin >> n >> m >> x;


	for (int i = 0; i < n; i++)
	{
		cin >> cost[i];
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
		}
	}
	if (check() == false)
	{
		cout << -1 << "\n";
		return;
	}

	for (int i = 1; i < (1 << n); i++)
	{
		int temp = calculate(i);
		ans = min(ans, temp);
	}
	cout << ans << "\n";
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll A,B;cin>>A>>B;
    if((A+B)%2){
        cout<<"IMPOSSIBLE"<<endl;
    }else{
        cout<<(A+B)/2<<endl;
    }
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int X, Y;
    cin >> X >> Y;
    if(abs(X - Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a,b,c,d;
int A[100000];
int res[100000];
int result[100000];
int k=0;

//int w,h,x,y,r;

int main(void) {

  while(scanf("%d %d",&a,&b) && a!=0 || b!=0){
      //花札作成
      for(int i=1;i<=a;i++){
        A[i]=a-i+1;
      }


      for(int i=1;i<=b;i++){
        scanf("%d %d",&c,&d);
          //花札取り置き
          for(int i=1;i<=c-1;i++){
            res[i]=A[i];
          }
          //花札入れ替え
          for(int i=c;i<=c+d-1;i++){
            A[i-c+1]=A[i];
          }
          for(int i=d+1;i<=c+d-1;i++){
            A[i]=res[i-d];
          }
      }
      result[k]=A[1];
      k++;
    }
    for(int i=0;i<k;i++){
      printf("%d\n",result[i]);
    }
    return 0;
  }



Measured memory_bytes: 2048
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int maxn=5e5+5;
vector<int> nei[maxn];
int dfn[maxn],low[maxn],cnt;
vector<pair<int,int> > bridges;
bool vis[maxn];
void dfs(int root,int pre)
{
    vis[root]=true;
    dfn[root]=low[root]=++cnt;
    for(int i=0;i<(int)nei[root].size();i++)
    {
        int next=nei[root][i];
        if(next==pre) continue;
        if(!vis[next])
        {
            dfs(next,root);
            low[root]=min(low[root],low[next]);
        }
        else
        {
            low[root]=min(low[root],dfn[next]);
        }
    }
    if(dfn[root]==low[root]&&dfn[root]!=1)
        bridges.push_back(make_pair(root,pre));
    return;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    dfs(1,0);
    printf("%d\n",(int)bridges.size());
    return 0;
}
/*
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7
 
 
3 3
1 2
1 3
2 3
 
 
6 5
1 2
2 3
3 4
4 5
5 6
 */


Measured memory_bytes: 15536
n = int(input())
A = [int(input()) for _ in range(n)]
cnt = 0

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

G = [1]
for i in range(99):
    if n < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt)
print(*A, sep='\n')


Measured memory_bytes: 53300
using System;

namespace ABC156
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int r = int.Parse(str[1]);
            
            if(n >= 10)
            {
                Console.WriteLine(r);
            }
            else
            {
                Console.WriteLine(100 * (10 - n) + r);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
vector<int> fr[36];
char s[100005],s2[100005];
int n,i,poz,ture;
bool ok;
int main()
{
    cin>>s;
    n=strlen(s);
    for(i=0;i<n;i++)
        fr[s[i]-'a'].push_back(i);
    cin>>s2;
    n=strlen(s2);
    for(i=0;i<n;i++)
    {
        if(fr[s2[i]-'a'].empty())
        {
            cout<<-1;
            return 0;
        }
    }
    poz=-1;
    for(i=0;i<n;i++)
    {
        ok=false;
        auto npoz=upper_bound(fr[s2[i]-'a'].begin(), fr[s2[i]-'a'].end(), poz);
        if(npoz==fr[s2[i]-'a'].end())
        {
            ture++;
            poz=fr[s2[i]-'a'][0];
        }
        else
        {
            poz=fr[s2[i]-'a'][npoz-fr[s2[i]-'a'].begin()];
        }
    }
    cout<<ture*strlen(s)+poz+1;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (m * 1900 + (n - m) * 100) * pow(2, m) << endl;
    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    int size = S.size();
    rep(i, size / 2)
    {
        if (S.at(i) != S.at(size - i - 1))
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

#from math import gcd
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(r, b)

def gcd_list(numbers):
    return reduce(gcd, numbers)

K = ii()
ans = 0

memo = dp3(-1, K+1, K+1, K+1)

for i in range(1, K+1):
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            ans += gcd_list([i, j, k])*6

for i in range(1, K+1):
    for j in range(1, K+1):
        if i!=j:
            ans += gcd_list([i, i, j])*3

for i in range(1, K+1):
    ans += gcd_list([i, i, i])


print(ans)

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

int main(){
    vector<int> x(5);
    for(int i = 0; i < 5; i++){
        cin >> x[i];
    }
    for(int i = 0; i < 5; i++){
        if(x[i] == 0) cout << i + 1 << endl;
    }
    return 0;
}

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

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

  int t, sum;
  t = N;
  while (t > 0) {
    sum += t % 10;

    t /= 10;
  }

  if ((N % sum) == 0)
  {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;
using LLONG = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    return 0;
}

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

// 最初の数1に対して、2倍するか、値addNumを足す操作を
// operationNum回繰り返した時の最小の値を出力する
// 値が小さくなる方の操作を続ければ、最終結果も最小になる
int main() {
    
    int num = 1;
    int operationNum, addNum;
    
    cin >> operationNum >> addNum;
    for (int i = 0; i < operationNum; i++) {
        int result1 = num * 2;
        int result2 = num + addNum;
        
        num = min(result1, result2);
    }
    
    cout << num << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int a, b; cin >> a >> b;
  if (a + b >= 10) cout << "error" << endl;
  else cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a, b;
    cin >> a >> b;

    if (a <= 9 && b <= 9) {
        cout << a*b;
    }
    else
    {
        cout << "-1";
    }

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, m, nc;
	cin >> n >> m;
	nc = n;
	Vec<int> cnt(m);
	while (nc--) {
		int k;
		cin >> k;
		while (k--) {
			int a;
			cin >> a;
			cnt[--a]++;
		}
	}
	cout << count(begin(cnt), end(cnt), n) << "\n";
}

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


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, j, n, sum=0;
	scanf("%d", &n);
	int d[n];
	rep(i,n) scanf("%d", &d[i]);
	rep(i,n-1){
		loop(j, i+1, n){
			sum += d[i]*d[j];
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>

int main(){
   char s[201], t[101], p[101];
 
   scanf("%s %s", s, p);
   strcpy(t, s);
   strcat(s, t);

   if ( strstr(s, p) == NULL ) printf("No\n");
   else printf("Yes\n");
 
   return 0;
}


Measured memory_bytes: 2752
def solution():
    s = input()
    acgt = ['A','C','G','T']
    cnt = ans = 0
    for i in range(len(s)):
        cnt = 0
        for ss in s[i:]:
            if ss in acgt:
                cnt += 1
            else:
                break
        ans = max(cnt, ans)
    print(ans)

solution()

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n-1):
    if a[i] < a[i+1]:
        a[i+1] -=1
count = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        count+=1
if count == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll h,w,x,y;
  cin >> w >> h >> x >> y;
  printf("%lf %d\n",double(h)*double(w)/2,(x*2==w && y*2==h) );
  return 0;
}


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

using namespace std;

int main() 
{
	int n,m;
	while(cin >> n >> m && n>0 && m>0)
	{
		int a[50]={0};
		for(int i=0;i<n;i++){	a[i]=n-i;	}
		
		for(int i=0;i<m;i++)
		{
			int x,y;
			cin >> x >> y;
			rotate(a,a+x-1,a+x+y-1);
		}
		cout << a[0] << endl;
	}
	return 0 ;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	int k; cin >>k;
	vector<string> vec;
	for(int i=0;i<s.size();i++){
		for(int j=1;j<=k;j++){
			string a=s.substr(i,j);
			vec.push_back(a);
		}
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());

	cout << vec[k-1]<< endl;
	return 0;
}

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


int main(){
   ll A,B,N;
   cin >> A >> B >> N;

   if(N>=B-1){
     cout << (A*(B-1))/B << endl;
   }
  else{
    cout << (A*N)/B-A*(N/B) << endl;
  }
  
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>

using namespace std;

long long A[200000],B[200001];

int main(){
  long long  N,i;
  long long n=0;
  cin >> N;
  B[0]=0;
  for (i=0;i<N;++i) {
    cin >> A[i];
    n+=A[i];
    B[i+1]=n;
  }
  sort(B, B+(N+1));
  n=0;
  long long mi=0;
  for (i=1;i<N+1;++i) {
    if (B[i-1]!=B[i]) {
      if (i-mi>1) {
        n+=(i-mi)*(i-mi-1)/2;
      }
      mi=i;
    }
  }
  if (N+1-mi>1) {
    n+=(N+1-mi)*(N+1-mi-1)/2;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 3328
A1 = list(map(str, input().split()))
A2 = list(map(str, input().split()))
A3 = list(map(str, input().split()))
#print(A1,A2,A3)
N = int(input())
for i in range(N):
  a = input()
  for j in range(3):
    if a == A1[j]:
        A1[j] = '*'
    if a == A2[j]:
        A2[j] = '*'    
    if a == A3[j]:
        A3[j] = '*'
B1= [A1[0], A2[0], A3[0]]
B2= [A1[1], A2[1], A3[1]]
B3= [A1[2], A2[2], A3[2]]
C1= [A1[0], A2[1], A3[2]]
C2= [A1[2], A2[1], A3[0]]
#print(A1, A2, A3, B1, B2, B3, C1, C2)
if ''.join(A1) == '***' or ''.join(A2) == '***' or ''.join(A3) == '***' or ''.join(B1) == '***' or ''.join(B2) == '***' or ''.join(B3) == '***' or ''.join(C1) == '***' or ''.join(C2) == '***':
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Many Many Paths
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_R = 1000000;
const int MAX_C = 1000000;
const int MAX_N = MAX_R + MAX_C + 2;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int fs[MAX_N + 1], ifs[MAX_R + 2];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

inline int f(int r, int c) {
  return (ll)fs[r + c] * ifs[r] % MOD * ifs[c] % MOD;
}

inline int fsums(int r, int c) {
  return (f(r + 1, c + 1) + MOD - 1) % MOD;
}

/* main */

int main() {
  int r0, c0, r1, c1;
  scanf("%d%d%d%d", &r0, &c0, &r1, &c1);
  r0--, c0--;

  int n = r1 + c1 + 2;
  fs[0] = 1;
  for (int i = 1; i <= n; i++) fs[i] = (ll)fs[i - 1] * i % MOD;

  int m = max(r1, c1) + 1;
  ifs[0] = 1;
  for (int i = 1; i <= m; i++) ifs[i] = powmod(fs[i], MOD - 2);

  int s00 = fsums(r0, c0);
  int s01 = fsums(r0, c1);
  int s10 = fsums(r1, c0);
  int s11 = fsums(r1, c1);

  int sum = (((s11 + (MOD - s10)) % MOD + (MOD - s01)) % MOD + s00) % MOD;
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 11904
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7;
ll OO=1e9;  
const int N=1e3 + 2;
char arr[N][N];
ll dp[N][N];

 
ll n,m,k,cnt,SU,idx,len,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;
vector<pair<ll,ll>> vec;
string str,s,t;
ll MNX,MNY,MXX,MXY,valx,valy;

bool valid(int x,int y){
	return x>-1 && y>-1 && x<n && y<m && arr[x][y]!='#';
}



ll Solve(int x,int y){
	
	if(x == n-1 && y == m-1)
		return 1;
	
	ll &ret = dp[x][y];
	if(~ret)
		return ret;
		
	ret = 0;
	if(valid(x+1,y))
		ret+=Solve(x+1,y);
	if(valid(x,y+1))
		ret+=Solve(x,y+1);

	return ret%MOD;
	
}
 
 
int main(){
	
	memset(dp,-1,sizeof dp);
	
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i)
		scanf("%s",arr+i);
	
	
	printf("%lld\n",Solve(0,0));
	
	
	
 
	
}
 
 
 
 
 
 

 

Measured memory_bytes: 9216
#include <stdio.h>
#include <stdlib.h>
int main(){
    int N,x,y;
    scanf("%d",&N);
    x = N/1000;
    if(N%1000==0){
        y = 0;
        printf("%d",y);
    }
    else{
        y = (x+1)*1000 - N;
        printf("%d",y);
    }
    return 0;
}

Measured memory_bytes: 1732
#ifndef _WIN32
#include<iostream>
#endif

#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

typedef long long LL;
template<typename T>
bool chmin(T &l, T r){
	bool f = l>r; if (f)l = r; return f;
}
template<typename T>
bool chmax(T &l, T r){
	bool f = l<r; if (f)l = r; return f;
}
typedef vector<int> V;
typedef vector<V> VV;

string s;
int N;
int out[26]; 
int ok[1123];
int ch[1123];
V id;
bool isbo(char c){
	switch (c){
	case 'a':
	case 'i':
	case 'u':
	case 'e':
	case 'o':return true;
	default: return false;
	}
}
bool issi(char c){
	switch (c){
	case 'k':
	case 's':
	case 't':
	case 'h':
	case 'p':return true;
	default: return false;
	}
}
void set_init(){
	N = s.size();
	REP(i, N + 10)ok[i] = 0, ch[i] = 0;

	string t;
	REP(i, N){
		if (i!=0&&s[i] == 'y'){
			if (issi(s[i - 1]))ch[t.size() - 1] = 2;
			else t.push_back(s[i]);
		}
		else t.push_back(s[i]);
	}
	s = t;
	N = s.size();
	id.clear();
	REP(i, N)if (isbo(s[i]))id.push_back(i);
}
int main(){
	while (cin >> s, s != "#"){
		set_init();
		FOR(i,1, N - 1)if (s[i] == 'i' || s[i] == 'u'){
			if (issi(s[i - 1]) && issi(s[i + 1]))ok[i] = 1;
		}
		if (s.back() == 'i' || s.back() == 'u'){
			if (N>1&&issi(s[N - 2]))ok[N-1] = 1;
		}

		for (auto &c : { 'a', 'o' })
			REP(l, N)FOR(r,l+4, N+1)if ((r - l) % 2 == 0){
			bool flag = true;
			for (int i = l; i < r; i += 2)if (!issi(s[i]))flag = false;
			for (int i = l+1; i < r; i += 2)if (s[i]!=c)flag = false;
			if (flag){
				for (int i = l + 1; i < r-1; i += 2)ok[i] = true;
			}
		}
		int m = id.size();
		REP(i, m){
			int now = id[i];
			if (ok[now]){
				if (i == 0 || ch[id[i - 1]] == 0)ch[now] = 1;
			}
		}
		string res;
		REP(i, N)if (ch[i]==1){
			res += "(";
			res += s[i];
			res += ")";
		}
		else if (ch[i] == 2){
			res += s[i];
			res += 'y';
		}
		else res += s[i];
		cout << res << endl;
	}

	return 0;
}

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

    if(k % 2 == 0)
    {
        cout << k/2 << " ";
        for(int i = 0; i < n-1; i++)
        {
            cout << k << " ";
        }
        cout << endl;
    }
    else
    {
        int back = n / 2;
        vector<int> ans(n, (k+1)/2);
        for(int i = 0; i < back; i++)
        {
            if(ans.back() != 1)
            {
                ans.back()--;
                int s = ans.size();
                if(s < n)
                {
                    for(int j = 0; j < n-s; j++)
                    {
                        ans.push_back(k);
                    }
                }
            }
            else
            {
                ans.pop_back();
            }
        }
        for(int i = 0; i < ans.size(); i++)
        {
            cout << ans[i] << " ";
        }
    }
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int xs, ys, xt, yt;
int N;
vector<int> X, Y, R;

vv<pair<double, int>> graph;

int main() {
    cin >> xs >> ys >> xt >> yt >> N;
    X.resize(N);
    Y.resize(N);
    R.resize(N);
    graph.resize(N + 2);
    rep(i, N) {
        cin >> X[i] >> Y[i] >> R[i];

        rep(j, i) {
            double cost = max(0.0, hypot(X[i] - X[j], Y[i] - Y[j]) - R[i] - R[j]);
            graph[i].emplace_back(cost, j);
            graph[j].emplace_back(cost, i);
        }

        double cost_s = max(0.0, hypot(X[i] - xs, Y[i] - ys) - R[i]);
        graph[i].emplace_back(cost_s, N);
        graph[N].emplace_back(cost_s, i);
        double cost_t = max(0.0, hypot(X[i] - xt, Y[i] - yt) - R[i]);
        graph[i].emplace_back(cost_t, N + 1);
        graph[N + 1].emplace_back(cost_t, i);
    }

    vector<double> dist(N + 2, 1e18);
    dist[N] = 0;
    dist[N + 1] = hypot(xs - xt, ys - yt);
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
    pq.emplace(0, N);
    int cnt_visited = 0;

    while (!pq.empty()) {
        auto v = pq.top(); pq.pop();
        if (v.first > dist[v.second]) continue;
        else if (++cnt_visited == N + 2) break;

        for (auto& u : graph[v.second]) {
            if (v.first + u.first < dist[u.second]) {
                dist[u.second] = v.first + u.first;
                pq.emplace(v.first + u.first, u.second);
            }
        }
    }

    write(dist[N + 1]);
}

Measured memory_bytes: 22512
program test
      implicit none
      character(:),allocatable :: s
      integer :: n,k,small,big
      
      read*,n,k
      allocate( character(n)::s )
      read*,s
      
      small = ichar('a')
      big = ichar('A')
      
      s(k:k) = char( ichar(s(k:k)) -big+small )
      
      print*,s
      
      
      
      end program
      

Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[n-1]-a[0]);
		in.close();
	}

}

Measured memory_bytes: 22868
#include<cstdio>
#include<cctype>
#define maxn 200005
#define ll long long
using namespace std;
ll n,ans,a[maxn];
inline ll read(){
	ll x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=(x<<3)+(x<<1)+ch-48,ch=getchar();
	return x;
}
int main()
{
	n=read();
	for (ll i=1,s=0,l=1;i<=n;++i){
		a[i]=read();
		while ((s^a[i])!=s+a[i]) s^=a[l++];
		s^=a[i];ans+=i-l+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <string.h>

using namespace std;

int main()
{
    int a,s;
    cin>>a>>s;
    int u=0;
    int c=2*s+1;
    int o=0;
    for( o=0;a>0;o++){
        a-=c;
    }

    cout<<o;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if(S[0]==S[1]&&S[1]==S[2]){
        cout << "Yes";
        return 0;
    }
    if(S[3]==S[1]&&S[1]==S[2]){
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
import bisect

N=int(input())
L=list(map(int,input().split()))

L.sort()

ans=0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        temp=L[i]-L[j]
        idx=bisect.bisect_right(L,temp)
        ans+=max(0,j-idx)
print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(const std::string& s)
{
  return s == "ABC" ? "ARC" : "ABC";
}

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

  std::cout << std::setprecision(20);
  std::cout << solve(s) << std::endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> myvs(n);
    for(int &x : myvs) cin >> x;

    int initial = 1;
    for(int i = 0; i < n; i++) {
        if (myvs[i] == initial) {
            initial++;
        }
    }

    if (initial == 1) {
        cout << -1 << '\n';
    }
    else {
        cout << n-initial+1 << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){

	while(1){
		int data[7]={22,60,6,38,24,42,20},a=0,b=0,sum=0;
		char x;
		rer(i,1,8){
			rer(j,1,8){
				if(!(cin>>x)) return 0;
				//if(cin.eof()) return 0;//!!!!!!!
				if(x=='1'){
					if(a==0 && b==0){
						a=i; b=j;
					}else{
						sum+=10*(i-a)+j-b;
					}
				}
				//o(sum);
			}
		}
		rep(i,0,7){
			if(sum==data[i]){
				char c;
				c='A'+i;
				o(c); break;
			}
		}
	}
}

Measured memory_bytes: 1132
n = int(input())
l = list(map(int,input().split()))

if n==2:
    print(max(l),min(l))
    exit()
maxi = max(l)
med = maxi//2
d = 10**9+1
ans = -1

for i in range(n):
    x = l[i]
    if l[i] > med:
        x = maxi-l[i]
    if med-x < d:
        d = med-x
        ans = l[i]

print(maxi,ans)

Measured memory_bytes: 85208