akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(void){
	char s;
	cin>>s;
	if(s=='A') cout<<'T'<<endl;
	else if(s=='T') cout<<'A'<<endl;
	else if(s=='C') cout<<'G'<<endl;
	else if(s=='G') cout<<'C'<<endl;
	return 0;
}

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

ll parent[100005];

ll find_set(int v){
    if(v == parent[v])
        return parent[v];
    return parent[v] = find_set(parent[v]);
}

void union_set(ll a, ll b){
    a = find_set(a);
    b = find_set(b);
    if(a!=b)
        parent[b] = a;
}


int main(){
    ll n,m;
    cin>>n>>m;
    for(int i=0; i<=n; i++){
        parent[i] = i;
    }
    for(int i=0; i<m; i++){
        ll a,b;
        cin>>a>>b;
        union_set(a,b);
    }
    int count = 0;
    for(int i = 1; i<n; i++){
        if(find_set(i) != find_set(i+1)){
            count++;
            union_set(i, i+1);
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 4412
h, n= list(map(int,input().split()))
a = []
b = []
for i in range(n):
    a_in, b_in = list(map(int,input().split()))
    a.append(a_in)
    b.append(b_in)

if h == 1:
    print(min(b))
else:
    dp = [0]*h
    dp[0] = min(b)
    for i in range(2,h+1):
        c = [0]*n
        for j in range(n):
            if i > a[j]:
                c[j] = b[j] + dp[i-a[j]-1]
            else:
                c[j] = b[j]
        dp[i-1] = min(c)
    print(dp[h-1])

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

int main(){
  int N,D;
  int sum = 0;
  cin >> N;
  vector<int> time(N);
  for(int i = 0; i < N; i++){
    cin >> time.at(i);
    sum += time.at(i);
  }
  cin >> D;
  int num,ad,k;
  for(int i = 0; i < D; i++){
    cin >> num >> ad;
    k = time.at(num-1) - ad;
    cout << sum - k << endl;
  }
}
  
  

Measured memory_bytes: 256
import java.util.Scanner;
public final class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String str = sc.next();
    if(n%2 == 1)
      	System.out.println("No");
    else{
      	int half = n/2; 
    	if(str.substring(0,half).compareTo(str.substring(half)) == 0){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
    sc.close();
  }
}

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

using namespace std;
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;
  int ssize = (int)s.size();
  int tsize = (int)t.size();
  vector<vector<int> > dp(ssize + 1, vector<int>(tsize + 1, 0));
  rep(i, s.size()) rep(j, t.size()) {
    if (s[i] == t[j]) {
      dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
    }
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
  }

  string ans = "";
  int i = ssize, j = tsize;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else {
      ans = s[i - 1] + ans;
      --i;
      --j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 38820
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int h,w;cin>>h>>w;
  vector<string> s(h);rep(i,h)cin>>s[i];
  
  int right = 0;
  rep(i,h){
    rep(j,w){
      if(s[i][j] == '#'){
        if(right <= j)right = j;
        else {
          print("Impossible");
          return 0;
        }
      }
    }
  }

  print("Possible");
  return 0;
}



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

int main() {
  
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> tmp(n);
  for(int i = 0; i < n; i++) { 
    cin >> a.at(i); 
    tmp.at(i) = a.at(i);
  }
  
  sort(tmp.begin(), tmp.end());
  reverse(tmp.begin(), tmp.end());

  if(tmp.at(0) == tmp.at(1)) {
    for(int i = 0; i < n; i++) {
      cout << tmp.at(0) << endl;
    }
    return 0;
  }

  vector<int> ans(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(a.at(i) != tmp.at(j)) {
        ans.at(i) = tmp.at(j);
        break;
      }
    }
  }
  for(int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 3968
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int n;
int cnt[105];
int C(int n) {
	return n*(n-1)/2;
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		int t = i;
		for(int j = 2; j*j <= t; j++) {
			while(t%j == 0) t /= j, cnt[j]++;
		}
		cnt[t]++;
	} 
	int tot1 = 0, tot2 = 0, tot3 = 0, ans = 0;
	for (int i = 2; i < 105; i++) {
		if(cnt[i] >= 4) tot1++; 
		if(cnt[i] >= 14) tot2++;
		if(cnt[i] >= 24) tot3++;
		if(cnt[i] >= 74) ans++;
	}
	for (int i = 2; i < 105; i++) {
		if(cnt[i] >= 2) {
			if(cnt[i] >= 4) ans += C(tot1-1);
			else ans += C(tot1);
		}
	}
	for (int i = 2; i < 105; i++) {
		if(cnt[i] >= 4) {
			if(cnt[i] >= 14) ans += tot2-1;
			else ans += tot2; 
		}
	}
	for (int i = 2; i < 105; i++) {
		if(cnt[i] >= 2) {
			if(cnt[i] >= 24) ans += tot3-1;
			else ans += tot3;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = dict()

for i in range(n):
  s = input()
  if(s not in d.keys()):
    d[s] = 1
  else:
    d[s] +=1
    
max = max(d.values())
ans = []
for i in d.keys():
  if(d[i] == max):
    ans.append(i)
for i in sorted(ans):
  print(i)



Measured memory_bytes: 35480
import collections
#H  = map(int, input().split())
H  = int(input())
dic = collections.defaultdict(int)
for _ in range(H):
    dic[input()]+=1
ma = max(dic.values())
res = []
for k in dic.keys():
    if dic[k] == ma:
        res.append(k)
for s in sorted(res):
    print(s)
        


Measured memory_bytes: 33372
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n, t = 0; cin >> n;
    int k; cin >> k;
    REP(i, k){
        int b; cin >> b;
        t += (1 << b);
    }
    REP(i, (1 << n)){
        if(!(~t & i)){
            cout << i << ":";
            int ii = i, bit = 0;
            while(ii){
                if(ii % 2){
                    cout << " " << bit;
                }
                ++bit; ii /= 2;
            }
            cout << "\n";
        }
    }
    return 0;
}



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

int n,ans,mx;
int a[6005],curdp[2005][2005],dp[2005][2005],f[2005];
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		f[i]=-n*10;
		for(j=i;j<=n;j++)
			dp[i][j]=curdp[i][j]=-n*10;
	}
	for(i=1;i<=n*3;i++)
		scanf("%d",&a[i]);
	dp[min(a[1],a[2])][max(a[1],a[2])]=0;
	f[a[1]]=f[a[2]]=0;
	for(i=5;i<=3*n;i+=3)
	{
		if(a[i]==a[i-1]&&a[i-1]==a[i-2])
		{
			ans++;
			continue;
		}
		int b[3];
		for(k=0;k<3;k++)
			b[k]=a[i-k];
		sort(b,b+3);
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			curdp[b[1]][b[2]]=max(curdp[b[1]][b[2]],max(dp[t][t]+1,mx));
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			if(b[1]==b[2])
			{
				for(j=1;j<=n;j++)
					curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],dp[min(b[1],j)][max(b[1],j)]+1);
			}
			for(j=1;j<=n;j++)
				curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],f[j]);
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			dp[b[1]][b[2]]=max(dp[b[1]][b[2]],curdp[b[1]][b[2]]);
			mx=max(mx,dp[b[1]][b[2]]);
			f[b[1]]=max(f[b[1]],dp[b[1]][b[2]]);
			f[b[2]]=max(f[b[2]],dp[b[1]][b[2]]);
			//curdp[b[1]][b[2]]=-n*10;
			for(j=1;j<=n;j++)
			{
				dp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],dp[min(t,j)][max(t,j)]);
				mx=max(mx,dp[min(t,j)][max(t,j)]);
				f[t]=max(f[t],dp[min(t,j)][max(t,j)]);
				f[j]=max(f[j],dp[min(t,j)][max(t,j)]);
				//curdp[min(t,j)][max(t,j)]=-n*10;
			}
			b[0]=t;
			sort(b,b+3);
		}
	}
	printf("%d\n",ans+max(mx,dp[a[n*3]][a[n*3]]+1));
	return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

map<char, char> mp = {
  {'A', 'T'},
  {'C', 'G'},
  {'T', 'A'},
  {'G', 'C'},
};

signed main() {
  char c;
  cin >> c;
  cout << mp[c] << endl;

  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
"""
n,m = LI()
a = LIR(n)
a.sort()
a = a[::-1]
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] != 0:
            if a[j][s] > 0:
                for k in range(s,m):
                    a[j][k] -= 1*a[i][k]
                    a[j][k] = abs(a[j][k])
r = 0
for i in range(n):
    if sum(a[i]) > 0:r += 1
print((pow(2,n+m-1)-pow(2,n-r+m-1))%998244353)
"""

#F
mod = 998244353
s = list(sys.stdin.readline().strip())
n = len(s)
dp = [[0 for i in range(2*n+1)] for j in range(2*n+1)]
r = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    b[i] = int(s[i])
    r[i] = 2-b[i]
for i in range(n-1):
    r[i+1] += r[i]
    b[i+1] += b[i]
r.insert(0,0)
b.insert(0,0)
if r[1] > 0:
    dp[1][1] = 1
for i in range(1,2*n+1):
    if b[min(i,n)] < i:break
    if b[min(i,n)] >= i:dp[i][0] = 1
for i in range(2,n+1):
    for j in range(1,2*n+1):
        if r[i] >= j:
            dp[i][j] += dp[i-1][j-1]
            dp[i][j] %= mod
        if b[i] >= i-j:
            dp[i][j] += dp[i-1][j]
            dp[i][j] %= mod
for i in range(n+1,2*n+1):
    for j in range(1,2*n+1):
        if r[n] >= j:
            dp[i][j] += dp[i-1][j-1]
            dp[i][j] %= mod
        if b[n] >= i-j:
            dp[i][j] += dp[i-1][j]
            dp[i][j] %= mod

print(dp[2*n][r[-1]])

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 169352
r4 = range(4)
r13 = range(13)
cards = [[0 for i in r13] for j in r4]

n = input()
for i in range(n):
    s1, s2 = raw_input().split()
    s1 = 'SHCD'.index(s1)
    s2 = int(s2)-1
    cards[s1][s2] = 1

for j in r4:
    for i in r13:
        if cards[j][i]==0:
            print 'SHCD'[j],i+1

Measured memory_bytes: 4244
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        long n = Long.valueOf(arr01[0]);
        long a = Long.valueOf(arr01[1]);
        long b = Long.valueOf(arr01[2]);

        long sho = n / (a + b);
        long amari = n % (a + b);

        long ball1 = a * sho;
        long ball2 = Math.min(amari, a);

        System.out.println(ball1 + ball2);

    }

}


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

using namespace std;

static bool years[7368792];

void solve()
{
  int m, n;
  while(cin >> m >> n && m && n) {
    memset(years, 1, sizeof years);
    for(int i = m; i < 7368792; i++) {
      if(years[i]) {
        --n;
        if(n == -1) {
          cout << i << "\n";
          break;
        }
        for(int j = i + i; j < 7368792; j += i) {
          years[j] = false;
        }
      }
    }
  }
}

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

Measured memory_bytes: 10332
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
	string s;
	int t;
	queue<string> name;
	queue<int> remain;

	int n, q;

	cin >> n;
	cin >> q;

	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		name.push(s);
		remain.push(t);
	}

	int clock = 0;
	while ( !name.empty() ) {
		t = remain.front();

		// 処理を終えられるか
		if (t <= q) {
			// 現在の時間
			clock += t;
			cout << name.front() << " " << clock << endl;
			name.pop();
			remain.pop();
		} else {
			clock += q;
			// キューから取り除いて、末尾に入れる
			remain.push(t - q);
			name.push(name.front());
			name.pop();
			remain.pop();
		}
	}


	return 0;
}



Measured memory_bytes: 6088
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void DFS(int V,vector<vector<int> > & GRAPH,vector<bool>& used)
{
  used[V] = true;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    
    int to = GRAPH[V][i];
    if(used[to] == false)DFS(to,GRAPH,used);
  }
  
}
void solve(void)
{
  int N,K;
  cin>>N>>K;
  vector<vector<int> >GRAPH(N);
  for (int i = 0; i < K; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  int ANS = 0;
  vector<bool>used(N,false);
  for (int i = 0; i < N; i++)
  {
    if(used[i] == false)
    {
      DFS(i,GRAPH,used);
      ANS++;
    }
  }
  cout<<ANS<<endl;
  

  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  rep(i, 2)
  {
    rep(j, N)
    {
      cin >> A.at(i).at(j);
    }
  }
  int ans = 0;
  rep(i, N)
  {
    int tmp = 0;
    for (int k = 0; k <= i; k++)
    {
      tmp += A[0][k];
    }
    for (int j = i; j < N; j++)
    {
      tmp += A[1][j];
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int w,g;
  while(cin>>w&&w!=-1){
    g=3130;
    if(w-w%10==0);
    else if(w-w%10==10)
      g-=w%10*125;
    else if(w-w%10==20){
      g-=1250;
      g-=w%10*140;
    }else{
      g-=2650;
      g-=(w-30)*160;
    }
    cout<<g<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

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

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  vector<ll> b(N);
  int sum = -1;
  for(int i=0; i<N; i++){
    b[i] = a[i]/2;
    ll temp = b[i];
    int cnt = 0;
    while(temp%2==0){
      cnt++;
      temp /= 2;
    }
    if(sum == -1){
      sum = cnt;
    }else{
      if(sum != cnt){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  ll lcm_b=b[0],lcm_a=a[0];
  for(int i=1; i<N; i++){
    lcm_b = lcm_b/gcd(lcm_b,b[i])*b[i];
    lcm_a = lcm_a/gcd(lcm_a,a[i])*a[i];
  }
  cout << M/lcm_b - M/lcm_a << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,head[100010],deg[100010],ans=0,rt,d1,d2,tmp,o=0;
char c[100010];
bool un[100010],flag;
struct edge{
	int to,link;
}e[200010];
void add_edge(int u,int v){
	deg[u]++,deg[v]++;
	e[++o].to=v,e[o].link=head[u],head[u]=o;
	e[++o].to=u,e[o].link=head[v],head[v]=o;
}
void dfs(int u,int pre,int dep,int &now){
	dep+=!c[u];
	if(dep>=tmp) tmp=dep,now=u;
	for(int i=head[u];i;i=e[i].link){
		if(e[i].to==pre||un[e[i].to]) continue;
		dfs(e[i].to,u,dep,now);
	}
}
queue<int>q;
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++) scanf("%d %d",&u,&v),add_edge(u,v);
	scanf("%s",c+1);
	for(int i=1;i<=n;i++) c[i]=(c[i]=='B'),flag|=!c[i];
	if(!flag) return puts("0"),0;
	for(int i=1;i<=n;i++) if(deg[i]<=1&&c[i]) q.push(i);
	while(!q.empty()){
		int now=q.front();q.pop();
		un[now]=true;
		for(int i=head[now];i;i=e[i].link){
			if(un[e[i].to]) continue;
			deg[e[i].to]--;
			if(deg[e[i].to]<=1&&c[e[i].to]) q.push(e[i].to);
		}
	}
	for(int i=1;i<=n;i++){
		if(un[i]) continue;
		rt=i;
		for(int j=head[i];j;j=e[j].link){
			if(!un[e[j].to]) c[e[j].to]^=1;
		}
		ans+=2;
	}
	for(int i=1;i<=n;i++) ans+=(!un[i]&&!c[i]);
	tmp=0,ans-=2;
	dfs(rt,0,0,d1);
	tmp=0;
	dfs(d1,0,0,d2); 
//	cout<<tmp<<"\n";
	printf("%d\n",max(1,ans-2*tmp));
} 

Measured memory_bytes: 7424
N=int(input())
P=list(map(float,input().split()))
C=[[0.00]*(N+1) for i in range(N+1)]
C[0][0]=1.00
for i in range(1,N+1):
    for j in range(0,i+1):
        """
        #print(i-1)
        print(P[i-1])
        print(C[i-1][j-1])
        print(C[i-1][j-1]*P[i-1])
        """
        C[i][j]=float(C[i-1][j-1]*P[i-1])+float(C[i-1][j]*(1-P[i-1]))
        #print(C[i][j])
ans=float(0.00)
for i in range((N-1)//2+1):
    ans+=C[N][i]
ans=float(1.00-ans)
print(ans)


Measured memory_bytes: 114268
using System;

class MainClass
{
    public static int Main()
    {
        int n=Convert.ToInt32(Console.ReadLine());
        string[] str=Console.ReadLine().Split(' ');
        
        int[] a=new int[n];

        int i=0;
        foreach(string s in str)
        {
            a[i]=Convert.ToInt32(s);
            i++;
        }

        int min=a[0];
        int max=a[0];
        long sum=0;

        foreach(int num in a)
        {
            if(num<min) min=num;
            if(num>max) max=num;
            sum+=num;
        }

        Console.WriteLine("{0} {1} {2}",min,max,sum);

        return 0;
    }
}

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

const int MAX_H = 305;
const int MAX_W = 305;

char table[MAX_H][MAX_W];
int ans[MAX_H][MAX_W];

int main(){
  int H,W,K; cin >> H >> W >> K;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){ cin >> table[i][j];}
  }
  
  int ub = 0; int num = 0;
  
  for(int i = 0; i < H; i++){
    bool flag = false;
    vector<int> berry;
    for(int j = 0; j < W; j++){ 
      if(table[i][j] == '#'){ flag = true; berry.push_back(j);}
    }
    if(flag){ //いちごが存在したら、この行で区切る
      int lb = i;  //下端
      int left = 0; //左端
      if( num+berry.size() == K){ lb = H-1;} 
      //もしこの行で全てのいちごを占めるなら、最後の行まで区切る
      for(int j = 0; j < berry.size(); j++){
        int right = berry[j];
        if( j == berry.size()-1){ //その行の最後のいちご
          right = W-1;
        }
        
        for(int s = ub; s <= lb; s++){
          for(int t = left; t <= right; t++){
            ans[s][t] = num;
          }
        }
        left = right+1;
        num++;
      }
      ub = i+1;
    }//if_flagとじ
  }
    
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){ 
        cout << ans[i][j]+1 << " " ;}
      cout << endl;
    }
    return 0;
  }
      
                  


Measured memory_bytes: 1280
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]

tot=[]
for i in range(N):
    tot.append(K-Q)

for i in range(Q):
    tot[A[i]-1]+=1

for i in range(N):
    if tot[i]>=1:
        print("Yes")
    else:
        print("No")

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

using namespace std;
int W,H,x,y,r;
int ans;

void solve(){
    ans = (r <= x) && (x <= W-r) && (r <= y) && (y <= H-r);
}

int main(){
    cin >> W >> H >> x >> y >> r;
    solve();
    cout << (ans ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

char itoc(const int i){
  switch(i){
    case 0: return '0';
    case 1: return '1';
    case 2: return '2';
    case 3: return '3';
    case 4: return '4';
    case 5: return '5';
    case 6: return '6';
    case 7: return '7';
    case 8: return '8';
    case 9: return '9';
    default : return 'N';
  }
} 

string itos(const int i) {
    string s = to_string(i);
    return s;
}

int main () {

    int n,k; cin >>n>>k;
    vector<char> d(k); REP(i,k) cin >> d[i];

    for (int i = n; i < 10*n + 1; i++) {
        string s = itos(i);
        bool flag = true;
        for (int j = 0; j < s.length(); j++) {
            bool flag2 = true;
            for (int h = 0; h < d.size(); h++) {
                if (s[j] == d[h]) {
                    flag2 = false;
                } 
            }
            if (!flag2) {
                flag = false;
            } 
        }
        if (flag) {
            cout << s << endl;
            return 0;
        } 
    }

    return 0;
}



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

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

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define ull unsigned long long

ull gcd(ull a, ull b) {
    if(a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(k > a) {
        b = b - (k - a);
        if(b <= 0) {
            b = 0;
        }
        a = 0;
    } else {
        a = a - k;
    }

    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll A, B; cin >> A >> B;
    ll lower = max(25*A, 20*B);
    ll upper = min(25*(A+1)-1, 20*(B+1)-1);

    if (lower > upper) {
        cout << -1;
        return 0;
    }

    cout << lower / 2 + (lower % 2);
}

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

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;


int f(const vi &A, ll K)
{
    unordered_map<int,int> past;
    int current = 1;
    for (ll i = 0; i < K; i++)
    {
        past[current] = i;
        current = A[current-1];
        
        auto it = past.find(current);
        if (it != past.end())
        {
            ll b = it->second;
            ll k = (K - b) % (i - b + 1);
            
            current = it->first;
            for (ll j = 0; j < k; j++)
                current = A[current-1];

            return current;            
        }
    }
    return current;
}

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vi A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    int ans = f(A, K);
    cout << ans << endl;
}

Measured memory_bytes: 11024
using System;

namespace AtCoder.Problems
{
    public class ProblemC
    {
        public static void Main(string[] args)
        {
            var s = new SolveC();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] { ' ' };

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveC
    {
        public void Solve()
        {
            var cin = new ProblemC.Scanner();
            var k = cin.NextInt();

            var result = GetAnswer(k);
            Console.WriteLine(result);
        }

        public long GetAnswer(int k)
        {
            long sum = 0;
            for (int a = 1; a <= k; a++)
            {
                for (int b = 1; b <= k; b++)
                {
                    for (int c = 1; c <= k; c++)
                    {
                        sum += GetMaxKoyakusu(GetMaxKoyakusu(a, b), c);
                    }
                }
            }
            return sum;
        }

        private int GetMaxKoyakusu(int a, int b)
        {
            if (dp[a, b] > 0) { return dp[a, b]; }

            for (var i = Math.Min(a, b); i >= 0; --i)
            {
                if (a % i == 0 && b % i == 0)
                {
                    return dp[a, b] = i;
                }
            }
            
            throw new Exception();
        }

        private int[,] dp = new int[300, 300];
    }
}


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

int main()
{
  int d,g;
  cin>>d>>g;
  std::vector<int> p(d),c(d);
  for (int i = 0; i < d; ++i)
  {
    cin>>p[i]>>c[i];
  }
  priority_queue<int,vector<int>,greater<int>> ans;
  for (int mask = 0; mask < (1<<d); ++mask)
  {
    vector<int> full,half;
    for (int i = 0; i < d; ++i)
    {
      if(mask>>i&1) full.emplace_back(i);
      else half.emplace_back(i);
    }
    reverse(half.begin(), half.end());
    int num=0;
    int point=0;
    for(auto&& e: full) {
      num+=p[e];
      point+=(e+1)*100*p[e]+c[e];
    }
    if(point>=g) {
      ans.emplace(num);
      continue;
    }
    for(int i=0;i<p[half[0]]-1;i++){
      point+=(half[0]+1)*100;
      num++;
      if(point>=g){
        ans.emplace(num);
        break;
      }
    }
  }
  cout<<ans.top();
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n, q, sum = 0;
		cin >> n;
		int arr[n]; map<int, int> mp;
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			mp[arr[i]]++;
			sum += arr[i];
		}
		cin >> q;
		while (q--) {
			int a, b;
			cin >> a >> b;
			mp[b] += mp[a];
			sum = sum - (mp[a] * a) + (mp[a] * b);
			mp[a] = 0;
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 10224
$a{"SUN"} = 7;
$a{"MON"} = 6;
$a{"TUE"} = 5;
$a{"WED"} = 4;
$a{"THU"} = 3;
$a{"FRI"} = 2;
$a{"SAT"} = 1;
chomp($s = <>);
print "$a{$s}\n";


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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
bool HasBit(ll x, int b) {
    return (x >> b) & 1;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<ll> arr(n);
    ll xorsum = 0;
    loop(n) {
        cin >> arr[i];
        xorsum ^= arr[i];
    }
    if (xorsum == 0) {
        RET(0);
    }
    xorsum ^= arr[0] ^ arr[1];
    ll sum = arr[0] + arr[1];
    if (xorsum > sum) {
        RET(-1);
    }
    if ((sum - xorsum) & 1) {
        RET(-1);
    }
    ll a = (sum - xorsum) >> 1;
    if (xorsum & a) {
        RET(-1);
    }
    vector<ll> val(51, 0);
    val[0] = HasBit(xorsum, 0);
    for (int i = 1; i <= 50; ++i) {
        val[i] = val[i - 1];
        if (HasBit(xorsum, i)) {
            val[i] |= 1LL << i;
        }
    }
    for (int i = 50; i >= 0; --i) {
        if (a >= arr[1]) {
            break;
        }
        if (HasBit(xorsum, i) && a + val[i] - (1LL << i) < arr[1]) {
            a |= 1LL << i;
        }
    }
    ll ans = a - arr[1];
    if (ans < 0 || ans >= arr[0]) {
        RET(-1);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

PY = [[i] for i in range(1,M+1)]

for i in range(M):
    temp1, temp2 = map(int, input().split())
    PY[i].append(temp1)
    PY[i].append(temp2)


PY.sort(key=lambda val: val[2])
# print(PY)
PY.sort(key=lambda val: val[1])
# print(PY)
city = 0

for i, value in enumerate(PY):
    if value[1] != city:
        j = 0
    j += 1
    value.append(j)
    city = value[1]

PY.sort(key=lambda val:val[0])

# print(PY)

for i in PY:
    ans = str(i[1]).zfill(6)+str(i[3]).zfill(6)
    print(ans)

Measured memory_bytes: 29068
package main

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

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - Banned K
	var N int
	fmt.Scan(&N)

	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	count := make(map[int]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		count[A[i]]++
	}

	var ans int
	for _, v := range count {
		if v >= 2 {
			ans += combination(v, 2)
		}
	}

	var temp int
	for i := 0; i < N; i++ {
		if count[A[i]] < 2 {
			fmt.Println(ans)
		} else if count[A[i]] == 2 {
			temp = ans - combination(count[A[i]], 2)
			fmt.Println(temp)
		} else {
			temp = ans - combination(count[A[i]], 2) + combination(count[A[i]]-1, 2)
			fmt.Println(temp)
		}
	}
}


Measured memory_bytes: 11648
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

int main() {
    set<int> st = { 1, 2, 3, };
    int a, b;
    cin >> a >> b;
    st.erase(a);
    st.erase(b);
    cout << *st.begin() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    long long int n,A,B;


    cin>>n>>A>>B;

    if(n==1)
    {
        if(A==B)
            cout<<"1"<<endl;
        else
            cout<<"0"<<endl;
    }
    else
    {
        if(A>B)
            cout<<"0"<<endl;
        else
        {
            long long int total=((n-2)*B)-((n-2)*A)+1;
            cout<<total<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    string N;
    cin >> N;
    ll ans = 0;
    rep(i,0,N.size()){
        ans += (N[i] - '0');
        ans = ans % 9;
      	//cout<< ans <<endl;
    }
    if(ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-09 15:46:24(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    area = a * b - (a + b - 1)
    print(area)



if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
// Crt. 2019-12-01  16:46:00
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    int n;
    double a1, an, k, ans = 0;

    cin >> n >> a1 >> k;

    an = a1 + (2 * n - 1) * k;

    for (n <<= 1; n; n -= 2) {
        ans += (a1 + an) / 2.0;
        a1 += (2.0 * a1 + 5.0 * k) / n;
        an += (2.0 * an - 5.0 * k) / n;
        if (k > 2) k = (an - a1) / (double) (n - 3);
    }

    printf("%.15lf\n", ans);

    return 0;
}


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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
graph = [lr() for _ in range(M)]


def bellmanford(s, g):
    dist = [float("inf")] * (N+1)
    dist[s] = 0
    for i in range(2 * N):
        for a, b, c in graph:
            cost = -(c - P)
            if dist[b] > dist[a] + cost:
                dist[b] = dist[a] + cost
                if i >= N:
                    dist[b] = -float("inf")
 
    if dist[g] == -float("inf"):
        return -1
    else:
        return max(-dist[g], 0)

answer = bellmanford(1, N)
print(answer)
# 


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N, d; cin >> N;
	unordered_map <int,int> mp;
	for (int i = 0; i < N; ++i){
		cin >> d;
		++mp[d];
	}
	int cnt = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it){
		if (it-> first > it->second){
			cnt += it->second;
		}else{
			cnt += it->second - it->first;
		}
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 7296
x=int(input())
if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 61600