akhauriyash/Code-Regression huggingface dataset:
#include <iostream>


int main()
{
    long N;
    long S[200000];
    std::cin >> N;
    char c;
    for (int i = 0; i < N; i++) {
        std::cin >> c;
        if (c == '.') {
            S[i] = 0; // white
        } else if (c == '#') {
            S[i] = 1; // black
        } else continue;
    }

    long white[200001];
    long black[200001];
    long answer = N;
    white[N] = 0;
    black[0] = 0;
    for (int i = 1; i <= N; i++) {
        if (S[i - 1] == 1) {
            black[i] = black[i - 1] + 1;
        } else {
            black[i] = black[i - 1];
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 0) {
            white[i] = white[i + 1] + 1;
        } else {
            white[i] = white[i + 1];
        }
    }
    for (int i = 0; i <= N; i++) {
        long temp = white[i] + black[i];
        answer = temp < answer ? temp : answer; 
    }

    std::cout << answer << std::endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];


void solve() 
{
  ll n,d;
  cin>>n>>d;
  ll x,y,c=0;
  ll t=d*d;
  for(ll i=0;i<n;i++)
  {
    cin>>x>>y;
    ll a=x*x;
    ll b=y*y;
    if(a+b<=t)
    {
        c++;
    }
  }
  cout<<c;
  
}

int main() 
{
  
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    
      solve();
    

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10692
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}


ll N, M;
vector<ll> a;
vector<bool> used;
vector<vector<ll>> graph;

// 違うグループで，使ってなくて，一番小さい物どうしで辺をはる
// そのグループでの小さい順のリストと，used


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

    cin >> N >> M;
    if (N - 1 == M) {
        cout << 0 << endl;
        return 0;
    }

    used.resize(N);
    REP(i, N) {
        ll t;
        cin >> t;
        a.push_back(t);
        used[i] = false;
    }

    graph.resize(N);
    REP(i, M) {
        ll l, r;
        cin >> l >> r;
        graph[l].push_back(r);
        graph[r].push_back(l);
    }

    vector<vector<ll>> groups;
    int count = 0;
    REP(i, N) {
        if (used[i]) continue;

        vector<ll> node_group;
        queue<ll> que;
        que.push(i);
        while (!que.empty()) {
            ll n = que.front(); que.pop();
            node_group.push_back(a[n]);
            used[n] = true;
            for (ll c : graph[n]) {
                if (!used[c]) que.push(c);
            }
        }
        sort(all(node_group));
        groups.push_back(node_group);
        count++;
    }


    ll ans = 0;
    if (N < count) {
        cout << "Impossible" << endl;
        return 0;
    }

    int remain = (count - 1) * 2;
    vector<ll> rest;
    for (auto score : groups) {
        for (int i = 0 ; i < score.size(); i++) {
            if (i == 0) {
                // どのグループも一番小さいものは使う
                ans += score[0];
                remain--;
            } else {
                rest.push_back(score[i]);
            }
        }
    }

    if (rest.size() < remain) {
        cout << "Impossible" << endl;
        return 0;
    }
    // すべてのノードからremain個のノードを選ぶ
    sort(all(rest));
    REP(i, remain) {
        ans += rest[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[(int)2e5 + 100];
ll dp[(int)2e5 + 100];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i = 1;i<=n;i++)cin>>arr[i];
	dp[0] = 2;
	for(ll i = 1;i<=k;i++){
		dp[i] = 2;
		for(ll j = 1;j<=n;j++){
			if(i - arr[j] >= 0)dp[i] = min(dp[i], 3 - dp[i - arr[j]]); 
		}
	}
	if(dp[k] == 1)
	cout<<"First";
	else
	cout<<"Second";
	return 0;
}

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

using namespace std;

int ex[] = {1, 0, -1, 0};
int ey[] = {0, 1, 0, -1};

int bfs(int s, int t, vector<string>& S){
  int H = S.size();
  int W = S[0].size();
  int s_i = s / W;
  int s_j = s % W;
  int t_i = t / W;
  int t_j = t % W;
  if(S[s_i][s_j] == '#' || S[t_i][t_j] == '#') return 0;
  
  vector<vector<int>> dist(H, vector<int>(W, -1));
  dist[s_i][s_j] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(s_i, s_j));
  while(!q.empty()){
    pair<int, int> p = q.front();
    q.pop();
    int y = p.first;
    int x = p.second;
    for(int i = 0; i < 4; i++){
      int dx = ex[i];
      int dy = ey[i];
      if(0 <= x + dx && x + dx < W && 0 <= y + dy && y + dy < H){
        if(S[y + dy][x + dx] == '.' && dist[y + dy][x + dx] == -1){
          dist[y + dy][x + dx] = dist[y][x] + 1;
          q.push(make_pair(y + dy, x + dx));
        }
      }
    }
    if(dist[t_i][t_j] >= 0) break;
  }
  
  return dist[t_i][t_j];
}

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }
  
  int d = 0;
  for(int s = 0; s < H * W - 1; s++){
    for(int t = s + 1; t < H * W; t++){
      d = max(d, bfs(s, t, S));
    }
  }
  
  cout << d << endl;
  
  return 0;
}

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

int main(){
    char s[101];
    long long k;
    cin >> s;
    cin >> k;
    if(k==1 && s[0]=='1') cout << "1" << endl;
    else if(s[0]!='1') cout << s[0] << endl;
    else{
        for(int i=1; s[i]!='\0'; i++){
            if(i+1==k){
                cout << s[i] << endl;
                break;
            }
            if(s[i]!='1'){
                cout << s[i] << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=-1000&&b<=1000)
    {
        if(a<b)
            printf("a < b\n");
        else if(a>b)
            printf("a > b\n");
        else
            printf("a == b\n");

    }
    return 0;
}



Measured memory_bytes: 2092
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cassert>

using namespace std;

typedef long long ll;

#define SIZE 100010
#define INF 1000000000

int main(){
  int n;
  string s;
  
  cin >> n;

  int dp[26];
  for(int i=0;i<26;i++) dp[i] = INF;
  
  for(int i=0;i<n;i++){
    cin >> s;

    int f = s[0] - 'a';
    int e = s[s.size()-1] - 'a';

    if(i == 0){
      dp[f] = 0;
    }

    if(i == n-1){
      cout << dp[f] + 1 << endl;
      return 0;
    }

    dp[e] = min(dp[e], dp[f]+1);
  }

  assert(false);


}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline void read(int &x){
    char c=getchar();
    int p=1;
    x=0;
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^'0');
        c=getchar();
    }
    x*=p;
}

const int MAXN=2e6+7;

static int n;

static int fac[MAXN],inv[MAXN];

const int mod=1e9+7;

inline int power(int a,int b)
{
	static int sum;
	for(sum=1;b;b>>=1,a=(long long)a*a%mod)if(b&1)
		sum=(long long)sum*a%mod;
	return sum;
}

inline void init()
{
	read(n);
	fac[0]=1;
	Rep(i,1,n+5)fac[i]=(long long)fac[i-1]*i%mod;
	inv[n+5]=power(fac[n+5],mod-2);
	Repe(i,n+5,1)inv[i-1]=(long long)inv[i]*i%mod;
}

inline int C(int a,int b)
{
	if(a<b)return 0;
	return (long long)fac[a]*inv[b]%mod*inv[a-b]%mod;
}

static int f[MAXN],ans;

inline void Add(int &a,int b){if((a+=b)>=mod)a-=mod;}

inline void solve()
{
	Rep(i,0,n/2-1)f[i]=(long long)C(n-i-2,i)*fac[n-i-1]%mod*fac[i]%mod;
	Rep(i,0,n/2-1)Add(ans,(long long)(f[i]-f[i+1]+mod)%mod*(n-i-1)%mod);
	printf("%d\n",ans);
}

int main(){
	init();
	solve();
	return 0;
}


Measured memory_bytes: 14464
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    int ai[]={1,1,1,0,0,-1,-1,-1};
    int aj[]={1,0,-1,-1,1,1,0,-1};
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#')cout<<"#";
            else{
                int cnt=0;
                rep(d,0,8){
                    int ni=i+ai[d];
                    int nj=j+aj[d];
                    if(ni>=0&&ni<h&&nj>=0&&nj<w){
                        if(s[ni][nj]=='#')cnt++;
                    }
                }
                cout<<cnt;
            }
        }
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define SENTINEL 1000000000
#define MAX 500000
int count=0,n;
void Merge(int x[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1],R[n2];
  for(i=0;i<n1;i++){
    L[i]=x[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=x[mid+i];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      x[k]=L[i];
      i++;
    }
    else{
      x[k]=R[j];
      j++;
    }
    count++;
  }
}
void Merge_Sort(int x[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    Merge_Sort(x,left,mid);
    Merge_Sort(x,mid,right);
    Merge(x,left,mid,right);
  }
}
int main(){
  int i;
  scanf("%d",&n);
  int x[n];
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  Merge_Sort(x,0,n);
  for(i=0;i<n;i++){
    printf("%d",x[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 4508
import sys
sys.setrecursionlimit(10000)


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


class UnionFind():
    def __init__(self, size):
        self.dat = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        dat = self.dat
        stack = [x]
        while True:
            y = stack[-1]
            if dat[y] != y:
                stack += [dat[y]]
            else:
                break
        for s in stack:
            dat[s] = y
        return y

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        dat = self.dat
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = dat[X] = Y
            else:
                m = dat[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

    def is_same(self, x, y):
        find = self.find
        return find(x) == find(y)

    def scan_uf(self):
        find = self.find
        length = len(self.dat)
        for i in range(length):
            find(i)

    def size(self, x):
        return self.SIZE[self.find(x)]


N, K = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
STmax = SegmentTree(array=P, f=max, ti=-float('inf'))
STmin = SegmentTree(array=P, f=min, ti=float('inf'))
UF = UnionFind(N - K + 1)
for i in range(N - K):
    if P[i] == STmin.query(i, i + K) and P[i + K] == STmax.query(
            i + 1, i + K + 1):
        UF.unite(i, i + 1)
inc = 0
incK = []
for i in range(N - 2, -1, -1):
    if P[i] <= P[i + 1]:
        inc += 1
        if inc >= K - 1:
            incK += [i]
    else:
        inc = 0
for i in incK:
    UF.unite(incK[0], i)
UF.scan_uf()
print(len(set(UF.dat)))


Measured memory_bytes: 126592
N,K = map(int,input().split())
A = list(map(int,input().split()))

loop = [1]
arrived = [0] * N
now = 1
arrived[now-1] = 1
for i in range(K):
    now = A[now-1]
    if arrived[now-1] == 0:
        arrived[now-1] = 1
        loop.append(now)
    else:
        loop = loop[loop.index(now):]
        arrive = loop[(K-(i+1))%len(loop)]
        print(arrive)
        exit()
print(now)



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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll int h,w,n;
map<pair<int,int>, ll int> m;

int main(){
	cin >> h >> w >> n;
	REP(i,n){
		int a,b;
		cin >> a >> b;
		a--; b--;
		REP(j,3){
			REP(k,3){
				int nx = (a - j);
				int ny = (b - k);
				if(nx < 0 || ny < 0 || nx + 2 >= h || ny + 2 >= w) continue;
				if(m.find(mp(nx,ny)) == m.end()) m[mp(nx,ny)] = 1;
				else m[mp(nx,ny)]++;
			}
		}
	}
	ll int ans[10] = {0};
	ll int sum = 0;
	for(auto d : m){
		// cout << d.first.first << " " << d.first.second << " : " << d.second << endl;
		ans[d.second]++;
		sum++;
	}
	ans[0] = (h-2)*(w-2)-sum;
	REP(i,10) cout << ans[i] << endl;
}

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

int main()
{
    int N;
    cin >> N;
    set<string> s;
    string Si;
    for(int i=0;i<N;i++){
        cin >> Si;
        s.insert(Si);
    }
    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 19200
#include<iostream>
using namespace std;
int main(){
    int X,ans,count;
    bool num[1000001]={};
    for(int i=2;i<=1000000;i++){
        if(!num[i]) 
        for(int j=i*2;j<=1000000;j+=i)  num[j] = true;
    }
    while(cin >> X)
    {
        count = 0;
        for(int i=2;i<=X;i++){
            if(!num[i]) count++;
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 4032
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N,x;
    cin >> N >> x;

    vector<ll> a(N);

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

    sort(a.begin(),a.end());
    int i=0;
    int cnt = 0;
    while(true){
        //cout << cnt << endl;
        if(x==a[i] && i == (a.size()-1)){
            cnt++;
            break;
        }
        else if(i==(a.size()-1)){
            break;
        }
        else if(x>=a[i]){
            cnt++;
            x-=a[i];
            i++;
        }
        else if(x<a[i]){
            break;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  REP(i, 0, n) cin >> a[i];
  sort(ALL(a));
  cout << a[n - 1] - a[0] << endl;

  return 0;
}


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

class Main {
    private static int[] calcPrimes(int n) {
        boolean[] table = new boolean[n + 1];
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        int counter = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                counter++;
            }
        }
        int[] result = new int[counter];
        int index = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                result[index++] = i;
            }
        }
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] primes = calcPrimes(200000);

        while (true) {
            int n = scanner.nextInt();
            int p = scanner.nextInt();
            if (n == -1 && p == -1) {
                break;
            }
            for (int i = 0; i < primes.length; i++) {
                if (primes[i] > n) {
                    int[] sum = new int[p * (p + 1) / 2];
                    int index = 0;
                    for (int j = 0; j < p; j++) {
                        for (int k = j; k < p; k++) {
                            sum[index++] = primes[i + j] + primes[i + k];
                        }
                    }
                    Arrays.sort(sum);
                    System.out.println(sum[p - 1]);
                    break;
                }
            }
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string o, e;
  cin >> o >> e;
  int n = o.size() + e.size();
  int cnt = 1;
  int num1 = 0, num2=0;
  for(int i=0; i<n; ++i){
    if(cnt%2==1){
      cout << o[num1];
      num1++;
    }
    else{
      cout << e[num2];
      num2++;
    }
    cnt++;
  }

}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];

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

	cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
N,Q = list(map(int,input().split()))

e_list = [[] for i in range(N)]

for i in range(N-1):
        a,b = list(map(int,input().split()))
        a,b = a-1,b-1
        e_list[a].append(b)
        e_list[b].append(a)

add_list = [0]*N

for i in range(Q):
        p,x = list(map(int,input().split()))
        p = p-1
        add_list[p]+=x

count_list = [0]*N
count_list[0] = add_list[0]

vi = 0 #時と場合によってここを変える
from collections import deque
Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.append(v1)
            count_list[v1] = count_list[v]+add_list[v1]

print(*count_list)

Measured memory_bytes: 109132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll a, b, n;

ll f(ll x){
    return ((a * x) / b) - (a * (x / b));
}


// bool isOK(ll x, ll key) {
//     if (f(x) >= key) return true;
//     else return false;
// }

// ll binary_search(ll key) {
//     ll ok = -1;
//     ll ng = 1e+9+7;
//     while (abs(ok - ng) > 1) {
//         ll mid = (ok + ng) / 2;
//         if (isOK(mid, key)) ok = mid;
//         else ng = mid;
//     }
//     return ok;
// }


int main(){
    cin >> a >> b >> n;
    cout << f(min(b - 1, n)) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  int h,w,n,x,c;cin>>h>>w>>n;
  x=max(h,w); c=0;
  while(x*c<n) c++;
  
  cout<<c;
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){var r=e.split("\n"),t=Number(r[0]),n=r[1].split(" ").map(function(e){return Number(e)});if(2!=t){var o=new Array(t);o[0]=n[0];for(var u=1;u<t;u++)o[u]=n[u]+o[u-1];for(var i=9999999999,f=1;f<t-1;f++)Math.abs(o[t-1]-o[f]-o[f])<i&&(i=Math.abs(o[t-1]-o[f]-o[f]));console.log(i)}else console.log(Math.abs(n[0]-n[1]))}},function(e,r){e.exports=require("fs")}]);

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

using namespace std;

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

  int i = 1;
  bool ok = true;
  for(auto &ss:s){
    if(i % 2 != 0 && (ss == 'R' || ss == 'U' || ss == 'D')) ;
    else if(i % 2 == 0 && (ss == 'L' || ss == 'U' || ss == 'D')) ;
    else{
      ok = false;
      break;
    }
    i++;
  }
  if(ok) cout << "Yes";
  else cout << "No";
}
    


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  cout << (N % 2 == 0 ? N : N * 2) << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = sorted(A)

visited = [0] * n  
idxs = {}  
for i, b in enumerate(B):
    idxs[b] = i

saisyo = min(A)  

ans = 0
for i in range(n):
    if visited[i]:
        continue  
    cur = i  
    S = 0  
    n2 = 0
    m = float("inf")
    while True:
        visited[cur] = True
        S += A[cur]
        m = min(m, A[cur])
        n2 += 1
        cur = idxs[A[cur]]
        if visited[cur]:
            break 
    ans += min(m*(n2-2)+S, m+S+(1+n2)*saisyo)

print(ans)


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N, M;

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

  cin >> N >> M;
  set< int > from;
  set< int > to;
  REP(i, M) {
    CIN(a, b);
    if (a == 1) {
      from.erase(b);
      from.insert(b);
    }
    if (b == N) {
      to.erase(a);
      to.insert(a);
    }
  }

  bool ok = false;
  EACH(t, to) {
    if (from.find(t) != from.end()) ok = true;
    if (ok) break;
  }

  OK(ok);

  return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


// X = a_k * (p + 0.5)
// a_k = 2a_k'
// X = a_k' * (2p + 1)
// 公倍数 X >= 3 * max{a_k'}

// p = (X / a_k' - 1)/2
// p = (X - a_k') / 2a_k'
// p = (X - a_k') / a_k
// p: 整数
// X - a_k': a_kの倍数


#define MAX_N 100'000
#define MAX_M 1'000'000'000

i64 N, M;
set<i64> A;

i64 gcd(i64 a, i64 b) {
    if (a < b) swap(a, b);

    i64 t;
    while(b > 0) {
        t = a % b;
        a = b;
        b = t;
    }

    return a;
}

i64 lcm(i64 a, i64 b) {
    return a * b / gcd(a, b);
}

void solve() {
    i64 x = 1;  // a_i / 2のLCM
    for (auto it = A.begin(); it != A.end(); it++) {
        x = lcm(x, *it);
    }

    for (auto it = A.begin(); it != A.end(); it++) {
      if ((x / (*it)) % 2 == 0) {
        cout << 0 << endl;
        return;
      }
    }

    i64 cnt = (M / x + 1) / 2;
    cout << cnt << endl;
}

int main() {
    cin >> N >> M;
    i64 a;
    REP(i, N) {
      cin >> a;
      A.insert(a / 2);
    }

    solve();

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define a109 1000000009
#define mod 1000000007
#define pb push_back
using namespace std;

int n,k,mn;
int dp[200005];
int dizi[302];

int dpf(int tas){
	if(tas<0){
		return 1;
	}
	if(tas<mn){
		return 0;
	}
	if(dp[tas]!=-1)
		return dp[tas];
	int mx=1;
	for(int i=0;i<n && mx;i++){
		mx=min(dpf(tas-dizi[i]),mx);
	}
	mx=!mx;
	dp[tas]=mx;	
	return dp[tas];
}	


int main(){

	// freopen("a.gir","r",stdin);
 //    freopen("a.cik","w",stdout);
	for(int i=0;i<100005;i++){
		dp[i]=-1;
	}
	mn=INT_MAX;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&dizi[i]);
		mn=min(mn,dizi[i]);
	}
	if(dpf(k)){
		printf("First\n");
	}
	else
		printf("Second\n");
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N=0,L=0;
  cin>>N >>L;
  vector<string>S(N);
  
  for (int i=0;i<N;i++){
    cin>>S[i];
  }
  sort(S.begin(),S.end());
  
  for (int j=0;j<N;j++){
    cout<<S[j];
  }
  
  return 0;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline


def main():
    t1, t2 = map(int, input().split())
    a1, a2 = map(int, input().split())
    b1, b2 = map(int, input().split())

    P = t1 * (b1 - a1)
    Q = t2 * (b2 - a2)
    if P + Q == 0:
        print("infinity")
        return
    if P * (P + Q) > 0:
        print(0)
        return
    P = abs(P)
    Q = abs(Q)
    T = P % (Q - P)
    S = P // (Q - P)
    if T == 0:
        ans = 2 * S
    else:
        ans = 2 * S + 1
    print(ans)


main()


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

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

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


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


namespace 競プロCS {
    class ABC162B {
        static void Main() {
            int n = int.Parse(Console.ReadLine());
            long total = 0;
            for (int i = 1; i < n + 1; i++) {
                if (!((i % 3 == 0) || (i % 5 == 0))) {
                    total += i;
                }
            }

            Console.WriteLine(total);

        }

    }
}


Measured memory_bytes: 27544
#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(obj) (obj).begin(),(obj).end()
typedef pair<int,int> P;
typedef pair<ll,P> Edge;
struct unionfind{
  vector<int> par;
  vector<int> size;
  unionfind(int n):par(n),size(n,1){
    rep(i,n)par.at(i)=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return root(par[x]);
  }
  void unit(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(size[par[x]]<size[par[y]])swap(x,y);
    par[y]=x;
    size[x]+=size[y];
  }
  bool find(int x,int y){
    x=root(x);
    y=root(y);
    return x==y;
  }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  vector<Edge> es;
  vector<int> id(n);
  iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](int i,int j){return x[i]<x[j];});
  rep(i,n-1){
    int u=id[i],v=id[i+1];
    es.push_back(Edge(x[v]-x[u],P(u,v)));
  }
  sort(id.begin(),id.end(),[&](int i,int j){return y[i]<y[j];});
  rep(i,n-1){
    int u=id[i],v=id[i+1];
    es.push_back(Edge(y[v]-y[u],P(u,v)));
  }
  sort(es.begin(),es.end());
  unionfind uf(n);
  ll ans=0;
  for(auto k:es){
    int u=k.second.first,v=k.second.second;
    if(uf.find(u,v))continue;
    ans+=k.first;
    uf.unit(u,v);
  }
  cout<<ans<<endl;
  return 0;
  }


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

#define MAX 201
#define MAXx2 402
#define MAXSHUFFLE 100

int
main ()
{
  char str[MAX];
  char temp[MAXx2] = {0};
  int kaisuu = 0;
  int h[MAXSHUFFLE] = {0};
  int i, j, k, size;

  while (1)
    {
      /* initialize */
	  
      for (i = 0; i < MAX; i++)
		{
		  str[i] = '\0';
		}

      /* data acquire */

	  scanf("%s\n", str);
	  
      if (str[0] == '-')
		{
		  return 0;
		}
      else
		{
		  size = strlen(str);
		  scanf ("%d\n", &kaisuu);
		  for (i = 0; i < kaisuu; i++)
			{
			  scanf ("%d\n", &h[i]);
			}
		}
	  
      /* process */
	  
      for (i = 0; i < kaisuu; i++)
		{
		  
		  for (j = 0; j < MAXx2; j++)
			{
			  temp[j] = '\0';
			}
		  
		  strcat (temp, str);
		  strcat (temp, str);

		  for (k = 0; k < size; k++)
			{
			  str[k] = temp[k + h[i]];
			}

		  for (k = size; k < MAX; k++)
			{
			  str[k] = '\0';
			}
		}
	  
	  /* print result */
	  
	  printf ("%s\n", str);
	}  
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		h, w;
queue<p>	que;
vector<vector<char>>	m(100, vector<char>(100));
vector<vector<int>> o(100, vector<int>(100));

int		map_check(p coordi){
	if (coordi.first < 0 || coordi.second < 0)
		return (0);
	if (coordi.first >= h || coordi.second >= w)
		return (0);
	return (1);
}

char	get_char(vector<vector<char>> v, p c){
	return (v[c.first][c.second]);
}

int		get_int(vector<vector<int>> v, p c){
	return (v[c.first][c.second]);
}

void	dfs(p c){
	vector<p> v = {p(0, 1), p(1, 0)};
	int	i = 0;
	p t;
	while (i < 2){
		t.first = c.first + v[i].first;
		t.second = c.second + v[i].second;
		i++;
		if (!(map_check(t)))
			continue ;
		if (get_char(m, t) == get_char(m, c) || get_char(m, c) == '#'){
			if (get_int(o, t) > get_int(o, c)){
				o[t.first][t.second] = get_int(o, c);
				dfs(t);
			}
		} else {
			if (get_int(o, t) > get_int(o, c) + 1){
				o[t.first][t.second] = get_int(o, c) + 1;
				que.push(t);
			}
		}
	}
}

int		main(void){
	cin >> h >> w;
	int		i, j;
	i = 0;
	while (i < h){
		j = 0;
		while (j < w){
			cin >> m[i][j];
			o[i][j] = INF;
			j++;
		}
		i++;
	}
	o[0][0] = 0;
	if(m[0][0] == '#')
		o[0][0]++;
	que.push(p(0, 0));
	while (!(que.empty())){
		dfs(que.front());
		que.pop();
	}
	cout << o[h-1][w-1] << endl;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
tree = [-i for i in range(n+1)]
rank = [1 for _i in range(n+1)]
def search_root(num, tree=tree):
    if tree[num] < 0:
        return num
    else:
        tree[num] = search_root(tree[num])
        return tree[num]

for _i in range(m):
    x, y, z = map(int, input().split())
    x, y = sorted([search_root(x), search_root(y)])
    if x==y:
        continue
    else:
        if rank[x]<rank[y]:
            rank[y] += 1
            tree[x] = y
        else:
            rank[x] += 1
            tree[y] = x
print(sum(1 for i in tree if i<0))

Measured memory_bytes: 7860
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll q;cin>>q;
    while(q--){
        ll l,r,t;cin>>l>>r>>t;
        for(ll i=0;i<r-l;i++){
            swap(a[l+i],a[t+i]);
        }
    }
    for(ll i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    

    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int arr[n+1];
    arr[0]=0;
    arr[1]=0;
    arr[2]=abs(h[1]-h[0]);
    for(int i=3;i<n+1;i++){
        int x=abs(h[i-1]-h[i-2]);
        int y=abs(h[i-1]-h[i-3]);
        arr[i]=min(arr[i-1]+x,arr[i-2]+y);     
    }
    cout<<arr[n]<<endl;
    return 0;
    
}


Measured memory_bytes: 4316
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

string s;

int main() {
  cin >> s;

  solve();

  return 0;
}

void solve() {

  ll size = (int)(s.size());

  ll ans = 0;
  for(int mask=0; mask<(1<<size); ++mask) {
    ll keep = 0;
    for(int i=0; i<size; ++i) {
      if(mask >> i & 1) {
        ans += keep;
        keep = 0;
      }else {
        keep *= 10;
        keep += (s[i]-'0');
      }
    }
    ans += keep;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin>>N;
	vector<ll> A(3*N);
	for(int i=0;i<3*N;i++) cin>>A[i];

	//1
	vector<ll> maxtable(3*N);
	priority_queue<ll,vector<ll>,greater<ll>> pq;
	ll sum=0;
	for(int i=0;i<N;i++){
		sum+=A[i];
		pq.push(A[i]);
	}
	maxtable[N-1]=sum;
	for(int i=N;i<2*N;i++){
		if(A[i]>=pq.top()){
			sum+=A[i];
			sum-=pq.top();
			pq.pop();
			pq.push(A[i]);
		}
		maxtable[i]=sum;
	}

	//2
	reverse(A.begin(),A.end());
	vector<ll> mintable(3*N);
	priority_queue<ll> pq2;
	sum=0;
	for(int i=0;i<N;i++){
		sum+=A[i];
		pq2.push(A[i]);
	}
	mintable[N-1]=sum;
	for(int i=N;i<2*N;i++){
		if(A[i]<=pq2.top()){
			sum+=A[i];
			sum-=pq2.top();
			pq2.pop();
			pq2.push(A[i]);
		}
		mintable[i]=sum;
	}
	reverse(mintable.begin(),mintable.end());

	/*for(int i=0;i<3*N;i++) cout<<maxtable[i];
	cout<<endl;
	for(int i=0;i<3*N;i++) cout<<mintable[i];
	cout<<endl;*/

	ll Ans=LLONG_MIN;
	for(int i=N-1;i<2*N;i++) if(maxtable[i]-mintable[i+1]>=Ans) Ans=maxtable[i]-mintable[i+1];
	cout<<Ans<<endl;
	return 0;
}



Measured memory_bytes: 9588
#include <stdio.h>
long long n, x, y, ans, z, w;
int main() {
	scanf("%lld", &n);
	if (n == 2) {
		printf("1\n");
		return 0;
	}
	x = n - 1;
	y = 2;
	while (y * y <= x) {
		if (x % y == 0) {
			ans += 2;
			if (y * y == x)ans--;
		}
		y++;
	}
	y = 2;
	while (y * y <= n) {
		if (n % y == 0) {
			z = n;
			while (z % y == 0)z /= y;
			if (z % y == 1)ans++;
			if (y * y != n) {
				z = n;
				w = n / y;
				while (z % w == 0)z /= w;
				if (z % w == 1)ans++;
			}
		}
		y++;
	}
	printf("%lld\n", ans + 2);
}

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

int main(void) {
    int64_t N;
    int64_t sum,maxsum = 0;
    int64_t last;
    cin >> N;
    vector<int64_t> H(N);
    for(int i=0;i<N;i++) {
        cin >> H[i];
    }

    sum = 0;
    last = H[N-1];
    for(int i=N-2;i>=0;i--) {
        if(H[i] >= last) {
            sum++;
            if(maxsum < sum) {
                maxsum = sum;
            }
        } else {
            sum = 0;
        }
        last = H[i];
    }

    cout << maxsum << "\n";
    return 0;
}


Measured memory_bytes: 1024
//#include<iostream>
#include<stdio.h>
using namespace std;

int main() {

	int a, i;
	for (i = 1; ; i++) {
		scanf("%d", &a);
		if (a == 0) break;
		printf("Case %d: %d\n", i, a);
	}
	return 0;
}


Measured memory_bytes: 2740
import java.util.Scanner;
public class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        String S = scan.nextLine();

        if("Sunny".equals(S)){
            System.out.print("Cloudy");
        }else if("Cloudy".equals(S)){
            System.out.print("Rainy");
        }else{
            System.out.print("Sunny");
        }

        




        }
    }


Measured memory_bytes: 19412
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll K, X;
    cin >> K >> X;

    cout << X - (K - 1);
    for (ll i = X - (K - 2); i <= X + (K - 1); i++)
    {
        cout << " " << i;
    }

    cout << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+1<c)cout<<b+(a+b+1)<<endl;
	else cout<<b+c<<endl;
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int s1=stoi(s.substr(0,2));
	int s2=stoi(s.substr(2,2));
	string k;
	if(s1 > 0 && s1 < 13)
	{
		if(s2 > 0 && s2 < 13)
		{
			k = "AMBIGUOUS";
		}
		else
		{
			k = "MMYY";
		}
	}
	else
	{
		if(s2 > 0 && s2 < 13)
		{
			k = "YYMM";
		}
		else
		{
			k = "NA";
		}
	}
	cout << k << endl;
	return 0;
}
//YYMM, MMYY, AMBIGUOUS, NA 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    if(A<=C&&C<=B)cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

using namespace std;

long long a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> a >> b;
    if(a * 500 >= b){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256