akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		HashSet<Integer> a = new HashSet<>();
		int k=0;
		
		for(int i=0;i<n;i++) {
			k=sc.nextInt();
			a.add(k);
		}
		
		if(a.size()==n) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 70424
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))
    N = int(next(tokens))
    A_list = []
    for i in range(N):
        A_list.append(int(next(tokens)))

    solve(H, N, A_list)

def solve(H: int, N: int, A_list: list):
    sum_a = 0
    for a in A_list:
        sum_a = sum_a + a

    if H <= sum_a:
        print('Yes')
    else:
        print('No')

    return


 
if __name__ == "__main__":
    propare()

Measured memory_bytes: 13996
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define N 100001
using namespace std;

int n;
int a[N],b[N],c[N];
int  dp[N][3];

int fun(int i,int j){
    if(i==0){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(j==0){
        return dp[i][j] = max(fun(i+1,1)+b[i],fun(i+1,2)+c[i]);
    }
    else if(j==1){
        return dp[i][j] = max(fun(i+1,0)+a[i],fun(i+1,2)+c[i]);
    }
    else{
        return dp[i][j] = max(fun(i+1,0)+a[i],fun(i+1,1)+b[i]);
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<max(fun(1,0)+a[0],max(fun(1,1)+b[0],fun(1,2)+c[0]))<<endl;
    return 0;
}

Measured memory_bytes: 7296
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a[] = new int[n-1];
        for(int i=0;i<n-1;i++){
            a[i] = in.nextInt();
        }
        int sum=a[0];
        for(int i=1;i<n-1;i++){
            sum+=Math.min(a[i],a[i-1]);
        }sum+=a[n-2];
        out.println(sum);
        
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int main(){
    int x,a,b;

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

    if(abs(x-a)<abs(x-b)){
        printf("A");
    }
    else{
        printf("B");
    }

    return 0;
}

Measured memory_bytes: 128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, l[ohara], r[ohara];
P p1[ohara], p2[ohara];
ll dat[ohara], le = -LINF, ri = LINF;
rpq qu;

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

  cin >> n;
  rep(i, n) {
    cin >> p1[i].fi >> p1[i].se;
    p2[i] = p1[i];
  }
  sort(p1, p1 + n);
  rep(i, n) {
    l[i] = p1[i].fi, r[i] = p1[i].se;
    ri = min(ri, r[i]);
    le = max(le, l[i]);
  }

  ll ma_le = -LINF, mi_ri;
  //左入れる
  rep(i, n) qu.push(r[i]);
  mi_ri = qu.top();
  U_MAP mp;

  rep(i, n - 1) {
    ma_le = max(ma_le, l[i]);
    cnt = max(0LL, ri - ma_le + 1);
    mp[r[i]]++;
    while (1) {
      if (mp[qu.top()] >= 1) {
        mp[qu.top()]--;
        qu.pop();
      } else {
        break;
      }
    }
    mi_ri = qu.top();
    cnt += max(0LL, mi_ri - le + 1);
    ans = max(ans, cnt);
    // cout << i << " " << ma_le << " " << mi_ri << "\n";
  }
  //別処理
  rep(i, n) { tmp = max(r[i] - l[i] + 1, tmp); }
  ans = max(ans, max(0LL, ri - le + 1) + tmp);

  Cout(ans);
  return 0;
}

Measured memory_bytes: 19444
def factor(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == [] and n != 1:
        arr.append([n, 1])
    return arr

n = int(input())
fact_n = factor(n)
cnt = 0
for _, e in fact_n:
    i = 1
    while i <= e:
        e -= i
        i += 1
    cnt += i - 1
print(cnt)

Measured memory_bytes: 9236
def main():
  S = str(input())
  s = list(S)
  T = str(input())
  t = list(T)
  alpha2num = lambda c: ord(c) - ord('a')
  r = [-1]*26
  r_ = [-1]*26
  ans = "Yes"
  for i in range(len(s)):
    if r[alpha2num(s[i])] >= 0:
      if r[alpha2num(s[i])] == alpha2num(t[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r[alpha2num(s[i])] = alpha2num(t[i])
    if r_[alpha2num(t[i])] >= 0:
      if r_[alpha2num(t[i])] == alpha2num(s[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r_[alpha2num(t[i])] = alpha2num(s[i])
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 6704
N = int(input())
if N == 1:
    print(1)
    exit()
max_count = 0
ans = 0
for i in range(1, N+1):
    tmp_i = i
    count = 0
    while True:
        if tmp_i % 2 == 0:
            count += 1
            tmp_i = tmp_i // 2
        else:
            if max_count < count:
                ans = i
                max_count = count
            break
print(ans)

Measured memory_bytes: 3064
#import sys
#import numpy as np
import itertools
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford, floyd_warshall
#sys.setrecursionlimit(10000)

H, W = [int(i) for i in input().split()]

rows = []
cols = []
weights = []

"""
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)
"""
for i in range(10):
    # u v 間のコスト
    c = [int(j) for j in input().split()]
    #print(c)
    for j in range(10):
        rows.append(i)
        cols.append(j)
        weights.append(c[j])

#graph = coo_matrix((weights, (rows, cols)), shape=(10, 10)).tocsr()
graph = coo_matrix((weights, (cols, rows)), shape=(10, 10)).tocsr()

#d1 = dijkstra(graph, indices=1, directed=True, unweighted=False)
d2 = floyd_warshall(graph, directed=True, unweighted=False)
#print(d2)

ans = 0

for i in range(H):
    a = [int(_) for _ in input().split()]
    for j in a:
        if j != -1:
            ans += d2[1][j]

print(int(ans))

Measured memory_bytes: 14404
import  java.util.Scanner;


public class Main {
	Scanner sc;
	private int parse( String mcxi ){
		boolean isNumEntered = false;
		int mk = 0;
		int ck = 0;
		int xk = 0;
		int ik = 0;
		int cur = 0;
		char[] cstr = mcxi.toCharArray();
		for( int i = 0; i < cstr.length; i++ ){
			switch( cstr[ i ] ){
				case 'm':
					mk = cur;
					if( !isNumEntered ){ mk = 1; }
					isNumEntered = false;
					break;
				case 'c':
					ck = cur;
					if( !isNumEntered ){ ck = 1; }
					isNumEntered = false;
					break;
				case 'x':
					xk = cur;
					if( !isNumEntered ){ xk = 1; }
					isNumEntered = false;
					break;
				case 'i':
					ik = cur;
					if( !isNumEntered ){ ik = 1; }
					isNumEntered = false;
					break;
				default:
					cur = cstr[ i ] - '0';
					isNumEntered = true;
					break;
			}
		}
		return mk * 1000 + ck * 100 + xk * 10 + ik;
	}

	private String getMcxi( int in ){
		int mk = in / 1000;
		in %= 1000;
		int ck = in / 100;
		in %= 100;
		int xk = in / 10;
		in %= 10;
		int ik = in;
		String r = "";
		if( mk >= 2 ){ r += mk; }
		if( mk >= 1 ){ r += "m"; }
		if( ck >= 2 ){ r += ck; }
		if( ck >= 1 ){ r += "c"; }
		if( xk >= 2 ){ r += xk; }
		if( xk >= 1 ){ r += "x"; }
		if( ik >= 2 ){ r += ik; }
		if( ik >= 1 ){ r += "i"; }
		return r;
	}

	private void run(){
		sc = new Scanner( System.in );
		int n = sc.nextInt();
		for( int i = 0; i < n; i++ ){
			System.out.println( getMcxi ( parse( sc.next() ) + parse( sc.next() ) ) );
		}
	}
	public static void main( String[] args ){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  string s;
  cin >> s;
  
  ll z = 0, o = 0;
  for(ll i = 0; i < s.size(); i++){
    if(s[i] == '0') z++;
    else o++;
  }

  cout << min(z, o) * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
vector<ll> sum;
ll fin(ll x, ll y, ll val){
	ll lef = x, rig = y;
	while(rig-lef>1){
		ll mid = (lef+rig)/2;
		if(sum[mid]>val/2)rig=mid;
		else lef = mid;
	}
	ll ldif = abs( sum[lef] - val/2 );
	ll rdif = abs( sum[rig] - val/2 );
	if(ldif<rdif)return lef;
	else return rig;
}
int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	vector<ll> half_normal, half_reversed;
	half_normal.pb(-1);
	half_reversed.pb(-1);
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	vector<ll> fixed_sum;
	fixed_sum.pb(a[0]);
	for(int i=1;i<n;i++){
		fixed_sum.pb(fixed_sum[i-1]+a[i]);
	}
	sum.pb(a[0]);
	for(int i=1;i<n;i++){
		sum.pb(sum[i-1]+a[i]);
		half_normal.pb( fin(0,i-1,sum[i]) );
	}
	sum.clear();
	reverse(a.begin(),a.end());
	sum.pb(a[0]);
	for(int i=1;i<n;i++){
		sum.pb(sum[i-1]+a[i]);
		half_reversed.pb( fin(0,i-1,sum[i]) );
	}
	ll ans = -1;
	for(int i=1;i<n-2;i++){
		vector<ll> pqrs;
		ll p = fixed_sum[ half_normal[i] ];
		ll q = fixed_sum[ i ] - fixed_sum[ half_normal[i] ];
		ll r = fixed_sum[ n - 2 - half_reversed[ n-2-i ] ] - fixed_sum[i];
		ll s = fixed_sum[n-1] - fixed_sum[ n - 2 - half_reversed[ n-2-i ] ];
		pqrs.pb(p);
		pqrs.pb(q);
		pqrs.pb(r);
		pqrs.pb(s);
		sort(pqrs.begin(),pqrs.end());
		ll tmp = pqrs[3]-pqrs[0];
		//cout<<p<<" "<<q<<" "<<r<<" "<<s<<" "<<half_normal[i]<<" "<<i<<" "<<n-2-half_reversed[n-2-i]<<endl;;
		if( ans == -1 || tmp<ans){
			ans = tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<vector<int>> G(n);
	vector<PI> vp;
	rep(i,n-1){
		int a, b; cin >> a >> b;
		a--; b--;
		G.at(a).push_back(b);
		G.at(b).push_back(a);
		vp.push_back(make_pair(a, b));
	}
	map<PI, int> M; //<頂点,頂点>で使う色
	queue<int> que;
	que.push(0);
	vector<int> cs(n,0); //その頂点の親(ある頂点に対するbfsでの一個手前の頂点)を結ぶ辺の色
	vector<int> seen(n, 0);
	seen.at(0) = 1;
	int K = 0; //辺の数の最大値
	while(!que.empty()){
		int v = que.front(); que.pop();
		if(K < (int)G.at(v).size()) K = G.at(v).size();
		int color = 1;
		for(int nv: G.at(v)){
			if(seen.at(nv)) continue;
			seen.at(nv) = 1;
			if(color == cs.at(v)) color++; //vはbfsの一個前の辺でこのcolorを使っちゃってる
			cs.at(nv) = M[make_pair(v, nv)] = M[make_pair(nv, v)] = color;
			color++;
			que.push(nv);
		}
	}
	cout << K << endl;
	for(auto p: vp){
		cout << M[p] << endl;
	}
}

Measured memory_bytes: 20088
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll H,W; cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >> A.at(i).at(j);
    }
  }
  rep(i,W+2){
    cout << "#";
  }
  cout << endl;
  rep(i,H){
    cout << "#";
    rep(j,W){
      cout << A.at(i).at(j);
    }
    cout << "#" << endl;
  }
  rep(i,W+2){
    cout << "#";
  }
}
  
    

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

int main(){
    int s;
    int j = 0;
    cin >> s;

    int v[200];
    for(int i = 0; i < s; i++){
      cin >> v[i];
    }

    while (true){
      bool exist_odd = false;
      //cout << j-1 <<endl;
      j++;
      for(int i = 0; i < s; i++){
        if (v[i] % (int)pow(2,j) != 0) exist_odd = true;
      }
      if (exist_odd) break;
    }

    cout << j-1 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define forb(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b,c,x,y;
	vi v;
	cin >> a >> b >> c >> x >> y;
	
	int d =  (x * a) + (y * b);
	
	int cu ; 
	if(x > y){
		int w = 2 * y;
		int jum = w * c;
		int se = x - y;
		int jum2 = se * a;
		int tot = jum + jum2 ;
		
		
		int t = 2 * x;
		int jums = c * t;
		
		cu = min(tot,jums);
		
	}else if(x < y){
		int w = 2 * x;
		int jum = w * c;
		int se =  y - x;
		int jum2 = se * b;
		int tot = jum + jum2 ;
		
		int t = 2 * y;
		int jums = c* t;
		
		cu = min(tot,jums);
		
	}else{
		
		int w = 2 * x;
		int jum = w * c;
		
		cu = jum ;
	}
	cout << min(d,cu) << endl;
	
	
	return 0;
}


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


public class Main {


	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		SqrtDecomposition sq = new SqrtDecomposition(n);
//		long[] array = new long[n + 1];
//		long[] bucket = new long[(n + 1)/sectionLen + 1];

		for(int i = 0; i < q ; i++){
			tmpArray = br.readLine().split(" ");
			if(tmpArray[0].equals("0")){
//				add(array, bucket, Integer.parseInt(tmpArray[1]), Integer.parseInt(tmpArray[2]), Integer.parseInt(tmpArray[3]) );
				sq.add(Integer.parseInt(tmpArray[1]), Integer.parseInt(tmpArray[2]) + 1, Integer.parseInt(tmpArray[3]));
			}

			else {
				System.out.println(sq.get(Integer.parseInt(tmpArray[1])));
			}
		}
	}

//	static void add(long[] array, long[] bucket, int s, int t, int x){
//
//		if(s/sectionLen == t/sectionLen){
//			for(int i = s; i <= t; i++){
//				array[i] += x;
//			}
//		}
//	}

}

class SqrtDecomposition {
	int N, K;
	long[] data;
	long[] bucketAdd;
	static final int sqrtN = 512;

	public SqrtDecomposition(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketAdd = new long[K];
	}

	void add(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
			} else {
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					data[i] += x;
				}
			}
		}
	}

	long get(int s) {
		int k = s / sqrtN;
//		System.out.println(s+" "+k);
		return data[s] + bucketAdd[k];
	}
}

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

#define FLOOR true
#define STEP false

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    string input;
    int count = 0;
    bool before_state = FLOOR, left = FLOOR, right = FLOOR;
    for(int i = 0; i < n; i++){
      cin >> input;
      if(input == "lu"){ left = STEP; }
      else if(input == "ru"){ right = STEP; }
      else if(input == "ld"){ left = FLOOR; }
      else if(input == "rd"){ right = FLOOR; }

      if(left == STEP && right == STEP){
        if(before_state == FLOOR){ ++count; }
        before_state = STEP;
      }
      else if(left == FLOOR && right == FLOOR){
        if(before_state == STEP){ ++count; }
        before_state = FLOOR;
      }
    }
    
    cout << count << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3120
'use strict'

const main = (arg) => {
  const S = arg.split('\n')[0]

  if (S.split('hi').filter(v => v).length == 0) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

string s, t;
string lcs;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    s+='.', t+='.';
    string stmp, ttmp;
    cin>>stmp>>ttmp;
    s+=stmp;
    t+=ttmp;
	int n1=s.size()-1;
	int n2=t.size()-1;
	vector<vector<int>> dp(n1+1, vector<int>(n2+1));
	vector<vector<pair<int, int>>> nx(n1+1, vector<pair<int, int>>(n2+1));
	
	for(int i=1; i<=n1; i++) {
		for(int j=1; j<=n2; j++) {
			int ans1=max((dp[i-1][j]), (dp[i][j-1]));
			
			if(s[i]==t[j]) {
				dp[i][j]=1+dp[i-1][j-1];
				nx[i][j]={i-1, j-1};
			}
			else {
				dp[i][j]=(ans1==(dp[i-1][j])?dp[i-1][j]:dp[i][j-1]);
				if(ans1==dp[i-1][j]) {
					nx[i][j]={i-1, j};
				}
				else {
					nx[i][j]={i, j-1};
				}
			}
		}
	}
	function<void(int, int)> printlcs = [&](int x, int y)
	{
		if(x<=0 or y<=0) return;
		if(s[x]==t[y] and nx[x][y]==make_pair(x-1, y-1)) {
			lcs+=s[x];
		}
		int newx=nx[x][y].first;
		int newy=nx[x][y].second;
		printlcs(newx, newy);
	};
	printlcs(n1, n2);
	//~ for(int i=0; i<sz(nx); i++) {
		//~ for(int j=0; j<sz(nx[i]); j++) {
			//~ cout<<nx[i][j].first<<" "<<nx[i][j].second<<"\n";
		//~ }
	//~ }
	reverse(all(lcs));
	cout<<lcs<<"\n";
    return 0;
}



Measured memory_bytes: 106240
import math
N, D = input().split()
N, D = [int(N), int(D)]

count = 0

for i in range (N):
    x, y = input().split()
    x, y = [int(x), int(y)]
    ans = math.sqrt((x**2)+(y**2))
    if ans <= D:
        count += 1

print(count)


Measured memory_bytes: 9200
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs32 a(n);
    for (auto& x : a) cin >> x;

    int s = 0;
    rep (i, n) s ^= a[i];

    vs32 ans(n, 0);
    rep (i, n) ans[i] = s ^ a[i];

    rep (i, n)
    {
        if (i > 0) cout << " ";
        cout << ans[i];
    }
    cout << "\n";

    return 0;
}



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

int sum[100005];

int main() {
    std::string s;
    std::cin >> s;
    int k = s.length();
    for (int i = 0; i < s.length(); ++i) {
        sum[i+1] = sum[i] + s[i] - '0';
    }
    while (k) {
        int start = s.length() - k;
        int end = k - 1;
        if (start <= end) {
            int tmp = sum[end + 1] - sum[start];
            if (tmp == 0 || tmp == end -start + 1) {
                printf("%d\n", k);
                return 0;
            }
        } else {
            printf("%d\n", k);
            return 0;
        }
        --k;
    }
}

Measured memory_bytes: 896
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x = int(input())
    if x == 2:
        print(x)
    else:
        while True:
            for i in range(2, x):
                if x % i == 0:
                    break
                if i == x-1:
                    print(x)
                    return
            x += 1

if __name__ == '__main__':
    main()

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

int main(){
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(i==A){
      if(S.at(i)!='-'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(!((S.at(i)>='0')&&(S.at(i)<='9'))){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  for (int i = 0; i < 3; i++) {
    if (S[i] == S[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS;
    int n;
    cin>>n;
    vector<int> v(n);
    map<int,int> mp;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        mp[i-v[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        mp[i-v[i]]--;
        ans+=mp[i+v[i]];
    }
    cout<<ans;
}

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

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};


int main() {
    ll N;
    cin >> N;
    SegmentTree<ll> seg(N+1,[](ll a,ll b){return (a+b);},0);

    for(int i=0;i<N-1;i++){
        int u,v;
        cin >> u >> v;
        --u;--v;
        if(u<v){
            seg.update(u,seg.query(u,u+1)+ N-v);
        }else{
            seg.update(v,seg.query(v,v+1)+N-u);
        }
    }
    
    ll ans  =0;
    for(int i=0;i<N;i++){
        ll remain = N-i;
        ll temp = remain*(remain+1)/2;
        temp -= seg.query(i,N);
        // cerr <<"temp=" <<temp  <<"query=" << seg.query(i,N)<< endl;
        ans += temp;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 7400
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll GCD(ll x, ll y) {
	ll tmp;
	if (y > x) {
		tmp = x;
		x = y;
		y = tmp;
	}
	while (x%y != 0) {
		tmp = y;
		y = x % y;
		x = tmp;
	}
	return y;
}

void solve() {

	ll A, B;
	cin >> A >> B;

	map<ll, ll> mp;

	ll num2 = GCD(A, B);
	for (ll i = 2; i<=sqrt(num2); i++) {
		if (num2%i == 0) {
			mp[i]++;
			num2 = num2 / i;
			i--;
		}
		if (num2 == 1) break;
	}
	if (num2 != 1) mp[num2]++;

	cout << mp.size() + 1;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;

    /**
     * 75 = 3 * 25
     * = 3 * 5 * 5
     * = 5 * 15
     * = 75
     * */
    std::map<i64, i64> p;
    i64 ret = 0;
    for (int i = 1; i <= n; i++) {
        int m = i;

        for (int j = 2; j * j <= m; j++) {
            while (m % j == 0) {
                m /= j;
                p[j]++;
            }
        }
        if (m > 1) p[m]++;
    }

    int three = 0, five = 0, fif = 0, sev = 0, twe = 0;
    for (auto& el : p) {
        // std::cout << el.first << " " << el.second << std::endl;
        if (el.second >= 2) three++;
        if (el.second >= 4) five++;
        if (el.second >= 14) fif++;
        if (el.second >= 74) sev++;
        if (el.second >= 24) twe++;
    }

    // 75
    ret += sev;
    // 3 * 25
    ret += (three - twe) * twe + twe * (twe - 1);
    // 5 * 15
    ret += (five - fif) * fif + fif * (fif - 1);
    // 3 * 5 * 5
    ret += (three - five) * five * (five - 1) / 2;
    ret += five * (five - 1) * (five - 2) / 2;

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
    val in = io.Source.stdin.getLines
    for (x <- in; r@Array(m, nmin, nmax) = x.split(" ").map(_.toInt) if r.forall(_ != 0)) {
        val ps = in.take(m).map(_.toInt)
        println(ps.zipWithIndex.foldLeft((0, 0, 0)){
            case ((gap, p0, res), (p1, i)) if (nmin-1 to nmax).contains(i) =>
                if (p0 - p1 >= gap) (p0-p1, p1, i) else (gap, p1, res)
            case (y, _) => y
        }._3)
    }
}

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

using namespace std;
const int N=2e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long X,K,D;
    cin>>X>>K>>D;
    X=abs(X);
    if(X/D>=K)
    {
        cout<<X-K*D<<endl;
        return 0;
    }
    K-=(X-(X%D))/D;
    X%=D;
    if(K%2==0) cout<<X<<endl;
    else cout<<abs(X-D)<<endl;
    return 0;
}


Measured memory_bytes: 3632
import heapq

# 標準入力受け取り
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]  #日数分(M)だけ[]を用意
# print(jobs)

for i in range(N):
    d, r = list(map(int, input().split()))   #d = A[i], r = B[i]
    if d - 1 < M:   #d-1番目の要素にrを追加して、同じ受け取り日数のバイトを同じ要素に入れる。d-1より、2日後のはjobs[1]におかれる。
        jobs[d - 1].append(-r)  # マイナスにしている
# print(jobs)

rewards = 0
heap = []

# 解法
for i in range(M):
    # 要素を一つづつヒープに追加
    for reward in jobs[i]:
        heapq.heappush(heap, reward)
    # print(heap)
    if len(heap) > 0:
        # 最大値(最小値)をヒープから取り出し
        reward = heapq.heappop(heap)
        rewards += -reward  # マイナスにしている
    # print(heap)

print(rewards)

Measured memory_bytes: 23752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
        int n, t, a;
        vector<int> vp;
        int mina = 1e9;
        int maxp = 0;
        cin >> n >> t >> a;
        mina = a;
        for (int i = 1; i < n; i++) {
                cin >> a;
                vp.push_back(a - mina);
                maxp = max(maxp, a - mina);
                mina = min(mina, a);
        }
        cout << count(vp.begin(), vp.end(), maxp) << endl;
        return 0;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

bool ok(int mul){
    stringstream ss;
    ss<<mul;
    string s = ss.str();
    rep(k,s.size()-1){
        if(s[k]+1!=s[k+1])return false;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    
    int ans = -1;
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            int mul = v[i]*v[j];
            if(ok(mul)){
                ans = max(ans,mul);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin>>n;
    vector<int> a;
    for(int i = 11; i <= 55555; i += 5){
        int j = 2;
        bool isprime = true;
        while(j*j <= i){
            if(i % j == 0){
                isprime = false; break;
            }
            j++;
        }
        if(isprime) a.push_back(i);
    }
    rep(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
l,r=[],[]
for _ in range(m):
    l0,r0=map(int, input().split())
    l.append(l0)
    r.append(r0)
keyl=max(l)
keyr=min(r)
if keyr-keyl>=0:
    print(keyr-keyl+1)
else: print(0)

Measured memory_bytes: 11108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if (s[n-1] == 's'){
    s.push_back('e');
    s.push_back('s');
  }
  else s.push_back('s');
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3596
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.Foldable (foldl')
import           Data.List     (transpose)

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = abc where
  [n, a, ab, abc] = foldl' f [1, 0, 0, 0] s
  f [n, a, ab, abc] 'A' = [n, add a n, ab, abc]
  f [n, a, ab, abc] 'B' = [n, a, add ab a, abc]
  f [n, a, ab, abc] 'C' = [n, a, ab, add abc ab]
  f [n, a, ab, abc] '?' = map (foldr add 0) . transpose $ map (f [n, a, ab, abc]) "ABC"

add :: Int -> Int -> Int
add x y = (x + y) `mod` modN

modN :: Int
modN = 10 ^ 9 + 7


Measured memory_bytes: 127356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// two integers
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int products =  a * b;
		if(products%2 == 0){
		System.out.println("Even");
		} else{
		System.out.println("Odd");	
		}
		

	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<cstdio>

std::string a;

int main(){
	std::cin>>a;
	for(int i=0;i<int(a.size());i++){
		if(a[i]=='C'){
			for(int j=i+1;j<int(a.size());j++){
				if(a[j]=='F'){
					puts("Yes");
					return 0;
				}
			}
			puts("No");
			return 0;
		}
	}
	puts("No");
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int id,k,pk,lk,rk,A[250],i;


  scanf("%d",&id);

  for(i=1;i<=id;i++) scanf("%d",&A[i]);


  for(i=1;i<=id;i++){

    printf("node %d: key = %d, ",i,A[i]);

    if(id == 1) printf("left key = %d, right key = %d",A[2*i],A[2*i+1]);
    
    if((i / 2) >= 1 ) printf("parent key = %d, ",A[i/2]);

    if(2*i <= id) printf("left key = %d, ",A[2*i]);

    if((2*i + 1) <= id ) printf("right key = %d, ",A[2*i + 1]);

    printf("\n");  
}





  return 0;
}

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

int gcd(int x, int y)
{
  return y ? gcd(y,x%y) : x;
}

int main()
{
  int k; cin >> k;
  ll ans = 0;
  for (int p=1; p<=k; p++)
    for (int q=1; q<=k; q++)
      for (int r=1; r<=k; r++)
        ans += gcd(gcd(p, q), r);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
    	int w = Integer.parseInt(sc.next());
      	int a = Integer.parseInt(sc.next());
      	int b = Integer.parseInt(sc.next());
      	
		if (a + w < b) {
        	System.out.println(b - (a + w));
        } else if (b + w < a) {
        	System.out.println(a - (b + w));
        } else {
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 22740
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{ //input->compute->output
        int N, K;
        cin >> N >> K;
        string S;
        cin >> S;
        vector<int> Nums;
        int now = 1;
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
                if (S[i] == (char)('0' + now))
                {
                        cnt++;
                }
                else
                {
                        Nums.push_back(cnt);
                        now = 1 - now;
                        cnt = 1;
                }
        }

        if (cnt != 0)
        {
                Nums.push_back(cnt);
        }

        if (Nums.size() % 2 == 0)
        {
                Nums.push_back(0);
        }

        int Add = 2 * K + 1;
        int ans = 0;

        // forループの外側に、left,rightを持つ
        int left = 0;
        int right = 0;
        int tmp = 0;

        for (int i = 0; i < Nums.size(); i += 2)
        {
                // 次のleft,rightを計算する
                int Nextleft = i;
                int Nextright = min(i + Add, (int)Nums.size());

                while (Nextleft > left)
                {
                        tmp -= Nums[left];
                        left++;
                }

                while (Nextright > right)
                {
                        tmp += Nums[right];
                        right++;
                }
                ans = max(ans, tmp);
        }

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


Measured memory_bytes: 1020
mod = 10 ** 9 + 7

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
bl = [True] * (N + 2)
for aa in a:
    bl[aa] = False

dp = [0] * (N + 2)
dp[0] = 1

for step_frm in range(N):
    if bl[step_frm]:
        dp[step_frm + 2] += dp[step_frm]
        dp[step_frm + 2] %= mod
        dp[step_frm + 1] += dp[step_frm]
        dp[step_frm + 1] %= mod
print(dp[N])


Measured memory_bytes: 51288
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 30
#define MAX_D 400

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int D;
int c[MAX_N];
int s[MAX_D][MAX_N];
int ma;
int ans[MAX_D];

int calc(){
    int las[26] = {};
    int res = 0;
    rep(i,D){
        res += s[i][ans[i]];
        las[ans[i]] = i+1;
        rep(j,26){
            res -= (i + 1 - las[j]) * c[j];
        }
    }
    return res;
}


int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> D;
        rep(i,26)cin >> c[i];
        rep(i,D)rep(j,26)cin >> s[i][j];
    }else{ // ファイル入力する
        ifs >> D;
        rep(i,26)ifs >> c[i];
        rep(i,D)rep(j,26)ifs >> s[i][j];
    }    
    
    int las[26] = {};
    rep(i,D){
        int max_s = -1;
        int arg = -1;
        rep(j,26){
            int tmp_score = s[i][j] + (i+1-las[j]) * c[j];
            if(tmp_score > max_s){
                max_s = tmp_score;
                arg = j;
            }
        }
        ans[i] = arg;
        las[arg] = i+1;
    }

    ma = calc();

    start = clock();
    int loop = 0;
    while(true){
        loop++;
        int x = rand()%D;
        int y = rand()%26;

        int keep = ans[x];
        ans[x] = y;

        int tmp = calc();

        if(tmp >= ma){
            if(tmp > ma){
                // cout << loop << ' ' << tmp << endl;
            }
            ma = tmp;
        }else{
            ans[x] = keep;
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.0)break;
    }

    while(true){
        loop++;
        int x = rand()%(D-10);
        int y = rand()%10+1;

        swap(ans[x], ans[x+y]);

        int tmp = calc();

        if(tmp >= ma){
            if(tmp > ma){
                // cout << loop << ' ' << tmp << endl;
            }
            ma = tmp;
        }else{
            swap(ans[x], ans[x+y]);
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.9)break;
    }

    /*
    int stooop;
    cin >> stooop;
    */

    rep(i,D){
        cout << ans[i] + 1 << endl;
    }

    string fileName = "out.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    rep(i,D){
        ofs << ans[i] + 1 << endl;
    }
    ofs.close();
    // cout << ma << endl;
    // cout << loop << endl;
    return 0;
}
 
 


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<long long>st;
    while(n--)
    {
        int num;
        cin>>num;
        if(st.find(num)!=st.end())st.erase(num);
        else
            st.insert(num);
    }
    cout<<st.size()<<endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n, k;cin>>n>>k;
  ll max_d=0;
  vector<ll>a(n);
  vector<ll>d(n);
  rep(i, n){
    cin>>a[i];
  }
  rep(i, n-1){
    d[i+1]=a[i+1]-a[i];
    max_d=max<ll>(max_d, d[i]);
  }
  d[0]=n-a[k-1]+a[0];
  max_d=max<ll>(max_d, d[0]);

//rep(i, k)cout<<d[i]<<' ';cout<<endl;

  cout<<n-max_d;
  
  return 0;
}

Measured memory_bytes: 15872