akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & -(x))
#define BIT(a,b) ((ll)((a)&(1<<(b)))==0 ? false : true)

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

    ll n,a,b;
    cin>>n>>a>>b;

    if (a>b || (n==1 && a!=b))
    {
        cout<<0;
        return 0;
    }

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    cout<<(n-2)*(b-a)+1;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }   

    private static void execute(BufferedReader br) throws Exception {
        int n = Integer.parseInt(br.readLine());
        int taro = 0, hanako = 0;
        for (int i = 0; i < n; i++) {
            String[] strs = br.readLine().split(" ");
            if (strs[0].compareTo(strs[1]) > 0) {
                taro += 3;
            }   
            else if(strs[0].compareTo(strs[1]) < 0) {
                hanako += 3;   
            }   
            else if(strs[0].compareTo(strs[1]) == 0) {
                taro++;
                hanako++;
            }   
        }   
        System.out.println(taro + " " + hanako);
    }   
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    string s, t; cin >> s >> t;

    ll ans = 0;
    rep(i, s.size()){
        if(s[i]!=t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3916
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    if A-1 <= N-B:
        count = A
        A = 1
        B = B - count
        print((B-A) // 2 + count)
    else:
        count = (N-B+1)
        A = A + count
        B = N
        print((B-A) // 2 + count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[])
{
	int n, i;
	double repay = 100000.0;
	// nを入力
	scanf("%d", &n);
	// nは100以下
	if (n <= 100) {
		// n回分のループ処理
		// 利子は5%/週
		// 返済額は1,000円未満切り上げ
		for (i = 0; i < n; ++i) {
			repay = repay * 1.05;
			// 1000に切り上げるために,1000で割ってから1000を掛ける
			repay = ceil(repay / 1000);
			repay = repay * 1000;
		}
		printf("%1.0f\n", repay);
	}
	return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int   N,a[101];
	
	i_cin(N);
	i_cins(N,a);
	if (N == 1) { i_cout(0); return 0; }

	qsort((void*)a, N,sizeof(a[0]),s_asort);
	
	i_cout(a[N-1]-a[0]);
	return 0;
}

//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}



Measured memory_bytes: 128
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    }
// end 

Measured memory_bytes: 23892
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b >= c)puts("Yes");
	else puts("No");
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int c = (a + n - 1) / n * n;
	if (c <= b)
		printf("OK\n");
	else
		printf("NG\n");
	return 0;
}

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

using namespace std;

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

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

    string s;
    cin>>s;

    for(ll i = 0 ; i < 3 ; i++)
    {
    	if(s[i] == s[i+1])
    	{
    		cout<<"Bad"<<endl;
    		return 0;
    	}
    }

    cout<<"Good"<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, x[3];
ll dp[41][1<<17];
int p[1<<17];
bool valid[1<<17];

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

int main() {
	cin >> n;
	REP(i, 3) cin >> x[i];
	int keta = x[0] + x[1] + x[2];
	
	REP(i, 17) p[1<<i] = i;
	
	REP(i, 1 << keta) {
		int now = i;
		int pos = 2, sum = 0;
		
		while (now > 0) {
			int last = p[now & -now] + 1;
			
			sum += last;
			if (sum == x[pos]) pos--, sum = 0;
			now >>= last;
		}
		
		if (pos != -1) valid[i] = true;
	}
	
	dp[0][0] = 1;
	
	REP(i, n) {
		REP(j, 1 << keta) {
			if (!dp[i][j]) continue;
			
			FOR(k, 1, 11) {
				int num = j << k | (1 << k - 1);
				num &= (1 << keta) - 1;
				
				if (valid[num]) (dp[i + 1][num] += dp[i][j]) %= MOD;
			}
		}
	}
	
	ll ans = 0;
	REP(i, 1 << keta) (ans += dp[n][i]) %= MOD;
	ans = (mod_pow(10, n, MOD) - ans + MOD) % MOD;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 40960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<int,int> pi;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	string S; cin >> S;
	int ans = 0;
	for (int i = 0; i < S.length() / 2; i++) {
		if (S[i] != S[S.length()-i-1]) ans++;
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
   char a;
   cin>>a;
   if(a=='A')
    cout<<"T"<<endl;
   else if(a=='T')
    cout<<"A"<<endl;
   if(a=='C')
    cout<<"G"<<endl;
   if(a=='G')
    cout<<"C"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		long n = nl();
		long n0=n;
		int s = 0;
		while (n>0) {
			s+=n%10;
			n/=10;
		}
		out.println(n0%s==0?"Yes":"No");
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
//  Table is the complete reverse of dp
//  Always think of the pattern (LCM, GCD)
const int MOD = (int)1e9 + 7;
unsigned long long fast_power(unsigned long long base, unsigned long long power)
{
    unsigned long long result = 1;
    while(power > 0)
    {
        if(power & 1)
        {
            result = ((result % MOD) * (base % MOD)) % MOD;
        }
        base = ((base % MOD) * (base % MOD)) % MOD;
        power >>= 1;
    }
    return result;
}
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    unsigned long long n, k, ans = 0;
    cin >> n >> k;
    unsigned long long *x = new unsigned long long[k + 1];
    for(unsigned long long i = k; i >= 1; i--)
    {
        unsigned long long tmp = fast_power(k / i, n);
        x[i] = tmp;
        for(int j = 2; i * j <= k; j++)
            x[i] = ((x[i] - x[i * j] + MOD) % MOD + MOD) % MOD;
        ans += (x[i] * i) % MOD;
        ans %= MOD;
    }
    cout << ans;
}

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

#define ll long long 
int main() {
  ll N;
  cin >> N;
  
  ll cur_num = 1;
  
  while(cur_num * 2 <= N) {
    cur_num *= 2;
  }
  
  cout << cur_num * 2 - 1 << endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,10){
		c=c*a-b;
		cout<<c<<endl;
	}
	
}


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

int main()
{
    double xa,ya,xb,yb,xc,yc,xd,yd;
    double v1x,v1y,v2x,v2y;
    while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd)
    {
        v1x = xb-xa;
        v1y = yb-ya;
        v2x = xd-xc;
        v2y = yd-yc;
        if( fabs(v1x*v2x+v1y*v2y)< DBL_MIN * 100){cout << "YES" << endl;}
        else {cout << "NO" << endl;}

    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,ans;
int main()
{
    string s;
	cin>>s;
	bool f=0;
	for(int i=0;i<s.length();i++)
	{
		if(i%2)
		{
			if(s[i]!='i')f=1;
		}
		else
		{
			if(s[i]!='h')f=1;
		}
	}
	if(f||s.length()%2)
	{
		printf("No\n");
	}
	else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
#define LL long long
#define MX 500005

int main()
{
    LL n,a,b,c,d;
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);

    LL l=0,r=n-1;
    int ok=0;
    while(l<=r)
    {
        LL mid = (l+r)/2;
        LL y = n-1-mid;
        LL w = b-a;
        if (mid*c>w+y*d)
            r = mid-1;
        else if (mid*d<w+y*c)
            l = mid+1;
        else
        {
            ok=1;
            break;
        }
    }
    if (ok)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    String W = sc.nextLine();
    String p = sc.nextLine().replaceAll(" ", "");
    String q = sc.nextLine().replaceAll(" ", "");
    char[] B = p.toCharArray();
    Arrays.sort(B);
    String s = new String(B);
    String g = s;
    ArrayList<String> list = new ArrayList<String>();
    while (true) {
      s = nextPermutation(s, list);
      if (s.equals("Final"))
        break;
    }
    list.add(g);
    Collections.sort(list);
    System.out.println(Math.abs(list.indexOf(p) - list.indexOf(q)));
  }

  public static String nextPermutation(String s, ArrayList<String> arg) {

    ArrayList<Character> list = new ArrayList<>();
    for (int i = 0; i < s.length(); i++)
      list.add(s.charAt(i));

    int pivotPos = -1;
    char pivot = 0;
    for (int i = list.size() - 2; i >= 0; i--) {
      if (list.get(i) < list.get(i + 1)) {
        pivotPos = i;
        pivot = list.get(i);
        break;
      }
    }

    if (pivotPos == -1 && pivot == 0)
      return "Final";

    int L = pivotPos + 1, R = list.size() - 1;
    int minPos = -1;
    char min = Character.MAX_VALUE;
    for (int i = R; i >= L; i--) {
      if (pivot < list.get(i)) {
        if (list.get(i) < min) {
          min = list.get(i);
          minPos = i;
        }
      }
    }

    Collections.swap(list, pivotPos, minPos);
    Collections.sort(list.subList(L, R + 1));

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < list.size(); i++)
      sb.append(list.get(i));

    arg.add(sb.toString());
    return sb.toString();

  }
}


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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    int a = 100 * r + 10 * g + b;
    if (a % 4 == 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int n,i,l;
    long a[5000],ans,s;
     
    for(i=0;i<5000;i++)a[i]=0;
   #include<stdio.h>
 
int main(void){
    int n,i,l;
    long a[5000],ans,s;
     
    for(i=0;i<5000;i++)a[i]=0;
     
    while(scanf("%d",&n)){
        if(n==0)break;
        ans=-100000;
        for(i=0;i<n;i++){
            scanf("%ld",&a[i]);
        }
         
        for(i=0;i<n;i++){
            s=0;
            for(l=i;l<n;l++){
                s+=a[l];
                if(ans<s)ans=s;
            }
        }
         
        printf("%ld\n",ans);
    }
    return 0;
}  
    while(scanf("%d",&n)){
        if(n==0)break;
        ans=-100000;
        for(i=0;i<n;i++){
            scanf("%ld",&a[i]);
        }
         
        for(i=0;i<n;i++){
            s=0;
            for(l=i;l<n;l++){
                s+=a[l];
                if(ans<s)ans=s;
            }
        }
         
        printf("%ld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()
L = len(T)
ans = INF

for i in range(len(S)-L+1):
    cnt = 0
    for x, y in zip(S[i:i+L], T):
        if x == y:
            cnt += 1
    ans = min(ans, L-cnt)
print(ans)


Measured memory_bytes: 9976
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	int count[n+1];
	memset(count,0,sizeof(count));
	for(int i=1;i<=n;i++){
	for(int j=i;j<=n;j++){
		count[min({abs(j-i),abs(abs(i-x)+1+abs(j-y))})]++;
		}	
		}
		for(int i=1;i<n;i++){
			cout<<count[i]<<"\n";
			}
	return 0;
	}


Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

s_dic = dict()
t_dic = dict()

flag = True
for i in range(len(s)):
    s_i = s[i]
    t_i = t[i]
    if s_i not in s_dic:
        s_dic[s_i] = t_i
    else:
        if s_dic[s_i] != t_i:
            flag = False
    if t_i not in t_dic:
        t_dic[t_i] = s_i
    else:
        if t_dic[t_i] != s_i:
            flag = False

if flag:
    print("Yes")
else:
    print("No")


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

int H, W, N;
int sr, sc;
string S, T;

int main() {
    cin >> H >> W >> N;
    cin >> sr >> sc >> S >> T;
    
    bool f = true;
    int t_r = 0;
    int a_l = 0;
    int t_l = 0;
    int a_r = 0;
    int t_u = 0;
    int a_d = 0;
    int t_d = 0;
    int a_u = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') t_r++;
        if (S[i] == 'L') t_l++;
        if (S[i] == 'U') t_u++;
        if (S[i] == 'D') t_d++;

        if (sc + t_r - a_l > W  || sc - t_l + a_r < 1 ||
            sr - t_u + a_d < 1 || sr + t_d - a_u > H ) {
            f = false;
        }        

        if (T[i] == 'L' && sc + t_r - a_l > 1) a_l++;
        if (T[i] == 'R' && sc - t_l + a_r < W) a_r++;
        if (T[i] == 'D' && sr - t_u + a_d < H) a_d++;
        if (T[i] == 'U' && sr + t_d - a_u > 1) a_u++;
    }

    cout << (f ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
int a[100005];
int main()
{
	int n,k;
	sc(n);sc(k);
	rep(i,1,k){
		int cou;sc(cou);
		rep(j,1,cou){
			int u;sc(u);a[u]=1;
		}
	}int count=0;
	rep(i,1,n)if(a[i]==0)count++;
	pf("%d\n",count);
}


Measured memory_bytes: 3812
N = int(input())
A = [int(input()) for i in range(N)]

# S = sorted(A)
# MAXS = max(A)
# two = S[-2]
# print("MAX {} two {}".format(MAXS,two))
# count = S.count(max(S))
#
# for i in range(N):
#     if A[i] == MAXS:
#         if count > 1:
#             print(MAXS)
#         else:
#             print(two)
#     else:
#         print(MAXS)

# 


# c = a.index(max(a))
# m = max(a)
# a.sort()
# d = a[-2]
# for i in range(n):
#     if i == c:
#         print(d)
#     else:
#         print(m)
# 
# 


S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])


# #
# for i in range(N):
#
#     if i == 0:
#         print(max(A[1:]))
#
#     elif i == N-1:
#         print(max(A[:i]))
#
#     else:
#         low = max(A[0:i])
#         high = max(A[i+1:])
#
#         if high > low:
#             print(high)
#         else:
#             print(low)


Measured memory_bytes: 15708
use std::collections::HashMap;
use std::io;
use std::io::{BufRead, Write};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let a: Vec<i64> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut acc = 0;
    let mut counts = HashMap::new();
    counts.insert(0, 1);
    for sum in a.iter().map(|&x| {
        acc += x;
        acc
    }) {
        *counts.entry(sum).or_insert(0usize) += 1;
    }
    let result: usize = counts.values().map(|x| x * (x - 1) / 2).sum();
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "6
1 3 -4 2 2 -2
",
            "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "7
1 -1 1 -1 1 -1 1
",
            "12\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "5
1 -2 3 -4 5
",
            "0\n",
        );
    }
}


Measured memory_bytes: 18380
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    p = tuple(LI())
    q = tuple(LI())
    a = b = -1
    for i,t in enumerate(itertools.permutations(range(1,n+1))):
        if t == p:
            a = i
        if t == q:
            b = i

    return abs(a-b)


print(main())





Measured memory_bytes: 5964
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    vector<int> key(n);
    rep(i,n) cin >> key[i];
    int x = 0;
    string str;
    cin >> str;
    while(key.size() < str.size()){
      if(x==key.size()) x = 0;
      key.push_back(key[x]);
      x++;
    }
    rep(i,str.size()){
      rep(j,key[i]){
        if(str[i]=='a') str[i] = 'Z';
        else if(str[i]=='A') str[i] = 'z';
        else str[i]--;
      }
    }
    rep(i,str.size()) cout << str[i];
    cout << endl;
  }
  return 0;
}




Measured memory_bytes: 3216
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

vector<pair<int64_t, int64_t>>
make_divisors(int64_t n) {
    vector<pair<int64_t, int64_t>> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back({i, n / i});
        }
    }
    return ret;
}
int main() {
    int64_t n; cin >> n;

    auto divs = make_divisors(n);
    int64_t ans = (1LL << 60);
    for (auto &p: divs) {
        auto x = p.first;
        auto y = p.second;
        auto diff = abs(x - 1) + abs(y - 1);
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

cnt = Counter(A)
lst = [0]*(10**5+1)

for i,j in cnt.items():
    lst[i] = j
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += lst[b]*(c-b)
    lst[c] += lst[b]
    lst[b] = 0
    print(ans)

Measured memory_bytes: 21248
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
#include<chrono>
#include <fstream>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}*/
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x);

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


/*ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}*/

ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}
ll sum_digit(ll n)
{
	ll ans = 0;
	while (n)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll gp(ll r, ll n)
{
	return (pow(r, n) - 1) / (r - 1);
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans;
	if(n%x==0)
		ans=(n/x)*t;
	else
	{
		ans=(n/x+1)*t;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
/*
时间:2020-7-31
书籍：算法和数据结构
内容：归并排序
页数：P121 
*/
#include<iostream>
using namespace std;
int cnt;
const int Max =99999999999;                //最大值
const int MAX2 = 500000;
int N1[MAX2 / 2 + 2];
int N2[MAX2 / 2 + 2];                     //在merge中使用固定长的数组，使用共同一个数组。
void merge(int A[],int n,int left,int mid,int right)   //对于长度为n的数组，left=0；right=n，right不是n-1,不然接下来的算法无法包括mid
{
	int n1, n2;
	n1 = mid - left;
	n2 = right - mid;
	for (int i = 0; i < n1; ++i)
		N1[i] = A[left + i];
	N1[n1] = Max;
	for (int i = 0; i < n2; ++i)
		N2[i] = A[mid + i];
	N2[n2] = Max;                             //最后一个储存单元用于存取最大值，以防后面排序时数组下标越界
	int i = 0, j = 0;
	for (int k = left; k < right; ++k)
	{
		++cnt;
		if (N1[i] <= N2[j])
		{
			A[k] = N1[i];
			++i;
		}
		else
		{
			A[k]=N2[j];
			++j;
		}
	}
;
}
void mergeSort(int A[],int n, int left, int right)
{
	int mid = (left + right) / 2;
	if (left + 1 >= right)                  //注意递归结束的条件
		return;
	mergeSort(A, n, left, mid);
	mergeSort(A, n, mid, right);
	merge(A, n, left, mid, right);
	return;

}
int main() 
{
	int n;
	cin >> n;
	int* A = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	mergeSort(A, n, 0, n);
	for (int i = 0; i < n - 1; ++i)
		cout << A[i] << " ";
	cout << A[n - 1] << endl;
	cout << cnt << endl;
	return 0;
}


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

fn main() {
    input! {
        n: usize
    }

    let odd_ceil_n = if n % 2 == 0 {n+1} else {n};
    let mut ret = vec![];
    for i in 1..odd_ceil_n+1 {
        let m = odd_ceil_n - i;
        for j in i+1..n+1 {
            if m == j {continue;}
            ret.push((i, j));
        }
    }

    println!("{}", ret.len());
    for i in 0..ret.len() {
        println!("{} {}", ret[i].0, ret[i].1);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int ans = 0;
    int i = 1;
    while (true)
    {
       ll num = i * i;
       if (num > n)
       {
           break;
       }
       ans = num;
       i++;
    }
    
    cout << ans << endl;
}

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

using namespace std;
using ll        = long long;
using vi        = vector<int>;
using predicate = function<bool(int)>;

const int AMAX = 1e9 + 11;

int n, k;
vi  a;

bool is_possible(int l)
{
    ll c = 0;
    for (int x : a)
        c += (x - 1) / l;
    return c <= k;
}

ll bsearch(ll l, ll r, predicate p)
{
    while (l < r)
    {
        ll m = l + (r - l) / 2;
        if (p(m))
            r = m;
        else
            l = m + 1;
    }
    return l;
}

int main(void)
{
    cin >> n >> k;
    a.resize(n);
    for (auto &x : a)
        cin >> x;

    cout << bsearch(1, AMAX, is_possible) << endl;

    return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <vector>

using namespace std;


void solve(vector<int> &S1, vector<int> &S2) {
    int N = S1.size(), M = S2.size();
    int sum1 = 0, sum2 = 0;
    int sumcard = 1 << 30, ans1, ans2;
    for(int i = 0; i < N; i++) sum1 += S1[i];
    for(int i = 0; i < M; i++) sum2 += S2[i];
    int diff = sum1 - sum2;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            if (2 * (S1[i] - S2[j]) == diff) {
                if (sumcard > S1[i] + S2[j]) {
                    sumcard = S1[i] + S2[j];
                    ans1 = S1[i];
                    ans2 = S2[j];
                }
            }
        }
    }
    if (sumcard == 1 << 30) {
        cout << -1 << endl;
    } else {
        cout << ans1 << " " << ans2 << endl;
    }
}

int main() {
    int N, M;
    while(cin >> N >> M, N) {
        vector<int> S1(N), S2(M);
        for(int i = 0; i < N; i++) cin >> S1[i];
        for(int i = 0; i < M; i++) cin >> S2[i];
        solve(S1, S2);
    }
    return 0;
}


Measured memory_bytes: 3040
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

int n, m;
char a[15][15];

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> a[i][j];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j){
            if (a[i][j] == '#' && a[i][j + 1] == '#' && a[i + 1][j] == '#' && a[i + 1][j + 1])
                return !(cout << "Impossible");
            if (i == 1 && j == 1)
                continue;
            if (a[i][j - 1] != '#' && a[i - 1][j] != '#' && a[i][j] == '#')
                return !(cout << "Impossible");
        }
    if (a[n][m] != '#')
        return !(cout << "Impossible");
    cout << "Possible";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void ch(int x){
  if(x==0) printf("00");
  else if(x<10) printf("0%d",x);
  else printf("%d",x);
  return;
}

void print(int A,int B,int C){
  //printf("//%d %d %d\n",A,B,C);
  ch(A);
  printf(":");
  ch(B);
  printf(":");
  ch(C);
  printf("\n");
  return;
}

int main(void){
  int T,H,S;
  int J,B;

  while(scanf("%d %d %d",&T,&H,&S)!=EOF){
    if(T==-1 && H==-1 && S==-1)   break;
    else{
      J=T*3600+H*60+S;
      J=7200-J;
      B=3*J;
      T=J/3600;
      J=J%3600;
      H=J/60;
      S=J%60;
      //printf("%d %d %d\n",T,H,S);
      print(T,H,S);
      T=B/3600;
      B=B%3600;
      H=B/60;
      S=B%60;
      print(T,H,S);
    }
  }
  return 0;
}

Measured memory_bytes: 604
N, K = map(int, input().split())

if N<K:
    if N>K/2:
        print(K-N)
    else:
        print(N)

elif N==K:
    print(0)
else:
    amari = N%K
    if amari>K/2:
        print(K-amari)
    else:
        print(amari)

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

int main(){
  double a, b, x, ans;
  scanf("%lf%lf%lf", &a, &b, &x);
  x /= a;
  if(x <= a * b / 2){
    ans = atan((b * b) / (2 * x));
  }
  else{
    ans = atan(2 * (a * b - x) / (a * a));
  }
  printf("%.10lf\n", ans * 180 / M_PI);
  return 0;
}

Measured memory_bytes: 512
n, a, b = map(int, input().split())
s = input()
total = 0
cnt_b = 0
for i in range(n):
    if s[i] == "c":
        print("No")
    else:
        if total < a + b:
            if s[i] == "a":
                print("Yes")
                total += 1
            elif s[i] == "b" and cnt_b < b:
                print("Yes")
                total += 1
                cnt_b += 1
            else:
                print("No")
        else:
            print("No")




Measured memory_bytes: 4016
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int d;
  cin>>d;
  cout << "Christmas";
  for (int i(0);i<25 - d;i++){
    cout << " Eve";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i=1;i<=n;i++){
		if (i%3 == 0 || i%10 == 3 || (i/10)%10 == 3 || (i/100)%10 == 3 || (i/1000)%10 == 3 || (i/10000)%10 == 3){
			cout << ' ' << i;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	string s;
	lli data[26]={0};

	cin>>s;
	REP(i,0,s.size()){
		data[s.at(i)-'A']++;
	}

	REP(i,0,26){
		if(data[i]!=0){
			if(data[i]!=2){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
 
	return 0;
}

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

int main() {
  int N,M,a,b;
  cin >> N >> M;
  vector<int> ab;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    ab.push_back(a);
    ab.push_back(b);
  }
  
  for(int i = 1; i < N+1; i++){
    int c = 0;
    for(int j = 0; j <M*2; j++){
      if(i == ab.at(j))
        c += 1;
    }
    cout << c <<endl;   
  }
}

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

int N, A[100000 + 2], S;

int main() {
  cin >> N;
  for(int i = 1; i <= N; ++i) cin >> A[i];
  for(int i = 0; i <= N; ++i) S += abs(A[i + 1] - A[i]);
  for(int i = 1; i <= N; ++i) {
    cout << S - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i])
      + abs(A[i + 1] - A[i - 1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ca = (C + B - 1) / B;
	int cb = (A + D - 1) / D;
	
	puts([&] {
		return ca <= cb;
	}() ? "Yes": "No");
	
	return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll MEMO[200];

ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll K;
  cin >> K;
  set<ll> gcd_set;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      ll gcd_v = euclidean_gcd(i, j);
      MEMO[gcd_v]++;
      gcd_set.insert(gcd_v);
    }
  }
  ll ans = 0;
  for (int i = 1; i <= K; i++) {
    for (auto j : gcd_set) {
      ans += MEMO[j] * euclidean_gcd(j, i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000003;

ll modpow(ll x, ll y){
    ll r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}

inline ll mod_inverse(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        swap(a -= t * b, b);
        swap(u -= t * v, v);
    }
    return (u % m + m) % m;
}
int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vector<ll> tbl(MOD + 1, 1);
    REPS(i, MOD - 1) tbl[i + 1] = tbl[i] * i % MOD;
    while(cin >> m){
        REP(_, m) {
            ll x, d, n;
            cin >> x >> d >> n;
            if (d == 0) {
                cout << modpow(x, n) << endl;
                continue;
            }
            x = x * mod_inverse(d, MOD) % MOD;
            if (MOD < x + n) {
                cout << 0 << endl;
                continue;
            }
            cout << tbl[x + n] * mod_inverse(tbl[x], MOD) % MOD * modpow(d, n) % MOD << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8704
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main() {
  int n, ans = 0, l, r, mid, flag;
  string s;
  set<string> se;
  cin >> n >> s;
  l = 1;
  r = n / 2;

  while (l <= r) {
    flag = 0;
    mid = (l + r) / 2;
    se.clear();
    for (int j = 0; 2 * mid + j - 1 < n && ans != mid; j++) {
      se.insert(s.substr(j, mid));
      if (se.find(s.substr(mid + j, mid)) != se.end()) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << r << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s.back() == 's') {
        s.push_back('e');
        s.push_back('s');
    }
    else {
        s.push_back('s');
    }
    cout << s << endl;
    return 0;
}





Measured memory_bytes: 3648
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] d = new int[N];
    for (int i = 0; i < N; i++) d[i] = scanner.nextInt();

    long sum = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        sum += d[i] * d[j];
      }
    }
    System.out.println(sum);
  }
}


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

struct node
{
    long long int first;
    long long int second;
};
node mat[3002][3002];
int main()
{
    long long int n,i,j,val[100005],len;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>val[i];
    }
    for(i=1;i<=n;i++)
    {
        mat[i][i].first = val[i];
        mat[i][i].second = 0;
    }
    for(len = 2;len<=n;len++)
    {
        for(i=1;i<=n-len+1;i++)
        {
            j = i+len-1;
            if(val[i] + mat[i+1][j].second > val[j] + mat[i][j-1].second)
            {
                mat[i][j].first = val[i] + mat[i+1][j].second;
                mat[i][j].second = mat[i+1][j].first;
            }
            else
            {
                mat[i][j].first = val[j] + mat[i][j-1].second;
                mat[i][j].second = mat[i][j-1].first;
            }
            
        }
    }
    // cout<<"-----------\n";
    // for(i=1;i<=n;i++)
    // {
    //     for(j=1;j<=n;j++)
    //     {
    //         cout<<mat[i][j].first<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<"-----------\n";
    // for(i=1;i<=n;i++)
    // {
    //     for(j=1;j<=n;j++)
    //     {
    //         cout<<mat[i][j].second<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<mat[1][n].first - mat[1][n].second<<endl;
}

Measured memory_bytes: 139648