akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
*/



int main() {
	int X, Y;
	cin >> X >> Y;
	lint ans = 0;
	if (X == 1 && Y == 1) {
		ans += 400000;
	}
	if (X == 1) {
		ans += 300000;
	}
	if (X == 2) {
		ans += 200000;
	}
	if (X == 3) {
		ans += 100000;
	}
	if (Y== 1) {
		ans += 300000;
	}
	if (Y== 2) {
		ans += 200000;
	}
	if (Y == 3) {
		ans += 100000;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
integer n
integer,allocatable,dimension(:)::x,y
integer ans
read*,n
allocate(x(n),y(n))
read*,x
read*,y

ans=0
do i=1,N
  if(x(i)-y(i)>0)ans=ans+x(i)-y(i)
end do
print"(I0)",ans
end

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    // S+1にしとけば全部消える
    ll N,K,S;
    cin >> N >> K >> S;

    vector<int> ans(N);
    REP(i,K){
        ans[i] = S;
    }

    FOR(i,K,N){
        ans[i] = S+1;
        if(S==1000000000) ans[i]=S-1;
    }

    REP(i,N-1){
        cout << ans[i] << " ";
    }

    cout << ans[N-1] << endl;

}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010], v[200010][2];
int main(){
    int n,k;
    while(cin>>n>>k){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
        }
        int tmp;
        while(k--){
        	for(int i=0; i<n; ++i){
        		if(i-a[i]>=0){
        			v[i-a[i]][0]++;
        		}
        		else{
        			v[0][0]++;
        		}
        		if(i+a[i]<n){
        			v[i+a[i]][1]++;
        		}
        		else{
        			v[n-1][1]++;
        		}
        	}
        	tmp=0;bool l=1;
        	for(int i=0; i<n; ++i){
        		tmp+=v[i][0];
        		a[i]=tmp;
        		tmp-=v[i][1];
        		v[i][0]=v[i][1]=0;
        		if(a[i]<n){
        			l=0;
        		}
        	}
        	if(l){
        		break;
        	}
        }
        for(int i=0; i<n; ++i){
        	printf("%d ",a[i]);
        }
        printf("\n");
    }
  return 0;
}




Measured memory_bytes: 6108
#include <iostream>
using namespace std;
 
int main() {
  int n, h, max_h = 0;
  long long answer = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (max_h < h) max_h = h;
    else answer += max_h - h;
  }
  cout << answer;
  return 0; 
}

Measured memory_bytes: 3576
/*
 * @Author: Kaizyn
 * @Date: 2020-05-23 19:56:18
 * @LastEditTime: 2020-05-23 21:13:14
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const long long INF = 1e18;

long long n, a, b, c, d;
map<long long, long long> mp;

inline void update(const long long &x, const long long &y) {
  if (mp.count(x)) mp[x] = min(mp[x], y);
  else mp.insert({x, y});
}

inline void solve() {
  mp.clear();
  cin >> n >> a >> b >> c >> d;
  mp[n] = 0;
  while (mp.size()) {
    auto p = *(--mp.end());
    long long x = p.first, y = p.second;
    if (x == 0) return cout << y << endl, void();
    update(x/2, y+a+(x%2)*d);
    update(x/2+1, y+a+(2-x%2)*d);
    update(x/3, y+b+(x%3)*d);
    update(x/3+1, y+b+(3-x%3)*d);
    update(x/5, y+c+(x%5)*d);
    update(x/5+1, y+c+(5-x%5)*d);
    if (x < INF/d) update(0, y+x*d);
    mp.erase(--mp.end());
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3788
#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(){
    string s;
    cin>>s;
    if(s[0]==s[2])cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

h = 0
w = 0
k = 0
a = []
num = 1
cnt = []
c = []

def rec(x1, y1, x2, y2):
    global num
    # print("x1:{}, y1:{}, x2:{}, y2:{}".format(x1, y1, x2, y2))
    sts = []
    for i in range(y1, y2+1):
        for j in range(x1, x2+1):
            if c[i][j] == '#':
                sts.append((j, i)) # x, y
    if len(sts) == 1:
        for i in range(y1, y2+1):
            for j in range(x1, x2+1):
                a[i][j] = num
        num += 1
        return
    p1, q1 = sts[0]
    p2, q2 = sts[1]
    if q1 < q2:
        rec(x1, y1, x2, q1)
        rec(x1, q1+1, x2, y2)
    else:
        # q1 = q2
        rec(x1, y1, min(p1, p2), y2)
        rec(min(p1, p2)+1, y1, x2, y2)

def main():
    global h, w, k, a, num, cnt, c
    h, w, k = list(map(int, input().strip().split()))
    c = [[0] * w for _ in range(h)]
    a = [[0] * w for _ in range(h)]
    for i in range(h):
        c[i] = input().strip()

    rec(0, 0, w-1, h-1)
    for i in range(h):
        print(" ".join(str(c) for c in a[i]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 497240
#include<iostream>
#include<stdio.h>
#include<cctype>
using namespace std;

int main()
{
	char ch;
	while (1){
		scanf("%c", &ch);

		if (isupper(ch)) cout << (char)tolower(ch);
		else if (islower(ch)) cout << (char)toupper(ch);
		else{
			if (ch == '\n') break;
			cout << ch;
		}
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 1148
import java.util.*;
class Main 
{ 

	
	 
	public static void main(String args[]) 
	{ 
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int count=0;
		while(b>=a && b>0 && c>0)
		{
			count++;
			b-=a;
			c-=1;
		}

		System.out.println(count);
		
		
	}
} 


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
/**
 Answer #2
 **/

using namespace std;

int main()
{

    //    cout << " a" << endl;
    long long X, Y, Z;
    long long K;
    long long A[1000], B[1000], C[1000];

    cin >> X >> Y >> Z >> K;
    for (int i = 0; i < X; ++i)
    {
        cin >> A[i];
    }
    sort(A, A + X, greater<long long>());

    for (int i = 0; i < Y; ++i)
    {
        cin >> B[i];
    }
    sort(B, B + Y, greater<long long>());

    for (int i = 0; i < Z; ++i)
    {
        cin >> C[i];    
    }
    
    sort(C, C+ Z, greater<long long>());

    std::vector<long long> vec;
    for (int i = 0; i < X; ++i)
    {
        for (int j = 0; j < Y; ++j)
        {
            for (int k = 0;  k< Z; ++k ){
                if((i+1)*(j+1) *(k+1) <= K) vec.push_back(A[i] + B[j] +C[k]);
                else break;
            }
        }
    }

    sort(vec.begin(), vec.end(), greater<long long>());

    for (int i = 0; i < K; ++i)
    {
        cout << vec[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1908
from itertools import permutations

while(1):
    a_ = [int(i) for i in input().split()]
    if a_ == [0,0,0,0]:
        break
    p = list(list(i) for i in permutations(a_))
    cont = 1
    for a,b,c,d in p:
        if cont == 0:
            break
        for i in ("+","-","*"):
            if cont == 0:
                break
            for j in ("+","-","*"):
                if cont == 0:
                    break
                for k in ("+","-","*"):       
                    if cont == 0:
                        break
                    p = 0
                    if exec("p = (a{}b){}c{}d".format(i,j,k)) is None and p == 10:
                        print("({0}{4}{1}){5}{2}{6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = (a{}b{}c){}d".format(i,j,k)) is None and p == 10:
                        print("({0}{4}{1}{5}{2}){6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}(b{}c){}d".format(i,j,k)) is None and p == 10:
                        print("{0}{4}({1}{5}{2}){6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}(b{}c{}d)".format(i,j,k)) is None and p == 10:
                        print("{0}{4}({1}{5}{2}{6}{3})".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}b{}(c{}d)".format(i,j,k)) is None and p == 10:
                        print("{0}{4}{1}{5}({2}{6}{3})".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = ((a{}b){}c){}d".format(i,j,k)) is None and p == 10:
                        print("(({0}{4}{1}){5}{2}){6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = (a{}b){}(c{}d)".format(i,j,k)) is None and p == 10:
                        print("({0}{4}{1}){5}({2}{6}{3})".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}((b{}c){}d)".format(i,j,k)) is None and p == 10:
                        print("{0}{4}(({1}{5}{2}){6}{3})".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = (a{}(b{}c)){}d".format(i,j,k)) is None and p == 10:
                        print("({0}{4}({1}{5}{2})){6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}(b{}(c{}d))".format(i,j,k)) is None and p == 10:
                        print("{0}{4}({1}{5}({2}{6}{3}))".format(a,b,c,d,i,j,k))
                        cont = 0
                    elif exec("p = a{}b{}c{}d".format(i,j,k)) is None and p == 10:
                        print("{0}{4}{1}{5}{2}{6}{3}".format(a,b,c,d,i,j,k))
                        cont = 0
    if cont == 1:
        print("0")



Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
string a,b,c;
cin>>a>>b>>c;
long long ans=0;
rep(i,N){
    char d=a[i];
    char e=b[i];
    char f=c[i];
    int dcnt=1;
    int ecnt=1;
    int fcnt=1;
    if(d==b[i]){
        dcnt++;
    }
    if(d==c[i]){
        dcnt++;
    }
    if(e==a[i]){
        ecnt++;
    }
    if(e==c[i]){
        ecnt++;
    }
    if(f==a[i]){
        fcnt++;
    }
    if(f==b[i]){
        fcnt++;
    }
    int p=max(fcnt,dcnt);
    ans+=3-max(p,ecnt);
}
cout<<ans<<endl;
 return 0;
}
/*
4
west
east
wait

3

9
different
different
different

0

7
zenkoku
touitsu
program

13
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        int[] antenna = new int[5];
        int min = 0, max = 0;
        for (int i = 0; i < antenna.length; i++) {
            antenna[i] = Integer.parseInt(sc.next());
            if (i == 0) {
                min = antenna[i];
                max = antenna[i];
            } else {
                min = Math.min(min, antenna[i]);
                max = Math.max(max, antenna[i]);
            }
        }
        int k = Integer.parseInt(sc.next());
        int diff = max - min;

        if (diff <= k) {
            System.out.print("Yay!");
        } else {
            System.out.print(":(");
        }
    }
}

Measured memory_bytes: 21712
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

set<int> ret;

bool prime_factor(int n) {
  for(int i = 2; i * i <= n; i++) {
    if (n%i==0){
      if (ret.count(i)) return 0;

      ret.insert(i);
      while(n % i == 0) n /= i;
    }
  }
  if(n != 1) {
    if (ret.count(n)) return 0;
    ret.insert(n);
  }
  return 1;
}

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

  int GCD = __gcd(A[0],A[1]);
  rep(i,N){
    GCD = __gcd(GCD,A[i]);
  }
  if (GCD!=1) {
    cout << "not coprime" << endl;
    return 0;
  }
  // あとはparwise coprimeかどうかを調べればOK

  rep(i,N){
    if (!prime_factor(A[i])) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }
  cout << "pairwise coprime" << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 7604
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

int V,E;
int table[NUM],GRUNDY[NUM];
bool edge[NUM][NUM];

int grundy(int node_id){

	if(GRUNDY[node_id] != -1){

		return GRUNDY[node_id];
	}

	set<int> S;

    for(int next = 0; next < V; next++){
    	if(!edge[node_id][next])continue;

       	S.insert(grundy(next));
    }

    int g = 0;
    while(S.count(g) != 0)g++;

    return GRUNDY[node_id] = g;
}


int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < V; i++){
		for(int k = 0; k < V; k++){

			edge[i][k] = false;
		}
	}

	for(int i = 0; i < V; i++){

		scanf("%d",&table[i]);
	}

	int from,to;

	for(int loop = 0; loop < E; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		edge[from][to] = true;
	}

	for(int i = 0; i < V; i++){

		GRUNDY[i] = -1;
	}

	for(int i = 0; i < V; i++){

		grundy(i);
	}

	int n = BIG_NUM;
	for(int i = 0; i < V; i++){

		n = min(n,GRUNDY[i]);
	}

	//GRUNDY(v) == nなる頂点全ての頂点のXORを取る
	int XOR = 0;
	for(int v = 0; v < V; v++){
		if(GRUNDY[v] == n){
			XOR ^= table[v];
		}
	}

	if(XOR == 0){ //ゲーム開始時点で「良い状態」なら後手の勝ち

		printf("2\n");
	}else{

		printf("1\n");
	}

	return 0;
}



Measured memory_bytes: 4144
n, m = map(int, input().split())

ans = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for a in ans:
    if a % 2 != 0:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 3956
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;

//auto

int main(){
int n;
cin>>n;
bool ok=false;
for(int i=1;i<=9;i++){
  for(int j=1;j<=9;j++){
    if(n==j*i)ok=true;
  }
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}



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

int main(void){
  int k, s;
  cin >> k >> s;
  
  int cnt = 0;
  
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (floor(z) == z && 0 <= z && z <= k) {
        cnt++;
      }
    }
  }
  
  printf("%d\n", cnt);
}

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

int main()
{
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())
	{
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size())
	{
		cout << "LESS" << endl;
		return 0;
	}
	else
	{
		for (int i = 0; i < a.size(); ++i)
		{
			if (a[i] > b[i])
			{
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i])
			{
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
#define Vanya Unstoppable
 
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n;
    cin >> n;
    
    pair<int, int> a[n];
    vector<int> us(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        --a[i].first;
        a[i].second = i;
    }

    sort(a, a + n);
    set<int> s;
    
    int ans = 0;
    
    s.insert(-1); s.insert(n);
    for (int i = 0; i < n; ++i) {
        auto l = s.lower_bound(a[i].second);
        auto r = l; --l;
        int val = (a[i].first + 1) * (*r - a[i].second) * (a[i].second - *l);
//        cout << i + 1 << ' ' << a[i].first + 1 << ' ' << a[i].second << ' ' << val << ' ' << *l << ' ' << *r << endl;
        ans += val;
        s.insert(a[i].second);
    }
    
    cout << ans;
}


Measured memory_bytes: 17184
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int half = s.size() / 2;

    string ans = YES;
    if(s.size() & 1){
        ans = NO;
        goto end;
    }

    for(int i = 0; i < half; i++){
        if(s[i] != s[half + i]){
            ans = NO;
            goto end;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	vector<int> v(3);
	for (int i = 0; i < 3; i++) {
		cin >> v[i];
	}

	int ans = INT_MAX;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == j) continue;
			int n = v[i] + v[j];
			ans = min(ans, n);
		}
	}

	cout << ans << endl;
}

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

int main(){
    string s1,s2;
    int cnt = 0;
    cin>>s1>>s2;
    for(int i = 0 ; i < 3 ; i++){
        if(s1[i] == s2[i])
            cnt++;
    }
    cout<<cnt<<endl;
	return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

/**
 * Union-Find
 *  - 概要
 *      - クエリに対して連結成分を作成
 *  - 時間計算量
 *      - 各クエリに対して O( log|V|以下 )
*/

#include <iostream>     // std::cout
#include <algorithm>    // std::fill

using namespace std;

/*==================================================*/
const int MAX_N = 201010;

struct UnionFind {
	int par[MAX_N];    // 親ノードの番号
	int deph[MAX_N];   // ノードの深さ

	// 上以外に持っておくデータ
	// 例)木であるかどうか(bool値)を持つ場合
	// bool istree[MAX_N];
	

	UnionFind(int n) {
		fill(par, par + MAX_N, -1);
		for (int i = 0; i<n; i++) {
			par[i] = i;
			deph[i] = 0;

			// 持っておくデータにおいて初期化が必要な場合
			// istree[i] = true;
		}
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			// 同じグループに属しているときの処理
			// istree = false;
			
			return;
		} 
		if (deph[x] < deph[y]) {
			par[x] = par[y];
			// ルートをyとする時の処理
			
		} else {
			par[y] = par[x];
			if (deph[x] == deph[y]) deph[x]++;
			//ルートをxとする時の処理
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main(){
    int N,K,L,left,right;
    cin >> N >> K >> L;
    
    UnionFind road(N);
    UnionFind train(N);

    REP(i,0,K){
        cin >> left >> right;
        left--;right--;
        road.unite(left, right);
    }
    REP(i,0,L){
        cin >> left >> right;
        left--;right--;
        train.unite(left, right);
    }

    map<pair<int,int>,int> mp;
    REP(i,0,N){
        mp[make_pair(road.find(i), train.find(i))]++;
    }

    REP(i,0,N){
        P(mp[make_pair(road.find(i), train.find(i))]);
    }
}

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



namespace Test1 {

    class ClassMain {



        
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                char[] chrs = line.ToCharArray();

                bool flg = true;
                for (int i = 0; i < chrs.Length - 1; i++) {
                    char pre = chrs[i];
                    char nex = chrs[i + 1];
                    if (pre == 'A') {
                        if (nex == 'B' || nex == 'D') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'B') {
                        if (nex == 'A' || nex == 'C' || nex == 'E') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'C') {
                        if (nex == 'B' || nex == 'F') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'D') {
                        if (nex == 'A' || nex == 'E' || nex == 'G') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'E') {
                        if (nex == 'B' || nex == 'D' || nex == 'F' || nex == 'H') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'F') {
                        if (nex == 'C' || nex == 'E' || nex == 'I') { flg = true;}
                        else { flg = false; break; }
                    }
                    if (pre == 'G') {
                        if (nex == 'D' || nex == 'H') { flg = true;  }
                        else { flg = false; break; }
                    }
                    if (pre == 'H') {
                        if (nex == 'E' || nex == 'G' || nex == 'I') { flg = true; }
                        else { flg = false; break; }
                    }
                    if (pre == 'I') {
                        if (nex == 'H' || nex == 'F') { flg = true; }
                        else { flg = false; break; }
                    }
                }

                if (flg) { Console.WriteLine(line); }

    
            }
        }


    }

    
}

Measured memory_bytes: 5316
s=input()
S=[]
t=input()
T=[]
for i in range(len(s)):
    S.append(s[i])
for i in range(len(t)):
    T.append(t[i])
S.sort()
T.sort()
T.reverse()

if S<T:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
	using namespace std;
	
	int main()
	{
		int cnt = 1;
		int x;
		cin >> x;
		while (x != 0)
		{
			cout << "Case " << cnt++ << ": " << x << endl;
			cin >> x;
		}
		
		return 0;
	}

Measured memory_bytes: 3068
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
 
l = sorted(l, key = lambda x:(x[1], x[0]))
cnt = m
 
for i in range(1, m):
    if l[i-1][1] > l[i][0]:
        l[i][1] = l[i-1][1]
        cnt -= 1
 
print(cnt)

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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cin >> a.at(i).at(j);
    }
  }

  // 表示すべき行と列をチェック
  vector<bool> h(H, false);
  vector<bool> w(W, false);

  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (a.at(i).at(j) == '#')
      {
        h.at(i) = true;
        w.at(j) = true;
      }
    }
  }

  // 表示
  for (int i = 0; i < H; ++i)
  {
    if (h.at(i))
    {
      for (int j = 0; j < W; ++j)
      {
        if (w.at(j))
        {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

  return 0;
}

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  
  if(n <= k){
    for(int i = 0; i < n; i++)
      ans += x;
  }
  else{
    for(int i = 0; i < k; i++)
      ans += x;
    for(int i = k; i < n; i++)
      ans += y;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define MOD (1000000007LL)
#define PI (3.1415926535897932384)
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
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; }



// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	cout << fixed << setprecision(20);
	int r; cin >> r;
	cout << 2 * PI * r << endl;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main()
{
	int m[10];
	int tmp;
   
	for(int i=0;i<10;i++){
	cin >> m[i];
	}
	
	for(int i=0 ;i<9 ;i++){
		for(int j=i+1 ;j<10 ;j++){
			if(m[i]<m[j]){			
			    tmp = m[i];
			   m[i] = m[j];
			   m[j] = tmp;
			}
		}
	}
	
	for(int i=0 ;i<3 ;i++){
		cout << m[i] <<endl;
		
	}
    
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(void){
  long long A, B;
  cin >> A >> B;
  if(A == 1) A = 14;
  if(B == 1) B = 14;
  if(A > B) cout << "Alice" << endl;
  else if(A < B) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> v;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout << v[N-1]-v[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

	/*

	int D, T, S;
	cin >> D >> T >> S;
	int hour = D / S;
	if (D % S != 0)hour++;
	if (hour <= T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	
	*/
	/*
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << 3 << endl;
	}
	else if (S == "SSS") {
		cout << 0 << endl;
	}
	else if (S == "SRR" || S == "RRS") {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	*/	
	/*
	int x;
	cin >> x  ;
	if (x == 1) {
		cout << 0 << endl;
	}
	if (x == 0) {
		cout << 1 << endl;
	}
	*/

	int X;
	cin >> X;
	if(X>=30){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}



}



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

int main()
{
	int W, a, b;
	cin >> W >> a >> b;
	if (a < b) {
		if (a + W > b) cout << 0 << endl;
		else cout << b - a - W << endl;
	}
	else {
		if (b + W > a) cout << 0 << endl;
		else cout << a - b - W << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,x,m;cin>>n>>x>>m;
    map<ll,ll> mp;
    ll ini=-1;
    vector<ll> sum;
    ll now=x;
    ll counter=0;
    ll S=0;
    
    while(true){
        mp[now]=counter;
        S+=now;
        sum.pb(S);
        counter++;
        now=(now*now)%m;
        auto it=mp.find(now);
        if(it!=mp.end()){
            break;
        }
    }
    
    ll r_i=mp[now];
    ll r_f=now;
    ll r_sum;
    if(r_i>0){
        r_sum=sum[counter-1]-sum[r_i-1];
    }else{
        r_sum=sum[counter-1];
    }
    ll r_num=counter-r_i;
    
    ll ans=0;
    now=x;
    rep(i,0,min(r_i,n-1)){
        ans+=now;
        now=(now*now)%m;
    }
    if(n-1<=r_i){
        cout<<ans<<endl;
        return 0;
    }
    ll r_c=(n-r_i-1)/r_num;
    ll amari=(n-r_i-1)%r_num;
    ans+=(r_c*r_sum);
    
    now=r_f;
    now=(now*now)%m;
    rep(i,0,amari-1){
        ans+=now;
        now=(now*now)%m;
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 6680
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc,char** argv){
  int n,t;
  cin >> n >> t;
  int c = 10000;
  for(int i = 0; i<n;i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    if(tmp2 <= t){
      c = (tmp1 < c) ? tmp1 : c;
    }
  }
  if(c > 1000){
    cout << "TLE" << endl;
  }else{
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

struct state
{
  vector<vector<int>> bd;
  int cnt;
};

class EightPuzzle
{
public:
  queue<state> q;
  map<vector<vector<int>>,bool> m;
  vector<vector<int>> goal;
  vector<int> dr,dc;
  EightPuzzle(){}
  EightPuzzle( state st ){ q.push(st); goal = {{1,2,3},{4,5,6},{7,8,0}}; dr = {1, -1, 0, 0}; dc = {0, 0, 1, -1}; }
  int solve();
  void find0( vector<vector<int>> &b, int &x, int &y );
};

void EightPuzzle::find0( vector<vector<int>> &b, int &r, int &c )
{
  for ( r = 0; r < 3; ++r )
    for ( c = 0; c < 3; ++c )
      if ( b[r][c] == 0 ) return;
}

int EightPuzzle::solve()
{
  while ( ! q.empty() )
    {
      state st = q.front();
      
      if ( st.bd == goal )
        {
          cout << st.cnt << endl;
          return 0;
        }

      int r, c;
      find0( st.bd, r, c );

      for ( auto i = 0; i < 4; ++i )
        {
          int nr = r + dr[i];
          int nc = c + dc[i];
          if ( nr < 0 || nr > 2 || nc < 0 || nc > 2 ) continue;

          state nst = st;
          nst.bd[r][c] = st.bd[nr][nc];
          nst.bd[nr][nc] = 0;
          nst.cnt = st.cnt + 1;

          if ( m.count(nst.bd) == 0 )
            {
              q.push(nst);
              m[nst.bd] = true;
            }
        }
      q.pop();
    }
  
  return 0;
}

int main()
{
  state st;
  st.cnt = 0;
  
  for ( auto i = 0; i < 3; ++i )
    {
      vector<int> vl;
      for ( auto j = 0; j < 3; ++j )
        {
          int v;
          cin >> v;
          vl.push_back(v);
        }
      st.bd.push_back(vl);
    }

  EightPuzzle ep( st );

  ep.solve();

  return 0;
}

Measured memory_bytes: 47488
import java.util.*;

public class 
Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();

    if(x<a){
      System.out.println("0");
    }else{
      System.out.println("10");
    }
  }
}

Measured memory_bytes: 21460
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  vector<int64> cnt(2);
  int64 ret = 0;
  for (int k = 59; k >= 0; --k) {
    cnt[0] = cnt[1] = 0;
    for (int i = 0; i < n; ++i) {
      cnt[(a[i] >> k) & 1]++;
    }
    ret += (cnt[0] * cnt[1]) % MOD * ((1LL << k) % MOD) % MOD;
    ret %= MOD;
  }
  printf("%lld\n", ret % MOD);
  return 0;
}


Measured memory_bytes: 2560
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  ll H, W;
  cin >> H >> W;

  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll res = H * W / 2.0 + 0.5;
  cout << res << endl;

  return 0;
}

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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

int n, k;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <math.h>

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();

if(a == b && b == c && c == a){
System.out.println("Yes");
}else{
System.out.println("No");
}
                
    }
}

Measured memory_bytes: 22100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int work = b - a;

        int sum = 0;
        for (int i = 1; i < work; i++) {
            sum += i;
        }

        System.out.println(sum - a);

        sc.close();

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	string s; cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5]) dunk("Yes");
	else dunk("No");

	return 0;
}


Measured memory_bytes: 256
T = int(input())
ABCD = [[int(i) for i in input().split()] for _ in range(T)]

def gcd(a, b) :
    a, b = max(a, b), min(a, b)
    while b != 0 :
        a, b = b, a % b
    return a

def solve(A, B, C, D) :
    if B > A or B > D :
        return 'No'
        
    a0 = A % B
    d = gcd(B, D)
    if a0 + ((C - a0) // d + 1) * d >= B :
        return 'Yes'
        
    return 'No'

for A, B, C, D in ABCD :
    print(solve(A, B, C, D))

Measured memory_bytes: 38640
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int a,b;
  while(cin>>a>>b){
  a+=b;
  b=0;
  while(a>0)
    b++,a/=10;
  cout<<b<<endl;
  }
}

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

int main()
{
	int month, day;
	int monthday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	while(scanf("%d %d", &month, &day)!= EOF)
	{
		if(month == 0) break;
		for(int i = 0; i < month;i++)
		{
			day = day + monthday[i];
	}
		day = day % 7;
		
		switch(day){
		case 0 : cout << "Wednesday" << endl; break;
		case 1 : cout << "Thursday" << endl; break;
		case 2 : cout << "Friday" << endl; break;
		case 3 : cout << "Saturday" << endl; break;
		case 4 : cout << "Sunday" << endl; break;
		case 5 : cout << "Monday" << endl; break;
		case 6 : cout << "Tuesday" << endl; break;
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
using namespace std;
long long a[3],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;
int main()
{
	for(i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[1]-a[0]==a[2]-a[1])
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: u64,
    }
    println!("{}", N*(N+1)/2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int ff[3][512][512];
int gg[3][512][512];
int main() {
	int N, X;
	cin >> N >> X;
	for (int n = 0; n <= N; ++ n) {
		int i = n%3;
		for (int x = 0; x <= X; ++ x) {
			for (int s = 0; s < 512; ++ s) {
				if (n == 0 || x == 0) {
					ff[i][x][s] = s == 0 ? 1 : 0;
				} else {
					ff[i][x][s] = (gg[i][x-1][s] + gg[(n-1)%3][x-1][s^x]) % mod;
				}
			}
			for (int s = 0; s < 512; ++ s) {
				gg[i][x][s] = n >= 2 ? gg[(n-2)%3][x][s] : 0;
				(gg[i][x][s] += ff[i][x][s]) %= mod;
			}
		}
	}
	cout << ff[N%3][X][X] << endl;
}



Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 1000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

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

    int n, k, i, arr[MAX + 5], sum = 0;
    cin >> n >> k;
    for (i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for (i = 0; i < k; ++i) {
        sum += arr[i];
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 3192
// AtCoder
// ABC C - Forbidden List

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;


int main()
{
	//steady_clock::time_point start = steady_clock::now();
	int X, N;

	cin >> X >> N;
	
	if (N > 0) {
		int p[N];
		for (int i = 0; i < N; i++) {
			cin >> p[i];
		}
		// 計算
		int ans = 500;
		int ans_id = -1;
		int dist;
		int cnt = 0;
		int res[200];
		int id = 0;
		int flag = 1;
		for (int i = 0; i <= 101; i++) {
			for (int j = 0; j < N; j++) { 
				if (i==p[j]) flag = 0;
			}
			if (flag == 1) {
				if ( X - i >= 0) {
					dist = X - i;
				} else {
					dist = - (X - i);
				}
				if (ans >= dist) {
					ans = dist;
					ans_id = i;
					cnt += 1;
					res[id] = i;
					id = id + 1;
				}
			}
			flag = 1;
		}
		if (cnt == 1) {
			cout << res[0] << endl;
		} else {
			int ans_min = 500;
			int candidate;
			int c_id = 0;
			for (int i = 0; i < id; i++) {
				if ( X - res[i] >= 0) {
					dist = X - res[i];
				} else {
					dist = - (X - res[i]);
				}
				if (ans_min > dist) {
					ans_min = dist;
					ans_id = res[i];
				} else if (ans_min == dist) {
					ans_min = dist;
					candidate = res[i];
					c_id++;
				}
			}
			if (c_id == 0) {
				cout << ans_id << endl;
			} else {
				cout << min(ans_id,candidate) << endl;
			}
		}
	} else {
		cout << X << endl;
	}

	//計算時間集計
	/*
	steady_clock::time_point end = steady_clock::now();
    steady_clock::duration d = end - start;
	cout << "計算時間は" << duration_cast<milliseconds>(d).count() << "ミリ秒です。\n";
	*/
}


Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<numeric>
#include<map>

using namespace std;

int main() {
   int a[3], b[3];
   map<int, int> log;
   for (int i = 0; i < 3; i++) {
      cin >> a[i] >> b[i];
      log[a[i]]++;
      log[b[i]]++;
   }
   vector<int> tmp;
   for (auto it = log.begin(); it != log.end(); ++it) {
      tmp.push_back(it->second);
   }
   sort(tmp.begin(), tmp.end());
   if (tmp[0] == 1 && tmp[1] == 1 && tmp[2] == 2 && tmp[3] == 2) cout << "YES" << endl;
   else cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto inf = (llint)1<<31;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

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;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
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;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main(){
	int a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	int x = 60 * a + b;
	int y = 60 * c + d;
	int ans = y - x - k;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <queue>
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    ll n, q; cin >> n >> q;
    vector<vector<ll>> adj(n);
    for(int i = 0; i < n-1; i++) {
        ll a,b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<ll> p(q);
    vector<ll> x(q);
    for(int i = 0; i< q; i++) {
        cin >> p[i] >> x[i];
        p[i]--;
    }
    vector<int> visited(n,0);
    visited[0] = 1;
    queue<ll> que;
    que.push(0);

    vector<ll> cost(n,0);
    vector<ll> start(n,0);
    for(int i = 0; i < q; i++) {
        start[p[i]] += x[i];
    }
    while(!que.empty()) {
        ll v = que.front(); que.pop();
        cost[v] += start[v];
        for(auto u : adj[v]) {
            if(visited[u] == 1) {
                continue;
            }
            cost[u] += cost[v];
            que.push(u);
            visited[u] = 1;
        }
    }
    for(auto c : cost) {
        cout << c << endl;
    }
}


Measured memory_bytes: 23896