akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
const int maxn=1e5+5;

int t,q,p;
char ch;
char c[maxn];
char begin[maxn*2];
char end[maxn*2];
int k1=maxn*2-5;
int k2=0;

int main(){
	scanf("%s%d",c,&t);
	int change=1;
	while(t--){
		scanf("%d",&q);
		if(q==1)
			change=-change;
		else{
			scanf("%d %c%*c",&p,&ch);
			if(p==1){
				if(change>0)
				    begin[k1--]=ch;
				else 
					end[k2++]=ch;
			}
			else{
				if(change>0)
					end[k2++]=ch;
				else
					begin[k1--]=ch;
			}
		}
	}
	begin[k2]='\0';
	if(change>0){
		for(int i=k1+1;i<=maxn*2-5;i++)
			printf("%c",begin[i]);
		printf("%s",c);
		for(int i=0;i<k2;i++)
		    printf("%c",end[i]);
		printf("\n");
	}
	else{
		for(int i=k2-1;i>=0;i--)
			printf("%c",end[i]);
		int len=strlen(c)-1;
		for(int i=len;i>=0;i--)
			printf("%c",c[i]);
		for(int i=maxn*2-5;i>k1;i--)
			printf("%c",begin[i]);
		printf("\n");
	}
	
	return 0;
}
	

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

template<int N>
struct disjoint_sets {
	int r[N];
	disjoint_sets() {
		memset(r,~0,sizeof(r));
	}
	int get(int x) {
		return r[x]<0 ? x : r[x]=get(r[x]);
	}
	int size(int x) {
		return -r[get(x)];
	}
	bool join(int x,int y) {
		x=get(x);
		y=get(y);
		if (x==y) return false;
		if (r[x]>r[y]) swap(x,y);
		r[x]+=r[y];
		r[y]=x;
		return true;
	}
};

int const MAXN=110000;
int N;
int x[MAXN],y[MAXN];
vector<int> by_x[MAXN];
disjoint_sets<MAXN> ds;
set<int> by_y[MAXN];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N;
	rep(i,0,N) {
		cin>>x[i]>>y[i];
		by_x[x[i]].push_back(y[i]);
	}
	
	rep(i,1,MAXN) rep(j,1,sz(by_x[i])) ds.join(by_x[i][j],by_x[i][j-1]);
	
	rep(i,0,N) by_y[ds.get(y[i])].insert(x[i]);
	
	ll res=0;
	rep(i,1,MAXN) if (ds.get(i)==i) res+=ll(ds.size(i))*sz(by_y[i]);
	cout<<res-N<<"\n";
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  int n;cin>>n;
  vector<ll>A(n);
  vector<ll>B(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>A[i];
    sum+=A[i];
  }
  vector<ll>used(n);
  vector<ll>tari(n);
  for(int i=0;i<n;i++){
    cin>>B[i];
    used[i]=max(0LL,A[i]-B[i]);
    tari[i]=max(0LL,B[i]-A[i]);
  }
  sort(ALL(used),greater<ll>());
  sort(ALL(tari));
  int cnt=0;
  int ans=0;
  vector<ll>C(n);
  bool usedfl=true;
  bool can=true;
  for(int i=0;i<n;i++){
    if(tari[i]>0)ans++;
    while(cnt<n&&tari[i]>0){
      // cout<<cnt<<" "<<used[cnt]<<" "<<tari[i]<<endl;
      if(used[cnt]==0){can=false;}
      ll num=max(0LL,tari[i]);
      ll num2=used[cnt];
      used[cnt]-=tari[i];
      if(usedfl){ans++;usedfl=false;}
      tari[i]-=num2;
      if(used[cnt]<=0){
	usedfl=true;
	cnt++;
      }
    }
  }
  if(can){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}


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

int main() {
  int n; cin>>n;
  vector<ll> a(n), b(n);
  rep(i, n) cin>>a[i];

  sort(a.begin(), a.end());
  int ans=1;
  ll sum=0;
  rep(i, n) {
    sum+=a[i];
    b[i]=sum;
  }
  rep(i, n-1) {
    if (b[i]*2>=a[i+1]) ans++;
    else ans=1;
  }
  cout<<ans<<endl;
}

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

int main(){
    int n,b;
    cin >> n;
    int a[13][4]={};
    char ch;
    for(int i = 0;i<n;i++){
        cin >> ch >> b;
        if(ch=='S'){
            a[b-1][0]=b;
        }else if(ch == 'H'){
            a[b-1][1]=b;
        }else if(ch == 'C'){
            a[b-1][2]=b;
        }else{
            a[b-1][3]=b;
        }
    }
    for(int j = 0;j<4;j++){
        for(int k = 0;k<13;k++){
            if((a[k][j]==0)&&(j==0)){
                cout << "S "<<k+1<<endl;
            }else if((a[k][j]==0)&&(j==1)){
                cout << "H "<<k+1<<endl;
            }else if((a[k][j]==0)&&(j==2)){
                cout << "C "<<k+1<<endl;
            }else if((a[k][j]==0)&&(j==3)){
                cout << "D "<<k+1<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin >> S >> T;

    int count=0;

    for(int i=0,j=0;i<S.size(),j<T.size();i++,j++)
    {
        if(S[i]!=T[j])
            count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		int a = Integer.parseInt(nums[0]);
		int b = Integer.parseInt(nums[1]);

		int fa = 0;
		for (int i = 1; i < b - a; i++)
			fa += i;

		System.out.println(fa - a);

	}

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2)
    {
        if(a==b)
            printf("Yes\n");
        else if((a==4 || a==6 || a==9 || a==11) && (b==4 || b==6 || b==9 || b==11))
            printf("Yes\n");
         else if((a==1 || a==3 || a==5 || a==7 || a==10|| a==8 || a==12) && (b==1 || b==3 || b==5 || b==7 || b==8|| b==10 || b==12))
            printf("Yes\n");
            else printf("No\n");
    }
    return 0;
}


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

#define llint long long int

using namespace std;

int main()
{
    int H, W, M;

    cin >> H >> W >> M;

    vector<int> c_y(H + 1, 0), c_x(W + 1, 0);
    map<string, bool> mp;

    for (int i = 1; i <= M; i++)
    {
        int h, w;

        cin >> h >> w;

        c_y[h]++;
        c_x[w]++;

        stringstream ss;
        ss << h << ',' << w;
        mp[ss.str()] = 1;
    }
    int y_max = 0;
    vector<int> ys;

    for (int i = 1; i <= H; i++)
    {
        if (c_y[i] > y_max)
        {
            y_max = c_y[i];
            ys.clear();
            ys.push_back(i);
        }
        else if (c_y[i] == y_max)
        {
            ys.push_back(i);
        }
    }
    int x_max = 0;
    bool masuniaru = false;
    int x, y;

    for (int i = 1; i <= W; i++)
    {
        if (c_x[i] > x_max)
        {
            x_max = c_x[i];
            x = i;
            bool flag = false;
            for (int y_ : ys)
            {
                stringstream ss;
                ss << y_ << ',' << i;
                if (mp.find(ss.str()) == mp.end())
                {
                    y = y_;
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                masuniaru = false;
            }
            else
            {
                masuniaru = true;
            }
        }
        else if (masuniaru && c_x[i] == x_max)
        {
            for (int y_ : ys)
            {
                stringstream ss;
                ss << y_ << ',' << i;
                auto it = mp.find(ss.str());
                if (it == mp.end())
                {
                    y = y_;
                    x = i;
                    masuniaru = false;
                    break;
                }
            }
        }
    }
    if (masuniaru)
    {
        cout << x_max + y_max - 1 << endl;
    }
    else
    {
        cout << x_max + y_max << endl;
    }
}

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

#define MAX 100

int n,m;
char chair[MAX+2];
  
void A()
{
    for (int i = 1; i <= n; i++) {
	if (chair[i] == '#') {
	    chair[i] = 'A';
	    return;
	}
    }
}
 
void B()
{
    int pos = -1;
    for (int i = 1; i <= n; i++) {
	if (chair[i] == 'A') {
	    pos = i;
	    break;
	}
    }
   
    if (pos == -1) {
	for (int i = n; i > 0; i--) {
	    if (chair[i] == '#') {
		chair[i] = 'B';
		return;
	    } 
	}
    } else {
	for (int i = n; i > 0; i--) {
	    if (chair[i] == '#' && chair[i-1] != 'A' && chair[i+1] != 'A') {
		chair[i] = 'B';
		return;
	    }
	}
  
	for (int i = 1; i <= n; i++) {
	    if (chair[i] == '#') {
		chair[i] = 'B';
		return;
	    }
	}
    }
}
  
void C()
{
    int cnt = count(chair, chair+n, '#');
  
    if (cnt == n) {
	if (n % 2) {
	    chair[(n+1)/2] = 'C';
	} else {
	    chair[n/2+1] = 'C';
	}
    } else {
	for (int i = 1; i <= n; i++) {
	    if (chair[i] != '#' && chair[i+1] == '#' && i != n) {
		chair[i+1] = 'C';
		return;
	    }
	    if (chair[i] != '#' && chair[i-1] == '#' && i != 1) {
		chair[i-1] = 'C';
		return;
	    }
	}
    }
}
  
void D()
{
    int Breadth = 0, pos;
    int cnt = count(chair, chair+n, '#');
 
    if (cnt == n) {
	chair[1] = 'D';
	return;
    } 
 
    for (int i = 1; i <= n; i++) {
	int dist = (1<<29);
	if (chair[i] != '#') continue;
	for (int j = 1; j <= n; j++) {
	    if (chair[j] != '#') {
		dist = min(dist, abs(j-i)+1);
	    }
	}
	if (Breadth < dist) {
	    Breadth = dist;
	    pos = i;
	} 
    }
  
    chair[pos] = 'D';
}
  
int main()
{
    while (cin >> n >> m, n | m) {
	char person;
  
	for (int i = 0; i <= n+1; i++) {
	    chair[i] = '#';
	}
  
	for (int i = 0; i < m; i++) {
	    cin >> person;
       
	    switch (person) {
                case 'A': 
                    A(); 
                    break;
                case 'B': 
                    B(); 
                    break;
                case 'C': 
                    C(); 
                    break;
                case 'D': 
                    D(); 
                    break;
	    }
	}
	for (int i = 1; i <= n; i++) {
	    cout << chair[i];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3012
def main():
    INF = 2 ** 60
    n = int(input())
    hs = list(map(int, input().split()))

    dp = [INF for _ in range(n)]
    dp[0] = 0

    for i in range(1, n):
        if i == 1:
            dp[1] = abs(hs[0] - hs[1])
        else:
            dp[i] = min(dp[i - 1] + abs(hs[i - 1] - hs[i]), dp[i - 2] + abs(hs[i - 2] - hs[i]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 20568
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main() {
	int n; cin >> n;
	map<int, int> m1, m2;
	pair<int, int> fmax1, fmax2, smax1, smax2;
	for (int i = 0; i < n; ++i) {
		int v; cin >> v;
		if (i & 1) {
			m2[v]++;
			if (m2[v] > fmax2.second) {
				if (v == smax2.second) swap(fmax2, smax2);
				fmax2 = { v,m2[v] };
			} else if (m2[v] > smax2.second) smax2 = { v,m2[v] };
		} else {
			m1[v]++;
			if (m1[v] > fmax1.second) {
				if (v == smax1.second) swap(fmax1, smax1);
				fmax1 = { v,m1[v] };
			} else if (m1[v] > smax1.second) smax1 = { v,m1[v] };
		}
	}
	int ans = n;
	if (fmax1.first != fmax2.first) ans -= fmax1.second + fmax2.second;
	else ans -= max(fmax1.second + smax2.second, smax1.second + fmax2.second);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
import Data.Array

main = do
  li <-getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  mapM_ print ans

compute :: Int -> [Int] -> [Int]
compute n as = elems $ accumArray (+) 0 (1,n) [(a,1)|a <- as]


Measured memory_bytes: 64140
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, w;
    std::cin >> n >> w;

    std::vector<std::pair<long long, long long>> goods(n);

    for (int i = 0; i < n; i++) {
        std::cin >> goods[i].first >> goods[i].second;
    }

    std::vector<std::vector<long long>> dp(n + 1, std::vector<long long>(1e5 + 1, 1e9 + 1));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1e5 + 1; j++) {
            if (j - goods[i].second >= 0) {
                dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j - goods[i].second] + goods[i].first);
            }
            dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
        }
    }

    long long ans = 0;
    for (int i = 0; i < 1e5 + 1; i++) {
        if (dp[n][i] <= w) {
            ans = i;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 80256
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// debug
#define debug(x) cout << (#x) << ": " << x << endl;
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    
    if(a1 + a2 + a3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int B[110];
int C[110];

signed main() {
    int N;
    cin >> N;
    int sum = 0;
    rep(i, N) {
        int a;
        cin >> a;
        sum += a;
        B[i] = a * N;
    }
    int cmin = INF;
    rep(i, N) {
        C[i] = abs(B[i] - sum);
        cmin = min(cmin, C[i]);
    }
    rep(i, N) {
        if (C[i] == cmin) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

nums = sorted(x)
m1 = n//2-1
m2 = n//2
for i in range(n):
  if x[i] <= nums[m1]: print(nums[m2])
  elif nums[m2] <= x[i]: print(nums[m1])

Measured memory_bytes: 30892
n, quantum = list(map(int, input().split()))
queue = []
sumOfTime = 0

for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while len(queue) > 0:
    name, time = queue.pop(0)
    if time > quantum:
        sumOfTime += quantum
        queue.append([name, time - quantum])
    else:
        sumOfTime += time
        print(name, sumOfTime)



Measured memory_bytes: 13012
#include <cstdio>

int main(void)
{
	int n, q, s[10000], t[500];
	int ans = 0;
	scanf("%d", &n);
	for(int i = 0; i != n; i++) {
		scanf("%d", s + i);
	}
	scanf("%d", &q);
	for(int i = 0; i != q; i++) {
		scanf("%d", t + i);
		for(int j = 0; j != n; j++) {
			if(t[i] == s[j]) {
				ans++;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

map<ll, ll> mp;

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

    ll n, k;cin >> n >> k;
    ll ans = 0;

    vector<ll> v(n+1);
    REP(i, n){
        cin >> v[i+1];
        v[i+1] = (v[i+1] - 1 + k) % k;
        if(i)v[i+1] = (v[i] + v[i+1]) % k;
    }

    REP(i, n+1){
        if(i >= k)mp[v[i-k]]--;
        //cout << v[i] << " " << mp[v[i]] << endl;
        ans += mp[v[i]];
        mp[v[i]]++;
    }

    cout << ans << endl;

	return 0;
}


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

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

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int W, H, N;

    int left = 0, bottom = 0;

    cin >> W >> H >> N;
    rep(i, N){
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1) {
            if(left < x) left = x;
        }else if(a == 2) {
            if(W > x) W = x;
        }else if(a == 3) {
            if(bottom < y) bottom = y;
        }else {
            if(H > y) H = y;
        }
    }

    if(W > left && H > bottom){
        cout << (W - left) * (H - bottom) << endl;
    }else {
        cout << 0 << endl;   
    }   
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  auto t = vector<int>(n,0);
  auto x = vector<int>(n,0);
  auto y = vector<int>(n,0);
  for(int i=0;i<n;i++){
  	cin >> t[i] >> x[i] >> y[i];
  }
  
  auto x_b =0;
  auto y_b =0;
  auto sum =0;
  bool f = true;
  for(int i=0;i<n;i++){
    sum += abs(x[i]-x_b)+abs(y[i]-y_b);
    if(t[i]<sum||(t[i]-sum)%2==1) f=false;
  	x_b = x[i];
    y_b = y[i];
  }
  
  if(f){
  	cout << "Yes";
  }else{
  	cout << "No";
  }
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int change;
map<int,int>mp;
int main(){
	//freopen("readin.txt","r",stdin);
	int n;
	cin >> n;
	mp[399] = 0;
	mp[799] = 0;
	mp[1199] = 0;
	mp[1599] = 0;
	mp[1999] = 0;
	mp[2399] = 0;
	mp[2799] = 0;
	mp[3199] = 0;
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d",&a);
		if(a >= 3200){
			change++;
			continue;
		}
		if(a < 400)
			mp[399]++;
		if(a > 399 && a < 800)
			mp[799]++;
		if(a > 799 && a < 1200)
			mp[1199]++;
		if(a > 1199 && a < 1600)
			mp[1599]++;
		if(a > 1599 && a < 2000)
			mp[1999]++;
		if(a > 1999 && a < 2400)
			mp[2399]++;
		if(a > 2399 && a < 2800)
			mp[2799]++;
		if(a > 2799 && a < 3200)
			mp[3199]++;
	}
	int ans = 0,temp = change;
	for(map<int,int>::iterator i = mp.begin();i != mp.end();i++){
		if(i->second == 0)
			continue;
		temp = 0;
		ans++;
	}
	cout << ans + (temp != 0)<< " ";
	cout << ans + change<< endl;
}

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

int main(){
    int n;
    cin >> n;
    map<string, int>total_res;
    string res[] = {"AC", "WA", "TLE", "RE"};
    total_res["AC"] = 0;
    total_res["WA"] = 0;
    total_res["TLE"] = 0;
    total_res["RE"] = 0;
    for(int i = 0; i < n; i++){
        string temp;
        cin >> temp;
        ++total_res[temp];
    }
    cout<<"AC x "<<total_res["AC"]<<endl;
    cout<<"WA x "<<total_res["WA"]<<endl;
    cout<<"TLE x "<<total_res["TLE"]<<endl;
    cout<<"RE x "<<total_res["RE"]<<endl;
}

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

using namespace std;

int main()
{
	int i = 0;
	string str;

	getline(cin, str);

	while(str[i] != 0){
		if(str[i] >= 97 && str[i] <= 122){
			str[i] -= 32;
			cout << str[i];
		}
		else
			cout << str[i];
		i++;
	}

	cout << endl;

	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if(n<=k) cout<<s<<'\n';
    else
    {
        string ans="";
        rep(i,k) ans+=s[i];
        ans+="...";
        cout<<ans<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3672
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    vector<ll> v(a),s(a+1,0);
    for(int i=0;i<a;i++)
    {
        scanf("%lld",&v[i]);
        v[i]--;
        s[i+1] = (s[i]+v[i]+b)%b;
    }

    map<int,int> mp;
    ll ans=0;
    for(int i=0;i<=a;i++)
    {
        if(i-b>=0)mp[s[i-b]]--;
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 12800
//54
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

struct S{
  int v,p,t;
  bool operator<(S a)const{
    return t>a.t;
  }
};

int main(){
  for(int n;cin>>n,n;){
    int d[21][21];
    fill(d[0],d[21],1<<29);
    int cn[21]={};
    for(int i=0;i<n-1;i++){
      int a,b,t;
      cin>>a>>b>>t;
      d[a][b]=d[b][a]=t;
      cn[a]++;
      cn[b]++;
    }
    int np=0;
    for(int i=1;i<=n;i++){
      np|=(cn[i]!=1)<<i;
    }
    priority_queue<S> que;
    S is={1,2,0};
    que.push(is);
    static bool p[21][1<<20];
    fill(p[0],p[21],false);
    for(;;){
      S c=que.top();
      if((np&~c.p)==0)break;
      que.pop();
      if(p[c.v][c.p>>1]++)continue;
      for(int i=1;i<=n;i++){
	if(d[c.v][i]!=1<<29){
	  S ns={i,c.p|1<<i,c.t+d[c.v][i]};
	  que.push(ns);
	}
      }
    }
    cout<<que.top().t<<endl;
  }
  return 0;
}

Measured memory_bytes: 22804
N=int(input())
a=4/N
h_st=max(int(N*(1/4))-1,1)
#h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if 4*h*n*n-(n*n+h*n+h*n)*N<=0 and 4*h*n*3500-(n*3500+h*3500+h*n)*N>=0:

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)


Measured memory_bytes: 43628
alpha = {1:'a', 2:'b', 3:'c', 4:'d', 5:'e', 6:'f', 7:'g', 8:'h', 9:'i', 10:'j', 11:'k', 12:'l', 13:'m', 14:'n', 15:'o', 16:'p', 17:'q', 18:'r', 19:'s', 20:'t', 21:'u', 22:'v', 23:'w', 24:'x', 25:'y', 0:'z'}
n = int(input())
t = ''
while n > 0:
  k = n % 26
  t = alpha[k] + t
  n //= 26
  if k == 0:
    n -= 1
print(t)


Measured memory_bytes: 9204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class EMajorityOfBalls {
public:

    int n;
    int isRed(int a) {
      cout << "? ";
      rep(i, n) {
        cout << a+i << ' ';
      }
      cout << endl;
      string s; cin >> s;
      return (s == "Red") ? 1 : -1;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      cin >> n;
      vector<int> dp(n+2);
      int mi = 1;
      int ma = n+1;
      dp[mi] = isRed(mi);
      dp[ma] = isRed(ma);
      while(mi+1 < ma) {
        int med = (mi+ma)/2;
        dp[med] = isRed(med);
        if (dp[mi] == dp[med]) {
          mi = med;
        } else {
          ma = med;
        }
      }

      vector<int> ball(2*n+1);
      ball[mi] = dp[mi];
      ball[mi+n] = dp[ma];
      debug(ball[mi], ball[mi+n]);

      vector<int> v1, v2;
      for(int i=1; i<=2*n; i++) {
        if (i == mi || i == mi+n) continue;
        if (ma <= i && i < mi+n) {
          v1.push_back(i);
        } else {
          v2.push_back(i);
        }
      }

      for(auto e1: v1) {
        cout << "? " << e1 << ' ';
        for(auto e2: v2) {
          cout << e2 << ' ';
        }
        cout << endl;
        string s; cin >> s;
        ball[e1] = (s == "Red") ? 1 : -1;
      }

      for(auto e2: v2) {
        cout << "? " << e2 << ' ';
        for(auto e1: v1) {
          cout << e1 << ' ';
        }
        cout << endl;
        string s; cin >> s;
        ball[e2] = (s == "Red") ? 1 : -1;
      }

      cout << "! ";
      for(int i=1; i<=2*n; i++) {
        cout << ((ball[i] == 1) ? 'R' : 'B');
      }
      cout << endl;
    }
};

signed main() {
  EMajorityOfBalls solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        
        ans+=2*min(abs(0-hoge),abs(k-hoge));
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
S=input()
N=len(S)
strings = ["maerd", "remaerd", "esare", "resare"]
tmp = ""
for i in range(N-1, -1, -1):
    if tmp not in strings:
        tmp += S[i]
        if tmp in strings:
            tmp = ""
if tmp:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 82268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  for(int h=1; ; ){
    if(h>n)break;
    G.push_back(h);
    h=3*h+1;
  }
  for(int i=G.size()-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  cnt=0;

  shellSort(A,n);

  cout<<G.size()<<endl;
  for(int i=G.size()-1;i>=0;i--){
    printf("%d",G[i]);
    if(i)printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(int i=0;i<n;i++)printf("%d\n",A[i]);

  return 0;
}

Measured memory_bytes: 7124
N, M = map(int,input().split())
right = {}
for i in range(M):
    li = list(map(int,input().split()))
    right[i] = li[1:]

p = list(map(int,input().split()))


ans = 0

for pattern in range(2**N):
    ri = 0
    for i, v in right.items():
        cnt = 0
        for sw in v:
            if pattern & (1 << (sw-1)) != 0:
                cnt += 1
        if cnt % 2  == p[i]:
            ri += 1

    if ri == M:
        ans += 1

print(ans)



Measured memory_bytes: 40944
# -*- coding: utf-8 -*-
import math
# スペース区切りの整数の入力
a, b = map(int, input().split())

if(a>=13):
	c = b
elif(a>=6):
	c = b/2
else:
	c = 0

# 出力
#print("{}".format(c))
print(math.floor(c))

Measured memory_bytes: 3060
/*
I've been down this road once or twice before
through the open door
i come falling through it
there's a sign post up ahead
like a watershed
and it opens my eyes
ways, for me to begin
to be born again
and knowing for the first time
ways, all so differently
shine for me to see
the better man that I am

I've been places in my head
behind me worse than what's ahead
and on my path just like a dream
takes me from the inbetween
from out of nowhere you came strong as stone
and now I'll never have to be alone
what it is I know

you have always been my safe home
I walk, I run, I burn out into you
you have always been my safe home
my whole world has moved on

i know what i am and I'll always be
your reality, is better than I could dream
all my fears turn from black to white
and i'd stand and fight
the whole world for you
faith, and destiny
I never did believe
my only god is love and
faith, what I see in you
and I can hold it true
like a weight in my hand.
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int n,ans[N],ar[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;

	for (int i=1;i<=n;i++){
		cin>>ar[i];
		ans[ar[i]]=1;
		ans[ar[i]]=max(ans[ar[i]],ans[ar[i]-1]+1);
	}

	int answ=0;
	for (int i=1;i<=n;i++){
		answ=max(answ,ans[i]);
	}
	cout<<n-answ<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

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

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

  sort(L.begin(), L.end());

  int n = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[k] < (L[i] + L[j]) && L[i] < (L[j] + L[k]) && L[j] < (L[k] + L[i])) {
          n++;
        }
      }
    }
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    float t,j,s;
    int n,i,k,a[1000];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    if(n==2)
    {
        t=(a[0]+a[1])/2.00;
        printf("%0.2lf",t);

    }
    else{
    t=(a[0]+a[1])/2.00;
    for(k=2;k<n;k++)
    {
        j=(t+a[k])/2.00;
        t=j;
    }
    printf("%0.2lf",t);
    }
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
R, G = 0, 0


def set_inputs():
    global R, G
    R = get_int()
    G = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    print((G - R) * 2 + R)
    return


if __name__ == '__main__':
    main()


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

int main(int argc, char *argv)
{
    long long n, p;

    long long maxCommon; 
    long long maxN;
    long long i;
    long long num;

    scanf("%lld %lld", &n, &p);

    if (n == 1) {
        printf("%lld\n", p);
        return 0;
    }

    maxCommon = 1;
    maxN = pow(p, 1/((double)n));

    // i = 2のとき
    while (1) {
        num = pow(maxCommon * 2, n);

        if (p % num == 0) {
            maxCommon *= 2;
        } else {
            break;
        }
    }

    i = 3;
    while(i <= maxN) {
        num = pow(maxCommon * i, n);
        if (num > p) {break;}

        if (p % num == 0) {
            maxCommon *= i;
        } else {
            i += 2;
        }
    }

    printf("%lld\n", maxCommon);

    return 0;
}


Measured memory_bytes: 384
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int s;
    s = sc.nextInt();
    System.out.println((s / 3600) + ":" + ((s % 3600) / 60) + ":" + (s % 60));
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17172
let mod = 1000000007

let line = readLine()!.split(separator: " ").map({Int($0)!})
let N = line[0]
let K = line[1]
var ans = 0
for i in K...(N + 1) {
    ans += i * (N + 1 - i) + 1
    ans %= mod
}
print(ans)


Measured memory_bytes: 8240
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	    String[] st = sc.readLine().split(" ");
	    int[] x = new int[5];
	    for(int i=0; i<5; i++)
		x[i] = Integer.valueOf(st[i]);
	    
	    Arrays.sort(x);
	    System.out.printf("%d %d %d %d %d\n",x[4],x[3],x[2],x[1],x[0]);
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 11000
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  ll B[N - 1];
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  ll sum = B[0] + B[N - 2];
  for (int i = 0; i < N - 2; i++) {
    sum += min(B[i], B[i + 1]);
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;
#define MAX_V 330

typedef long long ll;

int main(void) {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) {
    int j;
    if (n % i == 0) j = n / i;
    if (i < 10 && j < 10) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    const lint M = 1001000;
    // const lint M = 20;
    vector<vector<lint>> primes(M + 1, vector<lint>(0));
    for (int p = 2; p <= M; p++) {
        if (primes[p].size() != 0) continue;
        for (int pk = p; pk <= M; pk += p) {
            primes[pk].push_back(p);
        }
    }

    vector<lint> min_factor(M, 1);
    for (int p = 2; p <= M; p++) {
        if (min_factor[p] != 1) continue;
        for (int pk = p; pk <= M; pk += p) {
            if (min_factor[pk] == 1) min_factor[pk] = p;
        }
    }
    // dump(min_factor);

    lint G      = 0;
    rep(i, N) G = __gcd(G, A[i]);
    if (G != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    set<lint> used;
    for (int i = 0; i < N; i++) {
        // for (auto p : primes[A[i]]) {
        //     if (used.count(p) == 1) {
        //         cout << "setwise coprime" << endl;
        //         return 0;
        //     } else {
        //         used.insert(p);
        //     }
        // }

        set<lint> primess{};
        int a = A[i];
        // if (a == 1) continue;
        while (a != 1) {
            primess.insert(a / min_factor[a]);
            a /= min_factor[a];
        }
        for (auto p : primes[A[i]]) {
            if (used.count(p) == 1) {
                cout << "setwise coprime" << endl;
                return 0;
            } else {
                used.insert(p);
            }
        }
    }

    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 88988
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll n;
  cin >> n;
  vector<ll> A(n);
  REP(i, n) cin >> A[i];
  sort(ALL(A));
  cout << A[n-1] << " ";
  ll MAX1=A[0];
  ll MAX2=A[n-2];
  if(A[n-1]%2==1){
    REP(i,n-1){
      if(A[i]<=A[n-1]/2){
        MAX1=max(MAX1,A[i]);
      }else if(A[i]>=A[n-1]/2+1){
        MAX2=min(MAX2,A[i]);
      }
    }
    if(A[n-1]/2-MAX1<MAX2-(A[n-1]/2+1)){
      cout << MAX1 << endl;
    }else{
      cout << MAX2 << endl;
    }
  }else{
    REP(i,n-1){
      if(A[i]<=A[n-1]/2){
        MAX1=max(MAX1,A[i]);
      }else if(A[i]>=A[n-1]/2){
        MAX2=min(MAX2,A[i]);
      }
    }
    if(A[n-1]/2-MAX1<MAX2-A[n-1]/2){
      cout << MAX1 << endl;
    }else{
      cout << MAX2 << endl;
    }
  }
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int, int>P;
#define INF 1000000000

struct edge {
	int from, to;
	edge(int from, int to) {
		this->from = from; this->to = to;
	}
};

int V, E;
typedef vector<edge> edges;
vector<edges> G;

int h, w;

ll func(ll h, ll w) {
	ll ans = 100005LL * 100005LL;
	for (ll i = h / 3; i <= (h + 2) / 3; i++) {
		ll x = h - i;
		ll y = x / 2;
		ll z = (x + 1) / 2;
		ll a1 = y*w, a2 = i*w, a3 = z*w;
		ll ma = max(max(a1, a2), a3);
		ll mi = min(min(a1, a2), a3);
		ans = min(ans, abs(ma - mi));
		y = w / 2;
		z = (w + 1) / 2;
		a1 = i*w; a2 = y*(h - i); a3 = z*(h - i);
		ma = max(max(a1, a2), a3);
		mi = min(min(a1, a2), a3);
		ans = min(ans, abs(ma - mi));

	}
	return ans;
}

int main() {
	cin >> h >> w;

	ll ans = func(h, w);
	ans = min(ans, func(w, h));

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

/*
2 3 3

2 8
 */
public class Main {
	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt(), x=fs.nextInt()-1, y=fs.nextInt()-1;
		ArrayList<Integer>[] adj=new ArrayList[n];
		for (int i=0; i<n; i++) adj[i]=new ArrayList<>();
		for (int i=0; i+1<n; i++) {
			adj[i].add(i+1);
			adj[i+1].add(i);
		}
		adj[x].add(y);
		adj[y].add(x);
		int[] ans=new int[n];
		for (int from=0; from<n; from++) {
			int[] d=bfs(adj, from);
			for (int i=0; i<n; i++)
				ans[d[i]]++;
		}
		for (int i=1; i<n; i++) {
			System.out.println(ans[i]/2);
		}
	}
	
	static int[] bfs(ArrayList<Integer>[] adj, int from) {
		int n=adj.length;
		ArrayDeque<Integer> bfs=new ArrayDeque<>();
		int[] res=new int[n];
		Arrays.fill(res, -1);
		res[from]=0;
		bfs.add(from);
		while (!bfs.isEmpty()) {
			int at=bfs.remove();
			for (int o:adj[at]) {
				if (res[o]==-1) {
					res[o]=res[at]+1;
					bfs.add(o);
				}
			}
		}
		return res;
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		
	}

}


Measured memory_bytes: 52244
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>n;
    a=1;
    for(int i=1;i<=n;i++){
        a*=i;
        a%=1000000007;
    }
    C a E;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

def SelectionSort(N, A):
    cnt = 0
    for i in range(N):
        min_i = i
        for j in range(i, N):
            if A[j] < A[min_i]:
                min_i = j
        if i != min_i:
            A[i], A[min_i] = A[min_i], A[i]
            cnt += 1
    return A, cnt
    
res = SelectionSort(N, A)
print(" ".join(map(str, res[0])))
print(res[1])

Measured memory_bytes: 7744
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<list>
#include<vector>
#define LEN 100005
using namespace std;
//list実装
//cinだと遅い　scanf
int main(){
    stack<int> s1;
    stack<pair<int,int> > s2;
    char ch;
    int sum=0;
    for(int i=0;cin>>ch;i++){
        if(ch=='\\')s1.push(i);
        else if(ch=='/'&&s1.size()>0){
            int j=s1.top();s1.pop();
            sum+=i-j;
            int a=i-j;
            while(s2.size()>0&&s2.top().first>j){
                a+=s2.top().second;s2.pop();
            }
            s2.push(make_pair(j,a));
        }
    }
    
    vector<int> ans;
    while(s2.size()>0){ans.push_back(s2.top().second);s2.pop();}
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }

    cout<<endl;
return 0;
}



Measured memory_bytes: 3244