akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define int long long
#define P pair<int,int>

struct UnionFind {
    vector<int> Parent;
    vector<int> Size;

    UnionFind(int N) : Parent(N), Size(N,1){
        for(int i = 0; i < N; i++) Parent[i] = i;
    }

    int root(int A) {
        if (Parent[A] == A) return A;
        return Parent[A] = root(Parent[A]);
    }

    bool merge(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return false;

        if (Size[A] < Size[B]) swap(A, B);

        Size[A] += Size[B];
        Parent[B] = A;
        return true;
    }

    bool issame(int A, int B) { //
        return root(A) == root(B);
    }

    int findsize(int A) {
        return Size[root(A)];
    }
};

struct edge {
    int u, v, cost;
    bool operator < ( const edge &e) const {
        return cost < e.cost;
    }
};



int n,V,E;
const int MAX_E = 1000010;

vector<edge> es;

int kruskal(){
    sort(es.begin(),es.end());
    UnionFind Tree(V);
    int res = 0;
    for(int i = 0; i < E; i++){
        edge e = es[i];
        if(!Tree.issame(e.u, e.v)){
            Tree.merge(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


signed main() {
    cin >> n;

    vector<pair<pair<int,int>,int>> a(n);
    for(int i = 0 ; i < n; i++){
        cin >> a[i].first.first >> a[i].first.second;
        a[i].second = i;
    }
    sort(a.begin(),a.end());
    for(int i = 1; i < n; i++){
        edge e = {};
        int u = a[i].second;
        int v = a[i-1].second;
        int cost = a[i].first.first - a[i-1].first.first;
        e = {u, v, cost};
        es.push_back(e);
    }

    for(int i = 0; i < n; i++){
        swap(a[i].first.first, a[i].first.second);
    }

    sort(a.begin(),a.end());
    for(int i = 1; i < n; i++){
        edge e = {};
        int u = a[i].second;
        int v = a[i-1].second;
        int cost = a[i].first.first - a[i-1].first.first;
        e = {u, v, cost};
        es.push_back(e);
    }

    V = n;
    E = es.size();
    cout << kruskal() << endl;
}



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

bool check_masu(char s[52][52], int h, int w) {
  return s[h - 1][w] == '#' || s[h + 1][w] == '#' || s[h][w - 1] == '#' || s[h][w + 1] == '#';
}

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  char s[52][52] = {};
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  }

  bool is_ok = true;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#' && ! check_masu(s, i, j)) {
        is_ok = false;
        break;
      }
    }
    if (! is_ok) {
      break;
    }
  }
  if (is_ok) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

int main() {
  answer1();
}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int next = 1;
  int cnt = 0;
  rep(i, n) {
    if (a[i] == next) {
      next++;
    } else {
      cnt++;
    }
  }
  
  int ans;
  if (cnt == n) {
    ans = -1;
  } else {
    ans = cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t K;
    std::string S;

    std::cin >> K >> S;

    if (S.size() <= K) {
        std::cout << S << std::endl;
        return 0;
    }

    S.erase(K);
    S += "...";

    std::cout << S << std::endl;

    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>

int main(){
    int r,c;
    scanf("%d %d",&r,&c);
    int a[r + 1][c + 1];
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            scanf("%d",&a[i][j]);
        }
    }
    int s;
    for(int i = 0; i < r; i++){
        s = 0;
        for(int j = 0; j < c; j++){
            printf("%d ",a[i][j]);
            s += a[i][j];
        }
        printf("%d\n",s);
    }
    int t;
    int sum = 0;
    for(int i = 0; i < c; i++){
        t = 0;
        for(int j = 0; j < r; j++){
            t += a[j][i];
        }
        printf("%d ",t);
        sum += t;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int arr[N];
//vector<int> prim;

void Erat(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
	/*
	for(int i = 2; i < N; i++){
		if(arr[i]){
			//cout << i << endl;
            //prim.push_back(i);
		}
	}*/
}

int main(){
	Erat();
	arr[0] = 0;
	arr[1] = 0;
while(1){
	
	int a, d, n;
	cin >> a >> d >> n;
	if(a == 0 and d == 0 and n == 0) break;
	int cnt = 0;
	int A;
	
	int i = 0;
	while(cnt != n){
		A = a + i * d;
		if(arr[A]) cnt++;
		i++;
	}
	cout << A << endl;
	
}//end	
	return 0;
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for(int i = 1; i <= N; i++){
    int n = i, sum = 0;
    while(1){
  		sum += n % 10;
    	n /= 10;
      if(!n) break;
    }    
    if(A <= sum && sum <= B) total += i;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }


struct El{string name; int P; int idx;};
vector<El> vec;
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    for(int i = 0; i < N; i++)
    {
        string n; int p; cin >> n >> p;
        vec.push_back(El{n, p, i});
    }
    
    sort(vec.begin(), vec.end(), [](El a, El b) { if(a.name == b.name) return a.P > b.P; return a.name < b.name;});
    
    for(auto v : vec)
    {
        cout << v.idx + 1 << endl;
    }
   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  long long int a, b, ans;
  char op;

  std::cin >> a >> op >> b;

  if (op == '+') {
    ans = a + b;
  } else {
    ans = a - b;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

int main() {

  int N;
  int L;
  std::string s;

  std::multiset<std::string> mst;
  std::cin >> N >> L;
  for (int i = 0; i < N; i++) {
    std::cin >> s;
    mst.insert(s);
  }

  std::string tmp;
  for (std::string str : mst) {
    tmp += str;
  }

  std::cout << tmp << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int N;
	cin>>N;
	std::cout<<std::fixed;
	std::setprecision(8);
	double ans=0;
	double A;
	for(int i=0;i<N;i++){
	    cin>>A;
	    ans+=(1.0/A);
	}
	ans=1.0/ans;
	cout<<ans;
	return 0;
}

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

int main(){

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

	ll n;cin>>n;

	string s="";
	while(n>0){
		int t=n%26;
		n=n/26;
		if(t==0){
			s='z'+s;
			n--;
		}
		else
			s=(char)('a'+t-1)+s;

	}
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;
void solve() {
    int N;cin>>N;
    string S,T,ans;
    cin>>S>>T;
    REP(i,N){
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }
    print(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	string ans;
	while(n!=0){
		n--;
		ans.push_back(char('a'+n%26));
		n/=26;
	}
	reverse(all(ans));
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

typedef long long ll;

ll N;
ll x[101];

int main(){
    cin >> N;
    ll v = 0,w = 0,a=0,b=0,d=0;
    for(int i=0;i<=N;i++) x[i] = i;
    for(int i=2;i<=N;i++){
        ll c = 0;
        for(int j=i;j<=N;j++){
            while(x[j] > 0 && x[j]%i == 0){
                c++;
                x[j] /= i;
            }
        }
        if(c == 2 || c == 3) v++;
        if(c > 3) w++;
        if(14 <= c) a++;
        if(24 <= c) b++;
        if(74 <= c) d++;
    }
    if(w < 2){
        cout << 0 << endl;
        return 0;
    }
    if(w == 2 && v == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ans += v * w * (w-1) / 2;
    ans += w * (w-1) * (w-2) / 2;
    ans += (w + v - 1) * b;
    ans += (w-1) * a;
    ans += d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef struct{
	char mark;
	int num;
}card;
card A[36],B[36],C[36];
void BubbleSort(int n,card B[36]);
void SelectionSort(int n,card B[36]);
int Stable(int n,card A[36],card B[36]);
int main(void){
	int i,n,m;
	char str[5000],*line,c;

	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&n);
	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%c%d",&c,&m);
	C[0].mark=c; C[0].num=m;
	A[0]=C[0]; B[0]=C[0];
	for(i=1;i<n;i++){
		line = strtok(NULL," ");
		sscanf(line,"%c%d",&c,&m);
		C[i].mark=c; C[i].num=m;
		A[i]=C[i]; B[i]=C[i];	
	}
	BubbleSort(n,C);
	for(i=0;i<n;i++){
		if(i) printf(" ");
		printf("%c%d",C[i].mark,C[i].num);
	}
	printf("\nStable\n");
	SelectionSort(n,A);
	for(i=0;i<n;i++){
		if(i) printf(" ");
		printf("%c%d",A[i].mark,A[i].num);
	}
	if(Stable(n,A,B)) printf("\nStable\n");
	else		  printf("\nNot stable\n");
	return 0;
}

void BubbleSort(int n,card B[36]){
	int i,j;
	card tmp;
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){	
			if(B[j].num < B[j-1].num){
				tmp = B[j-1];
				B[j-1] = B[j];
				B[j] = tmp;
			}
		}
	}	
}
void SelectionSort(int n,card B[36]){
	int z,i,j;
	card tmp,min;
	for(j=0;j<n-1;j++){
		min.num = B[j].num;
		z = j;	
		for(i=j+1;i<n;i++){	
			if(B[i].num < min.num){
				min.num = B[i].num;
				z = i;
			}
		}
		if(B[j].num != B[z].num){
			tmp = B[j];
			B[j] = B[z];
			B[z] = tmp;
		}
	}
}
int Stable(int n,card A[36],card B[36]){
	int i,j,a,b;
    for(i=0;i<n;i++){
    	for(j=i+1;j<n;j++){
    		for(a=0;a<n;a++){
				for(b=a+1;b<n;b++){
					if(B[i].num==B[j].num && B[i].mark==A[b].mark &&
						B[j].mark==A[a].mark && B[i].num==A[b].num && 
						 B[j].num==A[a].num)
						return 0;
				}
    		}
    	}
    }
	return 1;
}

Measured memory_bytes: 620
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
k = I()
# 0 ~ k-1の値を取る場合がある。
i = 0
value = 7%k
while i < k:
    if value == 0:
        print(i+1)
        exit()
    value = (10*value + 7)%k
    i += 1
print(-1)


Measured memory_bytes: 10424
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    static String[] keyBoard = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };

    static String toLetter(String str) {
        int num = Integer.parseInt(str.substring(0,1)) - 1;
        int times = str.length();
//        System.out.println("Number is: "+num+" times:"+times+" len:"+keyBoard[num].length());
        return String.valueOf(keyBoard[num].charAt((times-1)%keyBoard[num].length()));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine().trim());
        for (int i = 0; i < n; i++) {
            String sentence = "";
            ArrayList<String> command = new ArrayList<>();
            for (String str: sc.nextLine().split("0")) {
                command.add(str);
            }
            command.removeAll(Collections.singleton(""));
            for (String str: command) {
                sentence += toLetter(str);
            }


            System.out.println(sentence);
        }
    }
}

Measured memory_bytes: 32236
#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)
using namespace std;

int n,s;
int memo[11][1010];

void rec(int index,int sum,int mask){
	memo[index][sum]++;
	if(index==10) return;
	rep(i,10){
		if(mask&(1<<i)) continue;
		int nmask=mask|(1<<i);
		int nsum=sum+(index+1)*i;
		rec(index+1,nsum,nmask);
	}
}

int main(void){
	rec(0,0,0);
	while(cin >> n >> s){
		if(cin.eof())
			break;
		if(s<1010)
			cout << memo[n][s] << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}

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

int k(int x) {
  int s = 0;
  while (x != 0) {
    x /= 10;
    s++;
  }
  return s;
}

int main() {
  int64_t n;
  cin >> n;
  int s = 1001001001;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (k(n / i) < s) {
        s = k(n / i);
      }
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void) {
  int n, m, p, i, j, min;
  scanf("%d%d%d", &n, &m, &p);
  int d[m];
  for(i = 0; i < m; ++i) {
    scanf("%d", &d[i]);
    d[i] -= p;
    if(d[i] < 0) d[i] += n;
  }
  sort(d, d + m);
  min = n - d[0] > d[m - 1] ? d[m - 1] : n - d[0];
  for(i = 0; i < m; ++i) {
    if(d[i]) {
      if(i != m - 1 && min > 2 * d[i] + n - d[i + 1]) min = 2 * d[i] + n - d[i + 1];
      if(i && min > 2 * (n - d[i]) + d[i - 1]) min = 2 * (n - d[i]) + d[i - 1];
    }
  }
  printf("%d\n", min * 100);
  return 0;
}


Measured memory_bytes: 2732
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#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(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

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

// struct UnionFind {
//     vector<int> par;

//     UnionFind(int n) : par(n, -1) { }
//     void init(int n) { par.assign(n, -1); }

//     int root(int x) {
//         if (par[x] < 0) return x;
//         else return par[x] = root(par[x]);
//     }

//     bool is_same(int x, int y) {
//         return root(x) == root(y);
//     }

//     bool merge(int x, int y) {
//         x = root(x); y = root(y);
//         if (x == y) return false;
//         if (par[x] > par[y]) swap(x, y); // merge technique
//         par[x] += par[y];
//         par[y] = x;
//         return true;
//     }

//     int size(int x) {
//         return -par[root(x)];
//     }
// };
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool is_same(int x, int y) {
        return root(x) == root(y);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    LL n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    LL cur = n * (n - 1) / 2;
    vector<LL> res;
    rep(i, m) {
        res.push_back(cur);

        int x = a[m - 1 - i]; int y = b[m - 1 - i];
        if (uf.is_same(x, y)) continue;

        LL sa = uf.size(x); LL sb = uf.size(y);
        cur -= sa * sb;
        uf.merge(x, y);
    }
    reverse(res.begin(), res.end());
    for (auto x : res) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
template<class T> 
inline void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9'){if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T, class U>
inline void read(T& x, U& y){read(x), read(y);}
template<class T, class U, class V>
inline void read(T& x, U& y, V& z){read(x), read(y), read(z);}
struct Point
{
	double x, y;
	Point(int a, int b){x = a, y = b;}
	Point(double a = .0, double b = .0){x = a, y = b;}
	Point operator+(const Point& r){return Point(x + r.x, y + r.y);}
	Point operator-(const Point& r){return Point(x - r.x, y - r.y);}
	Point operator*(double r){return Point(x * r, y * r);}
	double operator*(const Point& r){return x * r.y - y * r.x;}
};
typedef Point Vector;
double dot(Vector l, Vector r){return l.x * r.x + l.y * r.y;}
double norm(Vector l){return dot(l, l);}
char* ccw(Point x, Point y, Point z)
{
	double cross = (y - x) * (z - x);
	if(cross > 0) return "COUNTER_CLOCKWISE";
	if(cross < 0) return "CLOCKWISE";
	if(dot(y - x, z - x) < 0) return "ONLINE_BACK";
	if(norm(y - x) < norm(z - x)) return "ONLINE_FRONT";
	return "ON_SEGMENT";
}
int main()
{
	int x0, y0, x1, y1, x, y; read(x0, y0), read(x1, y1);
	int q; read(q);
	while(q--)
	{
		read(x, y);
		puts(ccw(Point(x0, y0), Point(x1, y1), Point(x, y)));
	}
	return 0;
}

Measured memory_bytes: 2548
/*
 * Constraints
 * 1 ≤ n ≤ 100,000
 * 0 ≤ wi ≤ 1,000
 */

#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

struct {
  int to, wt, next;
} E[100010];
int LE[100010];

int main() {
  int n;
  cin >> n;
  fill(LE, LE + 100010, -1);
  int out[100010]{0}, OPT[100010]{0}, LD[100010]{0}, parent[100010]{0};
  for (int i = 0, s, t, wt; i < n - 1; ++i) {
    cin >> s >> t >> wt;
    int _s = min(s, t); // root the tree at 0
    int _t = max(s, t);
    E[i] = {_t, wt, LE[_s]};
    LE[_s] = i;
    parent[_t] = _s;
    ++out[_s];
  }
  queue<int> q;
  for (int i = 0; i < n; ++i)
    if (!out[i])
      q.push(i);

  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int sgcld = 0; // second-greatest child leaf distance
    for (int e = LE[u]; e != -1; e = E[e].next) {
      int ch = E[e].to;
      OPT[u] = max(OPT[u], OPT[ch]);
      if (LD[ch] + E[e].wt > LD[u]) {
        sgcld = LD[u];
        LD[u] = LD[ch] + E[e].wt;
      } else if (LD[ch] + E[e].wt > sgcld) {
        sgcld = LD[ch] + E[e].wt;
      }
    }
    OPT[u] = max(OPT[u], LD[u] + sgcld);
    if (u != 0 && !--out[parent[u]])
      q.push(parent[u]);
  }
  cout << OPT[0] << endl;
}


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

const int N = 200005;
std::vector<int> v[N];
int n, s, p[N], ind[N], val[N], x[N], y[N];

int mex(std::vector<int> &v) {
	std::sort(v.begin(), v.end()); int t = 0;
	for (; t < v.size() && v[t] == t; ++t);
	return t;
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> p[i], ++ind[p[i]];
	std::queue<int> q; for (int i = 1; i <= n; ++i) if (!ind[i]) q.push(i);
	while (q.size()) {
		int x = q.front(); q.pop(), val[x] = mex(v[x]);
		v[p[x]].emplace_back(val[x]);
		if (!--ind[p[x]]) q.push(p[x]); 
	}
	for (int i = 1; i <= n; ++i) if (ind[i])
		s = i, x[i] = mex(v[i]), v[i].emplace_back(x[i]), y[i] = mex(v[i]);
	int val = x[s];
	for (int t = p[s]; ; t = p[t]) {
		val = val == x[t] ? y[t] : x[t];
		if (t == s) break;
	}
	if (val == x[s]) return std::cout << "POSSIBLE\n", 0;
	val = y[s];
	for (int t = p[s]; ; t = p[t]) {
		val = val == x[t] ? y[t] : x[t];
		if (t == s) break;
	}
	if (val == y[s]) return std::cout << "POSSIBLE\n", 0;
	std::cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 14080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            List<int> lstM = new List<int>();
            for (int i = 0; i <= iM; i++) { lstM.Add(0); }
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                for (int j = 1; j < sS.Length; j++)
                {
                    lstM[int.Parse(sS[j])] += 1;
                }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = lstM.Count(value => value == iN);

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n,k;
ll f[11];
int main(){FAST;
cin>>n>>k;
for(ll i=0;i<k;i++){
	ll x;cin>>x;
	f[x]++;
}
vl tmp;
ll x = n;
while(x){
	tmp.pb(x%10);
	x/=10;
}
reverse(all(tmp));
ll m = tmp.size();
ll pos = -1;
for(ll i=0;i<m;i++){
	if(f[tmp[i]]){
		pos = i;
		break;
	}
}

ll magic = 0;
for(ll i=0;i<=9;i++){
	if(!f[i]){
		magic = i;
		break;
	}
}

ll carry = 0;
for(ll i=pos;i>=0;i--){
	ll ok = -1;
	for(ll j=tmp[i]+1;j<=9;j++){
		if(!f[j]){
			ok=j;
			break;
		}
	}
	if(ok!=-1){
		tmp[i]=ok;
		for(ll j=i+1;j<m;j++){
			tmp[j]=magic;
		}
		carry=0;
		break;
	}
	else{
		carry=1;
	}
}
if(carry){
	for(ll i=1;i<=9;i++){
		if(!f[i]){
			cout<<i;
			break;
		}
	}
	for(ll i=0;i<m;i++)cout<<magic;
}
else{
	for(auto it:tmp)cout<<it;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

	int r;
	cin >> r;

	if(r<1200){
		cout << "ABC" << endl;
	}
	else if(1200<=r && r<2800){
		cout << "ARC" << endl;
	}
	else{
		cout << "AGC" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
/* You lost the game. */

#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>
#include <numeric>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <vector>

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000009

#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(i,n) { scanf("%d", &t[i]); }
#define sal(t,n) fin(i,n) { scanf("%lld", &t[i]); }

#define pi(n) printf("%d\n", n)
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s);
#define pii(n,m) printf("%d %d\n", n, m)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define pai(t,n) fin(i,n) { printf("%d ", t[i]); } printf("\n"); 
#define pal(t,n) fin(i,n) { printf("%lld ", t[i]); } printf("\n"); 

#define L long long int
#define D double
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>

using namespace std;

int main() {
    int a,b;
    sii(a,b);
    if (a == 1) { a = 14; }
    if (b == 1) { b = 14; }
    if (a > b) { printf("Alice\n"); }
    else if (a < b) { printf("Bob\n"); }
    else { printf("Draw\n"); }
} 

Measured memory_bytes: 764
from itertools import product

#n進m桁のbit列の作成
def bit(n,m):
    bi = list((product([i for i in range(n)],repeat = m)))
    return bi

if __name__ == "__main__":
    N, M = map(int, input().split(" "))
    S = [list(map(int, input().split()))[1:] for i in range(M)]
    P = list(map(int, input().split()))

    ans = 0
    petterns = bit(2,N)
    for pettern in petterns:
        for m in range(M):
            cnt = 0
            for s in S[m]:
                # 探索中の君合わせpetternの内、電球mのスイッチsが含まれてたらカウント
                if pettern[s-1] == 1:
                    cnt += 1
            if cnt %2 != P[m]:
                break
        else:
            ans += 1
    print(ans)

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

public class Main {
    static void answer(long[] array){
        for(int n=0; n<array.length-1; n++){
            System.out.print(array[n]);
            System.out.print(" ");
        }
        System.out.println(array[array.length-1]);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] dam = new long[N];

        long totalRain = 0;
        for(int n=0; n<N; n++){
            dam[n] = sc.nextLong();
            totalRain += dam[n];
        }

        long[] ans = new long[N];
        long currentRain = 0;
        for(int i=1; i<N; i+=2) currentRain += dam[i]*2;
        ans[0] = totalRain-currentRain;
        for(int i=1; i<2*N; i+=2){
            currentRain -= dam[i%N]*2;
            currentRain += dam[(i-1)%N]*2;
            ans[(i+1)%N] = totalRain - currentRain;
        }
        answer(ans);
    }
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
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); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep (i, n) {
    cin >> s[i];
    sort(all(s[i]));
  }
  sort(all(s));

  string pre;
  ll cnt = 0;
  ll ans = 0;
  rep (i, n) {
    if (s[i] == pre) cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      pre = s[i];
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;

}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,K,cnt=0,i;
    cin>>A>>B>>K;
    for(i=B; i>0; i--){
        if(A %i ==0 && B%i == 0){
         cnt++;
        }
         if(cnt==K)
            break;
    }
    printf("%d\n",i);
    return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll A,B,T;
  cin>>A>>B>>T;
  cout<<T/A*B<<endl;
  
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
	long long n;
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9) cout<<"hon";
	else if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"pon";
	else if(n%10==3) cout<<"bon";
	return 0;
} 

Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    set<ll>A;
    for(ll i=0;i<n;i++){
        ll a;cin>>a;
        A.insert(a);
    }
    ll m;cin>>m;
    set<ll>B;
    for(ll i=0;i<m;i++){
        ll b;cin>>b;
        B.insert(b);
    }
    set<ll>c;
    set_intersection(all(A),all(B),inserter(c,c.begin()));
    for(auto it=c.begin();it!=c.end();it++){
        cout<<*it<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 23696
a,b,c,k=map(int,input().split())
ans=0
zan=k
if k<=a:
    ans+=1*k
else:
    ans+=1*a
    zan-=a
    if zan<=b:
        zan=zan
    else:
        zan-=b
        ans-=1*zan
print(ans)

Measured memory_bytes: 61580
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, z, w;
int a[2010];
int ans;
int main() {
	scanf("%d%d%d", &n, &z, &w);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
	if(n == 1)printf("%d\n", abs(a[1] - w));
	else printf("%d\n", max(abs(a[n] - w), abs(a[n] - a[n - 1])));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(){
  int N,X;
  cin >>N>>X;
  
  int mm = 1e5;
  int m;
  int sum = 0;
  
  rep(i,0,N){
    cin >> m;
    sum += m;
    mm = min(mm,m);
  }
  
  int ans = N + (X-sum)/mm;
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
const int maxn = 1e5 + 100; 
const int maxm = 1 << 15 + 10; 
const int inf = 0x3f3f3f3f; 

int n, ans, state; 
int v[maxn], cnt[20], f[maxm]; 

int dp(int s) {
    if (!s) return 0; 
    if (f[s] < inf) return f[s]; 
    for (int i = 0; i <= 15; ++i) {
        if (!(s & (1 << i))) continue; 
        for (int j = 0; j <= 15; ++j) {
            if (i == j || !(s & (1 << j))) continue; 
            int x = i ^ j; 
            int y = s ^ (1 << i) ^ (1 << j) ^ (1 << x); 
            if (s & (1 << x)) f[s] = min(f[s], dp(y) + 2); 
            else f[s] = min(f[s], dp(y) + 1); 
        }
    }
    return f[s]; 
}

int main() {
    scanf("%d", &n); 
    for (int i = 1; i < n; ++i) {
        int x, y, z; 
        scanf("%d%d%d", &x, &y, &z); 
        x += 1, y += 1; 
        v[x] ^= z; v[y] ^= z; 
    }
    for (int i = 1; i <= n; ++i) cnt[v[i]]++; 
    for (int i = 1; i <= 15; ++i) {
        ans += (cnt[i] >> 1); 
        state += (cnt[i] & 1) * (1 << i); 
    }
    memset(f, 0x3f, sizeof(f)); 
    printf("%d\n", ans + dp(state)); 
    return 0; 
}

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

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int input1 = sc.nextInt();
			int input2 = sc.nextInt();
			//gcd
			int gcd = gcd(input1, input2);
			//lcm
			int lcm = input1 / gcd * input2;
			System.out.println(gcd + " " + lcm);
		}
	}

	private int gcd(int a, int b){
		if(b == 0) return a;
		else return gcd(b, a % b);
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
  }

  map<int,int>M;
  vector<int>sum(n+1);
  sum[0]=0;
  for(int i=0;i<n;++i){
    sum[i+1]=(sum[i]+a[i])%m;
  }
  long long int ans=0;
  for(int i=0;i<n+1;++i){
    ans+=M[sum[i]];
    ++M[sum[i]];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3968
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t_list = [A, B, C, D, E]
min_t = min(t_list)
min_i = 0

t_1 = math.ceil(N/min_t)
t_1 = int((N+min_t-1) / min_t)
print(t_1+4)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, a[MAXN];
LL ans=1e18, f[MAXN][5];

LL cost(int x, int op)
{
    if(op==0 || op==4) return x;
    if(op==1 || op==3)
    {
        if(!x) return 2;
        else return x&1;
    }
    if(op==2)
    {
        if(!x) return 1;
        else return !(x&1);
    }
}

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i) scanf("%d", &a[i]);
    memset(f, 0x3f, sizeof(f));
    for(rint i=0; i<=4; ++i) f[0][i]=0;
    for(rint i=1; i<=n; ++i)
        for(rint j=0; j<=4; ++j)
        {
            if(j) f[i][j]=min(f[i][j], f[i][j-1]);
            f[i][j]=min(f[i][j], f[i-1][j]+cost(a[i], j));
        }
    for(rint i=0; i<=4; ++i) ans=min(ans, f[n][i]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  string S;
  cin >> N >> S;
  long ans = 0;
  long c = 0;
  for (long i = 0; i < N; i++) {
    if (S[i] == '.') {
      c++;
    }
  }
  ans = c;
 for (long i = 0; i < N; i++) {
    if (S[i] == '.') {
      c--;
      ans = min(ans,c);
    } else {
      c++;
      ans = min (ans,c);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 644
import java.io.*
import java.lang.RuntimeException

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, a, b) = nextIntList()
    var ans = 0
    for (i in 1..n){
        var sum = 0
        val str = i.toString()
        for (j in str.indices){
            sum += str[j].toChar() - '0'
        }
        if(sum in a..b) ans += i
    }

    println(ans)

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)

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

signed main() {
    int n, w[101], ans;
    cin >> n;
    
    w[0] = 0;
    ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        cin >> w[i];
        w[i] += w[i-1];
        ans += w[i];
    }
    
    for ( int i = 0; i < n; i++ ) {
        ans = min(ans, abs((w[n] - w[i+1]) - w[i+1]));
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3632
# Coding:UTF-8

n = int(input())
ryorijun=[int(i) for i in input().split(' ')]
manzoku1=[int(j) for j in input().split(' ')]
manzoku2=[int(k) for k in input().split(' ')]

goukei=0
preorder = 0
for i in ryorijun:
    goukei += manzoku1[i-1]
    if preorder > 0 and (i-1) == preorder:
        goukei += manzoku2[i-2]
    preorder = i
print(goukei)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n;
int a[maxn];
int id[maxn];

bool cmp(int x,int y){
  return a[x]<a[y];
}

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  for(int i=1;i<=n;i++) id[i]=i;
  sort(id+1,id+n+1,cmp);
  for(int i=1;i<=n;i++) cout<<id[i]<<" ";cout<<endl;
}


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

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l-1) / d << endl;
    return 0;
}

Measured memory_bytes: 3636
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    string s;
    cin>>s;
    if(s=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }
    else if(s=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }


















    return 0;

}













Measured memory_bytes: 256