akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
int32_t main(){
 	fastIO;
 	int n,m;cin>>n>>m;
 	cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
} 	

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
res = a[0]
if 0 in a:
    print(0)
    exit()
for i in range(1, n):
    res *= a[i]
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int a, v, b, w, t, uzaklik, hiz;
	cin >> a >> v >> b >> w >> t;
	if(a >= b){
		uzaklik = a - b;
	}
	else{
		uzaklik = b - a;
	}
	hiz = v - w;
	if(hiz >= uzaklik / (long double)t){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;
 
typedef long long LL;
typedef pair < int, int > pa;
 
inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}
 
const int MAXN = 200020;
 
int q[MAXN], p[MAXN], n, T[MAXN], f[MAXN];
 
int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ ) q[ p[ i ] = read() ] = i;
	for( int i = n - 1 ; i ; i-- )
	{
		if( !T[ i + 1 ] )
		{
			if( q[ i ] > q[ i + 1 ] ) T[ i ] = 1, f[ i ] = i + 1;
			else T[ i ] = 0;
		}
		else
		{
			int cnt = 0;
			cnt += q[ f[ i + 1 ] ] < q[ i ];
			cnt += q[ i ] < q[ i + 1 ];
			cnt += q[ i + 1 ] < q[ f[ i + 1 ] ];
			if( cnt == 2 ) T[ i ] = T[ i + 1 ], f[ i ] = f[ i + 1 ];
			else T[ i ] = T[ i + 1 ] + 1, f[ i ] = i + 1;
		}
	}
	return printf( "%d\n", T[ 1 ] ), 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define N 100000
#define M 100

int main(){
	int i,j,n, ans = 0;

	cin >> i >> j;

	if (i + j == 3) {
		cout << 3 << endl;
	}
	else if (i + j == 4) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A = II()
B = II()
if A > B:
    print("GREATER")
elif A < B:
    print("LESS")
else:
    print("EQUAL")

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

const int N = 1e5 + 5;
int q;

using ll = long long;
ll sum1 = 0, sum2 = 0;

priority_queue<int, vector<int>, greater <int> > min_heap; //keeps larger than median
priority_queue<int> max_heap; //keeps smaller than median

void add(int a){
    if(max_heap.size() && a >= max_heap.top()){
        min_heap.push(a);
        sum2 += a;
    }
    else {
        max_heap.push(a);
        sum1 += a;
    }
    
    if(abs((int)max_heap.size() - (int)min_heap.size()) > 1){
        if(max_heap.size() > min_heap.size()){
            int temp = max_heap.top();
            max_heap.pop();
            sum1 -= temp;
            min_heap.push(temp);
            sum2 += temp;
        }else{
            int temp = min_heap.top();
            min_heap.pop();
            sum2 -= temp;
            max_heap.push(temp);
            sum1 += temp;
        }
    }
}




int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>q;
    int state, cnt = 0;
    ll b = 0;
    for (int i = 0; i < q; i++){
        cin>>state;
        if(state == 1){
            int x,y;
            cnt ++;
            cin>>x>>y;
            b+= y;
            add(x);
        }else{
            ll median;
            if (max_heap.size() >= min_heap.size()){
                median = max_heap.top();
            }else median = min_heap.top();
            cout<<median<<' '<<sum2 - sum1 + median * ((int)max_heap.size() - (int)min_heap.size()) + b<<endl;
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll r,g,b;cin>>r>>g>>b;
    ll n = r*100+g*10+b;
    cout<<(n%4?"NO":"YES");
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int  ep = e.FI;
			Cost ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

int n, q, k;
vector<pair<int, LL>> v[100001];
LL d[100001], INF = 1e14;

int main() {
	cin >> n;
	inc(i, n - 1) {
		LL a, b, c;
		cin >> a >> b >> c;
		v[a].EB(b, c);
		v[b].EB(a, c);
	}
	
	cin >> q >> k;
	inc1(i, n) { d[i] = INF; }
	dijkstra(k, v, d);
	
	inc(i, q) {
		int x, y;
		cin >> x >> y;
		
		cout << d[x] + d[y] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 11120
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    Dice dice = new Dice(stdIn.nextInt() ,stdIn.nextInt() ,stdIn.nextInt() ,stdIn.nextInt() ,stdIn.nextInt() ,stdIn.nextInt());
    String direction = stdIn.next();
    for (int i = 0; i < direction.length(); i++){
      if (direction.charAt(i) == 'N'){
        dice.TurnN();
      }
      else if (direction.charAt(i) == 'W'){
        dice.TurnW();
      }
      else if (direction.charAt(i) == 'E'){
        dice.TurnE();
      }
      else {
        dice.TurnS();
      }
    }
    System.out.println(dice.Top);
  }
}

class Dice{
  int Top;
  int Bottom;
  int N;
  int S;
  int W;
  int E;
  Dice (int a, int b, int c, int d, int e, int f){
    Top = a;
    S = b;
    E = c;
    W = d;
    N = e;
    Bottom = f;
  }
  public void TurnN(){
    int tmp = Top;
    Top = S;
    S = Bottom;
    Bottom = N;
    N = tmp;
  }
  public void TurnW() {
    int tmp = Top;
    Top = E;
    E = Bottom;
    Bottom = W;
    W = tmp;
  }
  public void TurnE() {
    int tmp = Top;
    Top = W;
    W = Bottom;
    Bottom = E;
    E = tmp;
  }
  public void TurnS() {
    int tmp = Top;
    Top = N;
    N = Bottom;
    Bottom = S;
    S = tmp;
  }
}



Measured memory_bytes: 26428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,l,q;
ll x[100010];
ll par[100010][20];

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    cin>>l>>q;
    par[n-1][0] = -1;
    for(int i=0;i<n-1;i++){
        par[i][0] = upper_bound(x,x+n,x[i]+l) - x;
        par[i][0]--;
        //cerr << x[i] << " a " << x[par[i][0]] <<"\n";
    }
    for(int j=1;j<20;j++){
        for(int i=0;i<n;i++){
            if(par[i][j-1]==-1){
                par[i][j]=-1;
                continue;
            }
            par[i][j] = par[par[i][j-1]][j-1];
        }
    }
    while(q--){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        if(a>b)swap(a,b);
        ll ans = 0;
        ll now = 19;
        while(a < b){
            while(now >0 && (par[a][now]==-1 || par[a][now]>b)){
                now--;
            }
            ans += (1LL<<now);
            a = par[a][now];
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200009;

int f[maxn],a[maxn];
int n,ans;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		f[x]=f[x-1]+1;
		ans=max(ans,f[x]);
	}
	cout<<n-ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}





#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // force size of x to be bigger than that of y
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll N, M; cin >> N >> M;

    int a[M], b[M];
    REP(i, M) {
        cin >> a[i] >> b[i], --a[i], --b[i];
    }

    UnionFind uf(N);
    ll ans[M];
    ll cur = N * (N - 1) / 2;
    REP(i, M) {
        ans[M-i-1] = cur;

        int ca = a[M-i-1], cb = b[M-i-1];

        if (uf.issame(ca, cb)) continue;

        ll as = uf.size(ca), bs = uf.size(cb);

        cur -= as * bs;

        uf.merge(ca, cb);
    }

    cout << fixed << setprecision(20);
    REP(i, M) cout << ans[i] << endl;

}


Measured memory_bytes: 3328
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    x = li()
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)




main()




Measured memory_bytes: 9960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<pair<int,int>> tasks;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        tasks.emplace_back(b,a);//(締め切り/所要時間)
    }
    sort(tasks.begin(),tasks.end());
    bool res = true;
    int sum = 0;
    for (auto x:tasks){
        sum+=x.second;
        if (sum > x.first){
            res = false;
            break;
        }
    }
    cout << (res ? "Yes" : "No") << endl;
}


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

using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    if (n<m){
        for (int i=0;i<m;i++){
            cout<<n;
        }
    }
    else{
        for (int i=0;i<n;i++){
            cout<<m;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

// 再帰関数による深さ優先探索
void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v =0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  tt = 0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
int a,b,c,flag;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    if(a+b==c)++flag;
    if(a+c==b)++flag;
    if(b+c==a)++flag;
    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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 V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t n, m, k;
    cin >> n >> m >> k;

    int64_t ans = 0;
    for (int64_t i = n; i <= m; ++i) {
        if ( i%k == 0 ) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
def solve():
    A, B = map(int, input().split())
    for price in range(10000):
        eight = price * 0.08
        ten = price * 0.10
        if int(eight) == A and int(ten) == B:
            print(price)
            break
    else:
        print('-1')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38768
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int h,w,d=0,e=0;
    map<char, int> m;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        string a;
        cin>>a;
        for(int j=0;j<w;j++){
            m[a[j]]++;
        }
    }
    for(auto x=m.begin();x!=m.end();x++){
        int y=x->second;
        if(y%2==1){
            d++;
            y--;
        }
        if(y%4>0)e++;
    }
    if(h%2==1)e-=w/2;
    if(w%2==1)e-=h/2;
    if(h%2+w%2>1)d--;
    if(d>0||e>0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	if(a==b){
		cout<<"a == b"<<endl;
	}
	if(a>b){
		cout<<"a > b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

class UnionFind:

    def __init__(self, n: int):
        self._n = n
        self._parents = [i for i in range(n)]
        self._rank = [1 for _ in range(n)]

    def unite(self, x: int, y: int) -> None:
        px = self.find(x)
        py = self.find(y)

        # 一致していないときはリンクをつける
        if px != py:
            self._link(px, py)

    def _link(self, x: int, y: int):
        if self._rank[x] < self._rank[y]:
            self._parents[x] = y
        elif self._rank[x] > self._rank[y]:
            self._parents[y] = x
        else:
            self._parents[x] = y
            self._rank[y] += 1

    def same(self, x: int, y: int) -> bool:
        px = self.find(x)
        py = self.find(y)
        return px == py

    def find(self, x: int) -> int:
        if self._parents[x] == x:
            return x

        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

N, M = map(int, input().split())
uf = UnionFind(N + 1)

for i in range(M):
    A, B = map(int, input().split())
    uf.unite(A, B)

s = set()
for i in range(1, N + 1):
    s.add(uf.find(i))

print(len(s) - 1)


Measured memory_bytes: 91556
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

const double PI=3.14159265358979323846;
int main() {
    int  R;
    cin >> R;
    double ans = (double)2*PI*R;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	x := nextInt()

	ans := (x/500)*1000 + ((x%500)/5)*5
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define maxn 25
char s[maxn];
int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=1;i<n;i++){
        if(s[i]==',')
            printf(" ");
        else
            printf("%c",s[i]);
    }
    printf("%c\n",s[n]);
    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long n,a,b;
	cin >> n >> a >> b;
	
	if((b-a)&1){
		long long res1=(a)+(b-a-1)/2;
		long long res2=(n-b+1)+(b-a-1)/2;
		cout << min(res1,res2) << "\n";
	}else{
		cout << (b-a)/2 << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

Falling down is an accident, Staying down is a choice.

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2
#define MAXN   1000001
  
// stores smallest prime factor for every number 
ll spf[MAXN];

void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

ll calc(ll x)
{
	map<ll,ll> m; 
    while (x != 1) 
    { 
        m[spf[x]]++; 
        x = x / spf[x]; 
    }
    ll ret=1;
    for(auto a:m)
    {
    	ret*=(a.S+1);
    }
    return ret;
}

ll n,ans=0;

int main()
{
    io;
    sieve();
    cin>>n;
    
    FOR(c,1,n)
    {
    	ans+=calc(n-c);
    }
    
    cout<<ans;
    
    return 0;
}



Measured memory_bytes: 11408
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int sum(int n)
{
    int m,s=0;
    while(n)
    {
        m=n%10;
        s+=m;
        n/=10;
    }
    return s;
}
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
        int n,k;
        cin>>n>>k;
        int a[n];
        read(a,n);
        int sum=1e12;
        for(int i=0;i<n-k+1;i++)
        {   
             sum=min(sum,abs(a[i])+abs(a[i+k-1]-(a[i])));
             sum=min(sum,abs(a[i+k-1])+abs(a[i+k-1]-(a[i])));
        }
        cout<<sum;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 4376
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Measured memory_bytes: 25720
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int hei = sc.nextInt();
			int wid = sc.nextInt();
			String frame = "";
			for (int i = 0; i < wid+2; i++) {
				frame = frame +"#";
			}

			String[] a = new String[hei];
			for (int i = 0; i < hei; i++) {
				a[i] = sc.next();
			}
			for (int i = 0; i < hei; i++) {
				a[i] = "#"+a[i]+"#";
			}

			System.out.println(frame);
			for (int i = 0; i < hei; i++) {
				System.out.println(a[i]);
			}
			System.out.println(frame);

		    sc.close(); }
}


Measured memory_bytes: 21844
def main():
    N = int(input())
    *A, = map(int, input().split())
    A.sort(reverse=True)

    cnt = 1
    ans = 0
    for x in A:
        if cnt == N: break
        if cnt == 1:
            ans += x
            cnt += 1
        else:
            if (use := N - cnt) >= 2:
                ans += x + x
                cnt += 2
            else:
                ans += x
                cnt += 1
                break
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 31436
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, k, q = f.read_int_list()
    a = [f.read_int() for _ in xrange(q)]
    p = [k] * n

    for i in xrange(q):
        p[a[i]-1] += 1

    ans = []
    for i in xrange(n):
        ans.append("Yes") if p[i] > q else ans.append("No")

    return "\n".join(ans)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

long long count(long long a, long long i) {
  long long p = 1LL<<(i+1),
            x = a/p*(p/2);
  if (a&(1LL<<i)) {
    x += a%(p/2)+1;
  }
  return x;
}

void solve() {
  long long a, b; scanf("%lld%lld", &a, &b);
  long long ans = 0;
  a = max(0LL, a-1);
  for (long long i = 0; i < 63; ++i) {
    ans += ((count(b, i) - count(a, i))%2)<<i;
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	vector<int>dp(N, LIMIT);
	dp[0] = 0;
	for (int i = 0; i < N-1; i++) {
		if (i != N - 2) {
			dp[i + 2] = min(dp[i + 2], abs(v[i] - v[i + 2]) + dp[i]);

		}

		dp[i + 1] = min(dp[i + 1], abs(v[i] - v[i + 1]) + dp[i]);
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;
 
int main()
{
    ll N;
    cin >> N;
    ll A, B, C;
    cin >> A >> B >> C;
    vector<ll> l(N);
    rep(i, N) cin >> l[i];
    ll mi = MOD;
    for(ll i = 0; i < (ll)pow(4, N); i++) {
        ll tmp = i;
        ll s1 = 0;
        ll s2 = 0;
        ll s3 = 0;
        ll index = 0;
        ll c = 0;
        while(tmp > 0) {
            if (tmp % 4 == 1) {
                if (s1 != 0) c += 10;
                s1 += l[index];
            } else if (tmp % 4 == 2) {
                if (s2 != 0) c += 10;
                s2 += l[index];
            } else if (tmp % 4 == 3) {
                if (s3 != 0) c += 10;
                s3 += l[index];
            }
            index++;
            tmp /= 4;
        }
        if (s1 == 0 | s2 == 0 | s3 == 0) continue;
        c += abs(s1-A) + abs(s2-B) + abs(s3-C);
        mi = min(mi, c);
    }
    print(mi);
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll x; cin >> x; ll year = 0; ll mon = 100;
  
  while(mon < x){
    mon *= 1.01;
    year++;
  }
  
  cout << year << endl;
}
  
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using Graph = vector<vector<int>>;

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
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; }

int N, M;
Graph G;

// メモ再帰
int dp[100005]; //---- dp[v]: vを始点としたときの、Gの有効パスの長さの最大値

int rec(int v){
    if ( dp[v] != -1 ) return dp[v]; //---- 更新済み

    int res = 0;
    for( int u : G[v] ){ //---- v から行ける各頂点に対して
        chmax( res, rec(u) + 1 ); //---- dp[u] + 1
    }
    return dp[v] = res;
}

int main(){
    cin >> N >> M;
    G.assign(N, vector<int>());
    rep(i,M){
        int x, y;
        cin >> x >> y;
        --x; --y;
        G[x].emplace_back(y);
    }
    for(int v = 0; v < N; ++v) dp[v] = -1; //---- initailization

    int ans = 0;
    for(int v = 0; v < N; ++v) chmax( ans, rec(v) );
    cout << ans;
}

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

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


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

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll n; cin >> n;
    ll ans = 1;

    vector<ll> n0 = divisor(n);
    vector<ll> n1 = divisor(n-1);

    ans += n1.size() -1;

    for(auto v: n0){
        if(v == 1 || v == n) continue;

        ll tmp = n;
        while(tmp %v == 0){
            tmp /= v;
        }

        ll waru = tmp/v;
        tmp = tmp - waru*v;

        while(tmp > 1){
            tmp -= v;
        }

        if(tmp == 1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
def B_0or1Swap():
    N = int(input())
    p = list(map(int, input().split()))
    p_sort = sorted(p)
    num = 0
    ans = "NO"
    for x in range(N):
        if p[x] != p_sort[x]:
            num += 1
    if (0 == num) or (2 == num):
        ans = "YES"
    print(ans)
    
if __name__ == "__main__":
    B_0or1Swap()

Measured memory_bytes: 3064
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll bS(ll l, ll r, ll x, vll arr) {
	while (l <= r) {
		ll m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;
}

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n;
		cin >> n;
		vll vec(n + 1);
		for (ll i = 1; i <= n; i++)
			cin >> vec[i];

		um<ll, ll>hash;
		hash[1 + vec[1]] = 1;
		ll count = 0;

		forn(i, 2, n + 1) {
			hash[i + vec[i]]++;

			if (hash.find(i - vec[i]) != hash.end()) {
				count += hash[i - vec[i]];
			}

		}

		cout << count << endl;

	}
	CLOCK
	return 0;
}
//Credits: Editorial
//Credits: https://codeforces.com/blog/entry/76833?#comment-614691

Measured memory_bytes: 12748
import random
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for k in range(D)]

def score(t):
    ret = 0
    last = [0]*26
    for k in range(D):
        last[t[k]-1] = k+1
        ret += s[k][t[k]-1]
        for i in range(26):
            ret -= c[i]*(k+1-last[i])
    return ret

ans = [1+k%26 for k in range(365)]
prev = score(ans)
for i in range(1,26):
    temp = [1+k%26 for k in range(i,365+i)]
    ima = score(temp)
    if ima > prev:
        prev = ima
        ans = temp[::]
print(*ans,sep="\n")


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::string S){
    cout << ((S == "AAA" || S == "BBB") ? "No" : "Yes") << endl;
}

signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

alice = 0
bob = 0

for i in range(1, n+1):
  
  if i % 2 != 0:
    card = max(a)
    alice += card
  else:
    card = max(a)
    bob += card
  
  a.remove(card)
  
print(alice - bob)

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

template <typename T>
T Pow(T a, ll b) {
	T res = 1;
	while (b) {
		if (b & 1) res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}

ll EX_GCD(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = EX_GCD(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

ll Inverse(ll a, ll mo = 1e9 + 7) {
	ll x, y;
	if (EX_GCD(a, mo, x, y) != 1) return -1;
	return x >= 0 ? x % mo : x % mo + mo;
}

class mint {
	ll val;
public:
	static const ll mod = 1e9 + 7;
public:
	mint() : val(0) {}
	mint(ll v) : val(v % mod) {}
	operator int() { return (int)val; }
	operator ll() { return val; }
	mint inv() { ll res = Inverse(val, mod); assert(res != -1); return res; }
	mint operator+(mint v) { return val + v.val >= mod ? val + v.val - mod : val + v.val; }
	mint operator-(mint v) { return val < v.val ? val + mod - v.val : val - v.val; }
	mint operator*(mint v) { return val * v.val % mod; }
	mint operator/(mint v) { return val * v.inv().val % mod; }
	mint& operator+=(mint v) { *this = *this + v; return *this; }
	mint& operator-=(mint v) { *this = *this - v; return *this; }
	mint& operator*=(mint v) { *this = *this * v; return *this; }
	mint& operator/=(mint v) { *this = *this / v; return *this; }
};
istream& operator >> (istream& is, mint m) { ll v; is >> v; m = v; return is; }
ostream& operator << (ostream& os, mint m) { os << (ll)m; return os; }

const int MAX = 1e5 + 1;

mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	fac[0] = rfac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * mint(i);
		rfac[i] = fac[i].inv();
	}
}

mint combi(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fac[n] * rfac[k] * rfac[n - k];
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> used(n, -1);
	int f, b;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i]; a[i]--;
		if (used[a[i]] != -1) {
			f = used[a[i]];
			b = i;
		}
		used[a[i]] = i;
	}
	init();
	for (int i = 1; i <= n + 1; i++) {
		cout << (combi(n + 1, i) - combi(n - b + f, i - 1)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3584
rate = int(input())
if ( rate >= 400 ) and ( rate < 600 ):
	print ("8")
elif(rate >= 600 and rate < 800 ):
	print ("7")
elif(rate >= 800 and rate < 1000 ):
	print ("6")
elif(rate >= 1000 and rate < 1200 ):
	print ("5")
elif(rate >= 1200 and rate < 1400 ):
	print ("4")
elif(rate >= 1400 and rate < 1600 ):
	print ("3")
elif(rate >= 1600 and rate < 1800 ):
	print ("2")
elif(rate >= 1800 and rate < 2000 ):
	print ("1")

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    IOS;
    int n,m;
    cin >> n >> m;
    vector<int> a(n+1);
    int s = 0 , x = 0;
    for(int i = 0; i < n;i++){
        cin >> a[i];
        s += a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    for(int i = 0; i < n; i++){
        float u = 0.25 * 1/m * s;
        if(u > a[i])
            break;
        else
            x++;
    }
    if(x >= m){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3628
//
// Created by Hideaki Imamura on 2020-01-02.
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool is_prime(ll n) {
    if (n <= 1) return false;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

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

    while (true) {
        if (is_prime(x)) {
            cout << x << endl;
            break;
        } else {
            x++;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    string s;
    cin >> s;
    int count=0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define ll long long
int main(){
	ll a,b,x; cin>>a>>b;
	while(b--) cin>>x,a-=x;
	if(a<=0) cout<<"Yes"; else cout<<"No";
}


Measured memory_bytes: 3592
N,M=map(int,input().split())

ans=0
pen=0
answered=set()
tp=[0]*(10**5+10)

for _ in range(M):
    P,S=input().split()
    p=int(P)
    if not p in answered:
        if S=='WA':
            tp[p]+=1
        elif S=='AC':
            answered.add(p)
            ans+=1
            pen+=tp[p]

print(ans,pen)

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

int main(){
    int n,d;cin>>n>>d;
    cout<<(n+2*d)/(2*d+1)<<endl;
    return 0;
}

Measured memory_bytes: 256