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>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M;
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
		return 0;
	}
	vector<vector<char>>A(N, vector<char>(N));
	vector<vector<char>>B(M, vector<char>(M));
	rep(i, N) {
		rep(j, N) {
			cin >> A[i][j];
		}
	}
	rep(i, M) {
		rep(j, M) {
			cin >> B[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < N-M; i++) {
		for (int j = 0; j < N-M; j++) {
			for (int ii = i; ii < i + M; ii++) {
				for (int jj = j; jj < j + M; jj++) {
					if (A[ii][jj] == B[ii - i][jj - j]) {
						cnt++;
					}
				}
			}
			if (cnt == M * M) {
				cout << "Yes" << endl;
				return 0;
			}
			cnt = 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main(void)
{
	int iK = 0;
    int iX = 0; 
    cin >> iK >> iX;

    for(int ii = iX - iK + 1; ii < iX + iK; ++ii)
    {
    	cout << ii << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int total = 1;
  int cnt = 0;
  for (; total < b;) {
    total += a - 1;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
int a[200010],s[200010];
int cnt[200010];

void solve(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
        s[i]=max(0,i-a[i]);
        cnt[s[i]]+=1;
    }
    ll ans=0;
    rep(j,n){
        ans+=cnt[min(a[j]+j,n)];
        cnt[s[j]]-=1;
    }
    cout << ans << endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 5960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,alice = 0,bob = 0;
    cin >> n;
    int a[n];
    rep(i, n)cin >> a[i];
    qsort(a, n, sizeof(int), desc);
    rep(i, n){
        if (i % 2 == 0) {
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
    using namespace std;
    static const int ConstraintsMin = 1;
    static const int ConstraintsMax = 100;
    int length =0;
    int breadth =0;
    cin >> length;
    cin >> breadth;

    assert(ConstraintsMin <= length && breadth <= ConstraintsMax); /* Precondition */

    /* Calculation  Area, perimeter */
    cout << length*breadth << " " << (length+breadth)*2 << endl;
	
    return 0;
}

Measured memory_bytes: 3092
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long a[] = new long[N];
		HashMap<Long, Long> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			if (map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i])+1);
			} else {
				map.put(a[i],1L);
			}
		}

		long cnt = 0;

		for (Map.Entry<Long, Long> entry : map.entrySet()) {
			if (entry.getValue()>=entry.getKey()) {
				cnt += entry.getValue() - entry.getKey();
			} else {
				cnt += entry.getValue();
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 66096
from itertools import permutations
input()
L = [int(x) for x in input().split()]
k = tuple(L)
prev = None
L.sort()
f = 0
for s in permutations(L):
    if s == k:
        if prev:
           print(*prev)
        print(*s)
        f += 1
    else:
        if f > 0:
            print(*s)
            break
    prev = s




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

set<ll> calc_prime(ll num) {
	set<ll> st;
	st.insert(1);

	ll tgt = 2;
	while (tgt*tgt <= num) {
		if (num%tgt == 0) {
			st.insert(tgt);
			num /= tgt;
		}
		else {
			tgt++;
		}
	}
	if (num != 1)st.insert(num);
	return st;
}

int main()
{
	ll A, B;
	cin >> A >> B;
	auto sta = calc_prime(A);
	auto stb = calc_prime(B);
	set<ll> res;
	set_intersection(sta.begin(), sta.end(),
		stb.begin(), stb.end(),
		inserter(res, res.end()));
	cout << res.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node treeSearch(Node u, int k){
if(u==NIL||k==u -> key) return u;
if(k<u->key) return treeSearch(u->left,k);
else return treeSearch(u->right,k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while( x != NIL ){
     y = x;
     if ( z->key < x->key ){
       x = x->left;
     } else {
       x = x->right;
     }
   }

   z->parent = y;
   if ( y == NIL ){
     root = z;
   } else {
     if (z->key < y->key) {
       y->left = z;
     } else {
       y->right = z;
     }
   }
}

void inorder(Node u){
  if ( u == NIL ) return;
   inorder(u->left);
   printf(" %d", u->key);
   inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if( t != NIL )
       printf("yes\n");
      else
       printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20444
#include <iostream>
#include <list>
#include <random>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))

using namespace std;

int main(){
	int H,W,K;
	cin >> H >> W >> K;
	char c[H][W];
	rep(i,0,H){ rep(j,0,W){
		cin >> c[i][j];
	}}
	
	int count = 0;
	int H_2=1,W_2=1;	// H^2,W^2;
	
	rep(i,0,H) H_2*=2;
	rep(i,0,W) W_2*=2;
	
	int k[10] = {1,2,4,8,16,32,64,128,256,512};
	
	rep(i,0,H_2){ rep(j,0,W_2){
		int black = 0;	// �����}�X
		rep(hh,0,H){
			if( k[hh]&i ){
				rep(ww,0,W){
					if( k[ww]&j ){
						if( c[hh][ww]=='#' ){
							black++;
						}
					}
				}
			}
		}
		if( black==K ) count++;
	} }
	
	cout << count;
	
	return 0;
}


Measured memory_bytes: 3628
H, W = list(map(int, input().split()))
grid = []
for _ in range(H):
    grid.append(list(input()))
dist_grid = [[-1 for _ in range(W)] for __ in range(H)]

queue = [(0, 0)]
dist_grid[0][0] = 1
while queue:
    h, w = queue.pop(0)
    nexts = [(h+1, w), (h-1, w), (h, w+1), (h, w-1)]
    for y, x in nexts:
        if y < 0 or H <= y or x < 0 or W <= x:
            continue
        if dist_grid[y][x] == -1 and grid[y][x] == '.':
            dist_grid[y][x] = dist_grid[h][w] + 1
            queue.append((y, x))
            
sharp_num = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            sharp_num += 1

if dist_grid[-1][-1] == -1:
    print(-1)
else:
    print(H * W - dist_grid[-1][-1] - sharp_num)



Measured memory_bytes: 40560
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

def solve(n: int, a: "List[int]"):
    tmp = 0
    s = 0
    for i, v in enumerate(a):
        s += v
        if i % 2 == 0 and s <= 0:
            tmp += abs(s) + 1
            s = 1
        elif i % 2 != 0 and s >= 0:
            tmp += abs(s) + 1
            s = -1
    ret = tmp
    tmp = 0
    s = 0
    for i, v in enumerate(a):
        s += v
        if i % 2 == 0 and s >= 0:
            tmp += abs(s) + 1
            s = -1
        elif i % 2 != 0 and s <= 0:
            tmp += abs(s) + 1
            s = 1
    ret = min(ret, tmp)
    print(ret)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15724
#include <bits/stdc++.h>
using namespace std;
const int MAX = 110;
const int MAX2 = 1e5 + 10;
long long dp[MAX2];	
int n;
int w;
const int inf = 0x3f3f3f3f;
int main() {
	scanf("%d %d", &n, &w);
	int va;
	int we;
	for(int i = 0; i < n; ++i){
		scanf("%d %d", &we, &va);
		for(int j = w - we ; j >= 0; --j){
			dp[j + we] = max(dp[j + we], dp[j] + va);
		}
	}
	long long ans = 0;
	for(long long i = 0; i <= w; ++i)ans = max(ans, dp[i]);
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int a,b,c,d,i,j;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	scanf("%d", &d);
  i = a*b;
  j = (b*c) + (a*d) - (c*d);
	printf("%d", i - j);
	return 0;
}


Measured memory_bytes: 128
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

mod = 10**9 + 7

n = I()
s = CS(n)

# print(s)

m = INF
for i in s:
    if m>len(i):
        m = len(i)
        ms = i
ms = list(ms)
        
def mycheck(a,b):
    ls = []
    for i in a:
        if i in list(b):
            b.remove(i)
            ls.append(i)    
    return ls

for i in s:
    b = list(i)
    ms = mycheck(ms,b)

ms.sort()
myoutput(ms,space=False)

Measured memory_bytes: 77480
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 c = sc.nextInt();
		
		System.out.println(a < b && b < c ? "Yes" : "No");

	}

}

Measured memory_bytes: 26276
#!/usr/bin/env python3
import sys

MOD = 2  # type: int

def solve(N: int, A: "List[int]"):

    i = 0
    while True:
        m = 2**(i+1)
        bEnd = False
        for a in A:
            if a % m != 0:
                bEnd = True
                break
        if bEnd:
            break
        i += 1

    print(i)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	map<string, int> r;
	long long ans = 0;
	for(int i = 0; i < n; i++){
		string v; cin >> v;
		sort(v.begin(), v.end());
		ans += r[v];
		r[v]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
N,X,Y = map(int, input().split())
X = X-1
Y = Y-1
kyori  = [0]*N
for i in range(N):
    for j in range(i+1,N):
        l = min(abs(i-j), abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X))
        kyori[l] += 1
for k in range(1,N):
    print(kyori[k])

Measured memory_bytes: 47964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
 
int main() {
  int k,b,c,m,sx=0,sy=1,gx,gy,x;
  string ka,ss;
  float a,memo=0,y=0;
  int n,ans=0;
  cin>>x>>y;
  float list[x];
  rep(i,x){
    float sss;
    cin>>sss;
    memo+=sss;
    list[i]=sss;
  }
  a=memo/(4*y);
  rep(i,x){if(list[i]>=a)ans++;}
  if(ans>=y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x;
    double p;
    while (cin>>n>>m>>p) {
        if (n==0&&m==0&&p==0) {
            break;
        } else {
            int sum=0;
            int tmp;
            for (int i=1;i<=n;i++) {
                cin>>x;
                if (i==m) {
                    tmp=x;
                }
                sum+=x;
            }
            sum=sum*100;
            double hoge=p/100;
            sum=sum-sum*hoge;
            if (tmp==0) {
                cout<<0<<endl;
            } else {
                int ans=float(sum/tmp);
                cout<<ans<<endl;
            }
        }
    }
}



Measured memory_bytes: 3204
S = input()

def count_ll(l):

    ret = [0]
    cur = 0

    for c in l:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    
    return ret

def count_rg(l):

    revl = reversed(l)
    ret = [0]
    cur = 0

    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    
    return list(reversed(ret))

l = count_ll(S)
r = count_rg(S)
# print("left: >", l)
# print("right: <", r)

N = len(S) + 1

ans = 0
for i in range(N):
    ans += max(l[i], r[i])

print(ans)



Measured memory_bytes: 37564
using System;

namespace test
{
	class program
	{
		static void Main()
		{
			while (true)
			{
				string[] str = Console.ReadLine().Split(' ');
				int x = int.Parse(str[0]);
				int y = int.Parse(str[1]);
				if (x == 0 && y == 0) break;
				if (x > y) { int temp = x;  x = y;	y = temp; }
				Console.WriteLine(x + " " + y);
			}
		}
	}
}

Measured memory_bytes: 9364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int w,h,x,y;
    cin >> w >> h >> x >> y;

    int ans;
    if (x*2 == w && y*2 == h) {
        ans = 1;
    } else {
        ans = 0;
    }

    cout << fixed << setprecision(9) << double(w)*double(h) / 2 << " " << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;
#define MAX_N 100000
int N, Q;
vector<ll> query;
struct S{
	S (ll idx, ll data) : idx(idx), data(data) {}
	ll idx, data;
	bool operator <(const S &a)const{
		return idx<a.idx;
	}
};

priority_queue<S> pq;

ll ans[MAX_N+1];

int main(){
	scanf("%d%d", &N, &Q);
	query.push_back((ll)N);
	for(int i=0; i<Q; i++){
		ll x;
		scanf("%lld", &x);
		while(!query.empty() && query.back()>=x)	query.pop_back();
		query.push_back(x);
	}
	if(query[0]==0){
		for(int i=0; i<N; i++)	printf("0\n");
		return 0;
	}
	pq.push({query.back(), 1});
	int idx = query.size()-1;
	while(!pq.empty()){
		S now = pq.top(); pq.pop();
		while(!pq.empty() && pq.top().idx==now.idx){
			now.data+=pq.top().data; pq.pop();
		}
		//cout<<now.idx<<' '<<now.data<<endl;
		if(now.idx<=query[0]){
			ans[now.idx] += now.data;
			continue;
		}
		while(idx>0 && query[idx]>=now.idx)	idx--;
		pq.push({query[idx], (now.idx/query[idx])*now.data});
		if((now.idx%query[idx])!=0)	pq.push({now.idx%query[idx], now.data});
	}
	for(int i=N-1; i>=1; i--){
		ans[i] += ans[i+1];
	}
	for(int i=1; i<=N; i++){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

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

int main()
{
    bool notPrime[1000000]={false};
    notPrime[0]=notPrime[1]=true;
    for (unsigned i=3; i<1000000; i+=2) {
        if (!notPrime[i]) {
            for (unsigned j=2; i*j<1000000; j++) {
                notPrime[i*j]=true;
            }
        }
    }
    for (unsigned n, count; cin >> n; cout << count << endl) {
        count=0;
        if (n>=2) {
            count++;
            for (unsigned i=3; i<=n; i+=2) {
                if (!notPrime[i]) {
                    count++;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2132
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    s=input()
    cond= s[2]==s[3] and s[4]==s[5]
    print(["No","Yes"][cond])
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """sippuu"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """iphone"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """coffee"""
        output = """Yes"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 5748
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

@lru_cache(maxsize=None)
def dfs(l, r, wl, wr):
    if r <= l + 1:
        return 0
    v = min(dfs(l, m, wl, wl+wr) + dfs(m, r, wl+wr, wr) + A[m] * (wl+wr) for m in range(l+1, r))
    return v

print(dfs(0, N-1, 1, 1) + A[0] + A[N-1])


Measured memory_bytes: 127312
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
map<int, int> mp;
void color(int n){
    if(n >= 1 && n <= 399){
        mp[0]++;
    }else if(n >= 400 && n <= 799){
        mp[1]++;
    }else if(n >= 800 && n <= 1199){
        mp[2]++;
    }else if(n >= 1200 && n <= 1599){
        mp[3]++;
    }else if(n >= 1600 && n <= 1999){
        mp[4]++;
    }else if(n >= 2000 && n <= 2399){
        mp[5]++;
    }else if(n >= 2400 && n <= 2799){
        mp[6]++;
    }else if(n >= 2800 && n <= 3199){
        mp[7]++;
    }
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> fre;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x >= 1 && x <= 3199){
            color(x);
        }else{
            fre.PB(x);
        }
    }
    int mn = SZ(mp);
    if(mn > 0)
        cout << mn << ' ' << mn + SZ(fre);
    else{
        cout << 1 << ' ' << SZ(fre);
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n;
int H[N];
int dp[N];
void solve(){
	scanf("%d",&n);
	long long ans=1LL*(n)*(n-1)/2;
	printf("%lld\n",ans);
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	string s;
	cin >> s;
	long length = (long)(s.length()+1) / 2;
	vector<long> index = vector<long>(length);
	for (long i = 0; i < length; i++) {
		index[i] = 2 * i;
	}
	string res="";
	long k = 0;
	for (auto i:index) {
		string r = { s[i] };
		 res.append(r);
		
	}
	cout << res;
	return 0;
}





Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<string.h>
#include<stack> 
#include<set>
#include<map>
#include<iostream>
#include<assert.h>
//#define Min(a,b,c) min((a),min((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define pi 3.14159265359
typedef long long LL;
using namespace std;
const int mod = 1e9+7;
int ans[1000005];
int n;
char c[1000005];
bool check(){
	for(int i=2;i<2*n;i++)
	{
		if(ans[i-1]==0){
			if(c[i-1]=='o')
			ans[i]=ans[i-2];
			if(c[i-1]=='x')
			ans[i]=1-ans[i-2];
		}
		if(ans[i-1]==1){
			if(c[i-1]=='x')
			ans[i]=ans[i-2];
			if(c[i-1]=='o')
			ans[i]=1-ans[i-2];
		}
	}
	if(ans[n]==ans[0]){
		if(ans[0]==0){
			if(c[0]=='o')
				if(ans[1]==ans[n-1])
					return true;
			if(c[0]=='x')
				if(ans[1]!=ans[n-1])
					return true;
		}
		else{
			if(c[0]=='x')
				if(ans[1]==ans[n-1])
					return true;
			if(c[0]=='o')
				if(ans[1]!=ans[n-1])
					return true;
		}
	}
	return false;
}
int main(){
	scanf("%d",&n);
	scanf("%s",c);
	for(int i=n;i<2*n;i++)
	c[i]=c[i-n];
	ans[0]=ans[1]=0;
	if(check()){
		for(int i=0;i<n;i++)
		printf("%c",ans[i]?'W':'S');
		return 0;
	}
	ans[0]=ans[1]=1;
	if(check()){
		for(int i=0;i<n;i++)
		printf("%c",ans[i]?'W':'S');
		return 0;
	}
	ans[0]=0;ans[1]=1;
	if(check()){
		for(int i=0;i<n;i++)
		printf("%c",ans[i]?'W':'S');
		return 0;
	}
	ans[0]=1;ans[1]=0;
	if(check()){
		for(int i=0;i<n;i++)
		printf("%c",ans[i]?'W':'S');
		return 0;
	}
	printf("-1\n");
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 6.2 + c[j] * 5.3;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

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

int main() {
    int a[3][3];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    int n;
    cin >> n;

    int match[3][3] = {};
    for (int k = 0; k < n; k++) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (a[i][j] == b)
                    match[i][j] = true;
    }

    int success = 0;
    for (int i = 0; i < 3; i++) {
        int sum = 0;
        for (int j = 0; j < 3; j++)
            sum += match[i][j];
        if (sum == 3)
            success++;
    }
    for (int j = 0; j < 3; j++) {
        int sum = 0;
        for (int i = 0; i < 3; i++)
            sum += match[i][j];
        if (sum == 3)
            success++;
    }

    int sum = 0;
    for (int k = 0; k < 3; k++) {
        sum += match[k][k];
    }
    if (sum == 3)
        success++;

    sum = 0;
    for (int k = 0; k < 3; k++) {
        sum += match[k][2 - k];
    }
    if (sum == 3)
        success++;

    cout << (success ? "Yes" : "No");
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    ll ans = 0;
    rep(i,n) if(i % 2 == 0 && a.at(i) % 2 == 1)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
from collections import deque


if __name__ == '__main__':
    s = deque()  # ?????????????????¢???????????¨?????????????????\??£???????????????append()??????????????????????????????pop()
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        if line.strip() == '0':
            print(s.pop())
        else:
            s.append(line.strip())

Measured memory_bytes: 7656
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#define ll long long int
using namespace std;
int main(void) {
  char r, g, b;
  cin>>r>>g>>b;
  int x=100*(r-'0')+10*(g-'0')+b-'0';
  if(x%4==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    ans = [0]*N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        ans[ai] += 1
        ans[bi] += 1

    print(*ans, sep='\n')
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 3316
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<cstring>
#define loop(i,r,l) for(int (i)=(r);(i)<(l);(i)++)
#define rep(i,n) loop(i,0,n)
using namespace std;

int main(){
    string s,t="CODEFESTIVAL2016";
    int res=0;
    cin>>s;
    rep(i,t.size()){
        if(s[i]!=t[i])res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll n;
vi parent;
vi rankk;
ll root(ll i){
    if(parent[i]==i)return i;
    return root(parent[i]);
}
void heigou(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y)return;
  if(rankk[x]<rankk[y])parent[x]=y;
  else if(rankk[x]>rankk[y])parent[y]=x;
  else{parent[y]=x;rankk[x]++;}
}
int main(){
    cin>>n;
    parent=vi(n);
    rankk=vi(n);
    rep(i,n)parent[i]=i;
    vi ans(n);
    ll m,k;cin>>m>>k;
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        heigou(a,b);
        ans[a]--;ans[b]--;
    }
    rep(i,k){
        ll a,b;cin>>a>>b;a--;b--;
        if(root(a)==root(b)){ans[a]--;ans[b]--;}
    }
    vi num(n);
    rep(i,n)num[root(i)]++;
    rep(i,n)ans[i]+=num[root(i)];
    rep(i,n)ans[i]--;
    outv(ans);
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String ans = "";
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) == '1') {
				ans += "9";
			} else {
				ans += "1";
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n;cin>>n;
  ll c=0LL,d=1LL;
  while(n>0){
    n/=2;
    c+=d;
    d*=2;
  }
  cout<<c;
}

Measured memory_bytes: 256
S = str(input())
l = list(map(str,(map(bin,range(2**(len(S)-1))))))

ans = 0
for i in range(len(l)):
    ev = l[i][2:].zfill(len(S)-1)
    res = 0
    num_str = S[0]
    for j in range(1,len(S)):
        if(ev[j-1] == '0'):
            num_str = num_str + S[j]
        else:
            res += int(num_str)
            num_str = S[j]
    res += int(num_str)
    ans += res

print(ans)

Measured memory_bytes: 3188
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
A = [ord(c) - ord('a') for c in S]
N = len(S)

# 答えの文字列の長さ
l = 0
# その文字以降で、何文字までの任意文字列を作れるか
lengths = [0] * N
counts = [0] * 26
for i, a in reversed(list(enumerate(A))):
    counts[a] += 1
    lengths[i] = l
    if min(counts) == 1:
        counts = [0] * 26
        l += 1
ans_size = l + 1

# 文字ごとの次のインデックス
graph = [[-1] * 26 for _ in range(N)]
pos = [-1] * 26
for i, a in reversed(list(enumerate(A))):
    graph[i] = pos[:]
    pos[a] = i
initials = pos


def solve(size, i=None):
    # i 番目から始まり、長さ size である、部分列でない文字列
    if i is None:
        pos = initials
    else:
        pos = graph[i]

    if size == 1:
        return chr(pos.index(-1) + ord('a'))

    size -= 1
    for ci, i in enumerate(pos):
        if lengths[i] < size:
            c = chr(ci + ord('a'))
            return c + solve(size, i)
    assert False


print(solve(ans_size))


Measured memory_bytes: 90572
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
int main()
{
	while (true)
	{
		int a, c, calc;
		char b;
		cin >> a >> b >> c;
		switch (b)
		{
		case '+':
			calc = a + c;
			break;
		case '-':
			calc = a - c;
			break;
		case '*':
			calc = a * c;
			break;
		case '/':
			calc = a / c;
			break;
		}
				
		if(b == '?')
				break;
		cout << calc << endl;
	}
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll bs(ll x){
	ll l = 1, r = 1e9, mid;
	ll ans = 1;
	while(l <= r){
		mid = l + (r - l)/2;
		ll cmp = (mid * (mid + 1)) >> 1;
		
		if(cmp <= x){
			ans = mid;
			l = mid + 1;
		}
		
		else
		r = mid - 1;
	}
	return ans;
}

int main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		cin >> n;


		i = 2;
		ll ans = 0;
		map<ll, ll> mp;
		// ll n1 = n;
		for(i=2; i*i <= n; i++) {
			ll c = 0;
			while (n % i == 0) {
				n = n / i;
				c++;
			}
			
			if(c >= 1 )
			mp[i] = c;
		
		}
		
		for(auto i : mp){
			// cout << i.S << endl;
			ans += bs(i.S);
		}
		
		if(n > 1) ans++;
		

		
		cout << ans << endl;


	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include"list"
using namespace std;
#define ll long long
#define inf (long long)1e10
#define IO {\
	freopen("input.txt","r",stdin);\
	freopen("output.txt","w",stdout);\
}
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}



int main(){


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

    }
    sort(a,a+n);
    for(int i=0;i+1<n;i++){
        if(a[i]==a[i+1]){
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<"YES\n";

}


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

#define N 
#define MP make_pair

int main()
{
	//freopen("in.txt", "r", stdin);
	
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		set<char> S;
		S.insert(a[i]);
		S.insert(b[i]);
		S.insert(c[i]);
 		if (S.size() == 2) ++ans;
 		else if (S.size() == 3) ans += 2;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

void solve() {
	string s;
	ll l = 0, r = 0;
	cin >> s;
	for(int i = 0; i < s.size(); ++i) if(s[i] == 'A') {l = i;break;}
	for(int i = (int)s.size() - 1; i >= 0; --i) if(s[i] == 'Z') {r = i; break;}
	cout << r - l + 1 << endl;
	return;
}
	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

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

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] > rank[y]){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

int main(){
	ll n; cin >> n;
	vvl x(101010), y(101010);
	rep(i,n){
		ll X,Y; cin >> X >> Y; X--; Y--;
		x[X].push_back(Y);
		y[Y].push_back(X);
	}
	UnionFind uf(202020);
	rep(i,100001){
		if(y[i].size() > 1){
			rep(j,y[i].size()-1){
				uf.unite(y[i][j]*2,y[i][j+1]*2);
			}
		}
		if(x[i].size() > 1){
			rep(j,x[i].size()-1){
				uf.unite(x[i][j]*2+1, x[i][j+1]*2+1);
			}
		}
	}
	ll ans = 0;
	rep(i,100001){
		if(x[i].empty()) continue;
		for(auto j : x[i]){
			if(uf.same(i*2, j*2+1)) continue;
			ans += uf.size(i*2) * uf.size(j*2+1);
			uf.unite(i*2, j*2+1);
		}
	}
	cout << ans - n << endl;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  
  if (a == 'H') {
    cout << b << endl;
  } else {
    if (b == 'H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }
  
  return 0;
}

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

#define IOS     ios_base::sync_with_stdio(0)
#define int     long long

int32_t main() {
    IOS;
    int n;
    cin >> n;
    int* arr1 = new int[n];
    int* arr2 = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> arr1[i];
        cin >> arr2[i];
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (count == 3)
            break;
        if (arr1[i] == arr2[i]) {
            count++;
        }
        else {
            count = 0;
        }
    }
    if (count == 3) {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

    delete[] arr1;
    delete[] arr2;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// make less_equal in order to make a multiset pbds


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	ll CaseN=1; 
	//cin>>t;
	while(t--)
	{	
		ll n;
		cin>>n;
		ll a[n+4];
	
		ll x=0;
		for(ll i=1;i<=n;i++)
		{
		cin>>a[i];	
		x = x^a[i];
		}
		
		
		for(ll i=1;i<=n;i++)
		{
		a[i]= a[i]^x;
		cout<<a[i]<<" ";	
		}
		cout<<endl;
		
		
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
		
	}

return 0;
}



Measured memory_bytes: 5164
using System;
using System.Linq;

namespace abc063_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[0] += a[1];
            if (a[0] >= 10) { Console.WriteLine("error"); }
            else { Console.WriteLine(a[0]); }
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int c[200001]={0};
    int redstorn=0;
    
    int n;
    scanf("%d\n", &n);
    char color;
    for(int i=1;i<=n;i++){
        scanf("%c", &color);
        //printf("%c",color);
        if(color=='R'){
            c[i]=1;
            redstorn++;
        }
    }
    
    int min=0;
    
    int rmin=0;
    for(int i=1;i<=redstorn;i++){
      //  printf("%d",c[i]);
        if(c[i]==0){
        rmin++;
        }
    }
    //printf("\n");
    int wmin=0;
    for(int i=n;i>redstorn;i--){
      //  printf("%d",c[i]);
        if(c[i]==1){
        wmin++;
        }
    }
    
    if(wmin<rmin){
        min=wmin;
    }else{
        min=rmin;
    }
    
    printf("%d",min);
}

Measured memory_bytes: 2512
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main()
{
    priority_queue< int,vector<int>,less<int> > que;
    int in;
    
    for(int i = 0; i < 10; i++){
        cin >> in;
        que.push(in);
    }
    
    
    for(int j = 0; j < 3; j++){
        cout << que.top() << '\n';
        que.pop();
    }
    
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>

#define INF 1000000

int list[101][101][2];
int cost[101];
bool used[101];
int n,m,k;

int main(){
	while(std::cin>>n>>m){
		if(n==0&&m==0)break;
		for(int i=0;i<=m;i++){
			for(int j=0;j<=m;j++){
				list[i][j][0]=INF;
				list[i][j][1]=INF;
			}
		}
		for(int i=0;i<n;i++){
			int a,b,c,d;
			std::cin>>a>>b>>c>>d;
			list[a][b][0]=c;list[a][b][1]=d;
			list[b][a][0]=c;list[b][a][1]=d;
		}
		std::cin>>k;
		for(int i=0;i<k;i++){
			for(int j=0;j<=m;j++)cost[j]=INF,used[j]=false;
			int p,q,r;
			std::cin>>p>>q>>r;
			cost[p]=0;
			while(1){
				used[p]=true;
				if(used[q])break;
				for(int i=1;i<=m;i++){
					if(list[p][i][r]!=INF){
						if(cost[i]>cost[p]+list[p][i][r])cost[i]=cost[p]+list[p][i][r];
					}
				}
				p=0;
				for(int i=1;i<=m;i++){
					if(!used[i]&&cost[p]>cost[i])p=i;
				}
			}
			std::cout<<cost[q]<<std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	m := make(map[string]int, 5000*5000)
	for i := 0; i < len(s); i++ {
		for j := i + 1; j <= i+k && j <= len(s); j++ {
			//fmt.Printf("[%d,%d] %s\n", i, j, s[i:j])
			m[s[i:j]]++
		}
	}
	ks := make([]string, 0)
	for k := range m {
		ks = append(ks, k)
	}
	sort.Strings(ks)
	fmt.Println(ks[k-1])
}


Measured memory_bytes: 879232