akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int n, m;

int main()
{
	cin >> n;

	m = n * 25 / 27;

	if (m * 27 / 25 == n)
		cout << m << endl;
	else if ((m + 1) * 27 / 25 == n)
		cout << m + 1 << endl;
	else
		cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int n;
    cin >> n;
    vector<int> counts(n);
    rep(i, n-1){
        int a;
        cin >> a;
        counts.at(a-1)++;
    }
    rep(i,n){
        pr(counts.at(i));
    }
    return 0;
}



Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  priority_queue<pair<int ,int>> q;
  for(int i = 0; i < n; i++){
    cin >> b[i];
    q.push({b[i], i});
  }

  int ans = 0;
  while(!q.empty()){
    auto p = q.top(); q.pop();
    int idx = p.second;
    int left = (idx - 1 + n) % n, right = (idx + 1) % n;
    int diff = (b[idx] - a[idx]) / (b[left] + b[right]);
    int val = b[idx] - (b[left] + b[right]) * diff;
    if(diff == 0 || val < a[idx]) continue;
    b[idx] = val;
    q.push({val, idx});
    ans += diff;
  }
  if(a != b) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9328
import bisect

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort()
    b.sort()
    c.sort()
    ans = 0
    for y in b:
        i = bisect.bisect_left(a, y)
        j = bisect.bisect_right(c, y)
        if i > 0 and j != len(c):
            ans += i * (n - j)

    print(ans)

main()


Measured memory_bytes: 22720
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> b(n), l(n), u(n);
  long long loss = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i] >> l[i] >> u[i];
    loss += b[i] * l[i];
  }
  vector<long long> value(n);
  for (int i = 0; i < n; i++) {
    value[i] = x * u[i] - b[i] * (u[i] - l[i]);
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(), [&](int i, int j) {
    return value[i] > value[j];
  });
  vector<long long> pref(n + 1);
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + value[order[i]];
  }
  long long ans = (long long) 9e18;
  for (int it = 0; it < n; it++) {
    int i = order[it];
    for (long long coeff : {l[i], u[i]}) {
      int low = 0, high = n;
      while (low <= high) {
        int mid = (low + high) >> 1;
        long long cur = loss;
        if (coeff == u[i]) {
          cur += b[i] * (u[i] - l[i]);
        }
        long long can_get = pref[mid];
        long long vals = mid;
        if (it < mid) {
          can_get -= value[i];
          vals -= 1;
        }
        can_get += x * coeff;
        if (can_get >= cur) {
          can_get -= x * coeff;
          long long need = 0;
          if (can_get < cur) {
            need = (cur - can_get + coeff - 1) / coeff;
          }
          ans = min(ans, vals * x + need);
        }
        if (low == high) {
          break;
        }
        if (can_get >= cur) {
          high = mid;
        } else {
          low = mid + 1;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string w;
    cin>>w;
    map<char,int>mp;
    int n=w.size();
    rep(i,n){
        mp[w[i]]++;
    }
    bool ok=true;
    for(auto&x:mp){
        if(x.second%2!=0)ok=false;
    }
    cout<<(ok==true?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                long n = Long.parseLong(sc.next());
                sc.close();
                String s = "";
                boolean ebishu = true;
                while(ebishu){
                        if(n <= 0) ebishu = false;
                        else{
                                int i =(int) (n % (long)26);
                                if(i == 0) i += 26;
                                char q = (char)(i + 96);
                                s = q + s;
                                n--;
                                n /= 26;
                        }
                }
                ou.print(s + "\n");
                ou.flush();
        }
}

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

class Dice {
public:
    int upside() {
        return faces[0];
    }
    int frontside() {
        return faces[1];
    }
    int rightside() {
        return faces[2];
    }
    int backside() {
        return faces[4];
    }
    int leftside() {
        return faces[3];
    }
    int downside() {
        return faces[5];
    }

    void E() {
        int tmp = faces[0];
        faces[0] = faces[3];
        faces[3] = faces[5];
        faces[5] = faces[2];
        faces[2] = tmp;
    }

    void N() {
        int tmp = faces[0];
        faces[0] = faces[1];
        faces[1] = faces[5];
        faces[5] = faces[4];
        faces[4] = tmp;
    }

    void S() {
        int tmp = faces[0];
        faces[0] = faces[4];
        faces[4] = faces[5];
        faces[5] = faces[1];
        faces[1] = tmp;
    }

    void W() {
        int tmp = faces[0];
        faces[0] = faces[2];
        faces[2] = faces[5];
        faces[5] = faces[3];
        faces[3] = tmp;
    }

    void rotate() {
        int tmp = faces[1];
        faces[1] = faces[2];
        faces[2] = faces[4];
        faces[4] = faces[3];
        faces[3] = tmp;
    }

private:
    int faces[6] = {0, 1, 2, 3, 4, 5};
};

int main() {
    int a[6];
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }

    int q; cin >> q;
    Dice dice;

    for (int i = 0; i < q; i++) {
        int up, front;
        cin >> up >> front;

        if (a[dice.frontside()] == up) {
            dice.N();
        } else if (a[dice.rightside()] == up) {
            dice.W();
        } else if (a[dice.backside()] == up) {
            dice.S();
        } else if (a[dice.leftside()] == up) {
            dice.E();
        } else if (a[dice.downside()] == up) {
            dice.N();
            dice.N();
        }

        for (int j = 0; j < 4; j++) {
            if (a[dice.frontside()] == front) {
                cout << a[dice.rightside()] << endl;
                break;
            }
            dice.rotate();
        }
    }

    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

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



	int x, y; cin >> x >> y;
	cout << (--x ) * (--y) << endl;
		return 0;
	
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> h(N);
	REP(i, N) cin >> h[i];

	sort(h.begin(), h.end());
	ll mi = 10101010101;
	REP(i, N-K+1){
		ll tmp = h[i+K-1] - h[i];
		if (tmp<mi) mi = tmp;
	}
	cout << mi << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    s = input()

    if len(s) % 2 != 0:
        print('No')
        exit()

    for i in range(len(s)//2):
        if s[i] != s[i+len(s)//2]:
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()

void solve();

main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

#define int ll
const int N = 1e5 + 5;
int ans, a[N], n;

void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	int last = 0;
	for (int i = 1; i <= n; ++i) {
		if (last == 1) {
			if (a[i] & 1) {
				ans += a[i] / 2;
				++ans;
				last = 0;
			} else {
				ans += a[i] / 2;
				if (a[i] == 0) last = 0;
			}
		} else {
			if (a[i] & 1) {
				ans += a[i] / 2;
				last = 1;
			} else {
				ans += a[i] / 2;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int nn[1001];
	int mm[1001];
	int n, m, x, y, z, max, max_num;
	
	scanf("%d %d", &n, &m);
	
	for (x = 0; x < n; x++) {
		mm[x] = 0;
		scanf("%d", &nn[x]);
	}
	for (x = 0; x < m; x++) {
		scanf("%d", &y);
		for (z = 0; z < n; z++) {
			if (nn[z] <= y) {
				mm[z]++;
				break;
			}
		}
	}
	
	max = mm[0];
	max_num = 1;
	for (x = 1; x < n; x++) {
		if (max < mm[x]) {
			max = mm[x];
			max_num = x + 1;
		}
	}
	
	printf("%d\n", max_num);
	
	return (0);
}

Measured memory_bytes: 604
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e,k,p;
  cin>>a>>b>>c>>d>>e>>k;
  p=e-a;
  if(p<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[1002][1002];
int d[1002],c[1002];

int main(){
  int n,m;
  cin>>n>>m;
  loop(i,n)cin>>d[i];
  loop(j,m)cin>>c[j];
  loop(i,n){
    loop(j,m){
      if(i==j){
        dp[i][j]=dp[i-1][j-1]+d[i]*c[j];
      }else{
        dp[i][j]=min(dp[i][j-1],dp[i-1][j-1]+d[i]*c[j]);
      }
    }
  }
  cout<<dp[n][m]<<endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


using W=int;
using E=pair<W,int>;
struct Node{
	E e; 
	W put;
	Node *l,*r;
	Node(const E e=E()):e(e),put(0),l(nullptr),r(nullptr){}
	Node* push(){
		e.first+=put;
		if(l)l->put+=put;
		if(r)r->put+=put;
		put=0;
		return this;
	}
};
Node* merge(Node *a,Node *b){
	if(!a)return b;
	if(!b)return a;
	a->push();b->push();
	if(a->e>b->e)swap(a,b);
	a->r=merge(a->r,b);
	swap(a->l,a->r);
	return a;
}
Node pool[2222222];
int tail;

struct EHeap{
	Node* root;
	EHeap():root(nullptr){}
	void pop(){
		root->push();
		root=merge(root->l,root->r);
	}
	void push(E e){
		pool[tail]=Node(e);
		Node *p=&pool[tail++];
		root=merge(root,p);
	}
	void add(W a){
		if(root)root->put+=a;
	}
	E top(){
		return root->push()->e;
	}
	void meld(EHeap &eh){
		root=merge(root,eh.root);
	}
};


struct MinimumWeightArborescence{
	int n;
	vector<vector<E>>G;
	MinimumWeightArborescence(int n):n(n),G(n){}

	void addEdge(int a,int b,W c){
		G[a].emplace_back(c,b);
	}

	W calc(int r){
		tail=0;
		vector<int>par(n);iota(par.begin(),par.end(),0);
		function<int(int)>find=[&](int x){return x==par[x]?x:par[x]=find(par[x]);};
		
		vector<int>st(n);
		vector<EHeap>eh(n);
		
		for(int v=0;v<n;v++)for(auto &e:G[v])eh[e.second].push(E(e.first,v));
		
		st[r]=2;
		W ans=0;
		for(int i=0;i<n;i++){
			if(st[i])continue;
			int v=i;
			vector<E>es;
			
			while(st[v]!=2){
				st[v]=1;
				int u;W c;
				tie(c,u)=eh[v].top();eh[v].pop();
				u=find(u);
				if(u==v)continue;
				ans+=c;
				if(st[u]!=1){
					es.push_back(E(c,v));
					v=u;
					continue;
				}

				eh[v].add(-c);
				while(v!=u){
					int w;
					tie(c,w)=es.back();es.pop_back();
					eh[w].add(-c);
					eh[w].meld(eh[v]);	
					par[v]=u;
					v=w;
				}
			}
			for(auto &e:es)st[e.second]=2;
		}
		return ans;
	}
};


signed main(){
	int N,M;
	scanf("%d%d",&N,&M);
	MinimumWeightArborescence mwa(N);
	vint in(N);
	rep(i,M){
		int a,b;
		scanf("%d%d",&a,&b);
		mwa.addEdge(a,b,0);
		mwa.addEdge(b,a,1);
		in[b]++;
	}
	
	vpint lis;
	rep(i,N){
		if(in[i])continue;
		int tmp=mwa.calc(i);
		lis.eb(tmp,i);
	}
	sort(all(lis));
	vint ans;
	rep(i,lis.size())if(lis[i].fi==lis[0].fi)ans.pb(lis[i].se);
	printf("%d %d\n",(int)ans.size(),lis[0].fi);
	rep(i,ans.size()){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}puts("");
	return 0;
}


Measured memory_bytes: 75280
#include<stdio.h>
 
int main(void){
  int n,i;
  int a[200000]={0};
  int j[200000]={0};
  
  do{
    scanf("%d",&n);
  }while(n<2 || n>200000);
  
  for(i=0; i<n-1; i++){
    do{
      scanf("%d",&a[i]);
    }while(a[i]<1 || a[i]>i+1);
  }
  
  for(i=0; i<n-1; i++){
    j[a[i]-1]++;
  }
  
  for(i=0; i<n; i++){
    printf("%d\n",j[i]);
  }
  
  return 0;
}

Measured memory_bytes: 3272
import java.util.*;
import java.util.regex.*;
import static java.lang.System.out;

// String
public class Main {
	public static void main(String[] args) {
		new Main().AOJ0064();
	}
	Scanner sc = new Scanner(System.in);
	
	void AOJ0064(){	// Secret Number
		int ans=0;
		while(sc.hasNext()){
			Matcher m = Pattern.compile("\\d+").matcher(sc.nextLine());
			while(m.find())	ans+=Integer.parseInt(m.group());
		}
		out.println(ans);
	}
	
	void AOJ0050(){	// Apple and Peach
		while(sc.hasNext()) out.println(sc.nextLine().replaceAll("apple", "PEACH").replaceAll("peach", "apple").replaceAll("PEACH", "peach"));
	}
	
	void AOJ0039(){	// Roman Figure ローマ数字 -> 10進数
		HashMap<Character,Integer> dic = new HashMap<Character,Integer>();
		dic.put('I', 1);	dic.put('V', 5);	dic.put('X', 10);	dic.put('L', 50);
		dic.put('C', 100);	dic.put('D', 500);	dic.put('M', 1000);
		while(sc.hasNext()){
			char[] c = sc.next().toCharArray();
			int ans=0,last=dic.get(c[0]);
			for(int i=0; i<c.length; i++){
				if(last>=dic.get(c[i])){
					ans+=dic.get(c[i]);
					last=dic.get(c[i]);
				}else{
					ans+=dic.get(c[i])-last-last;
					last=dic.get(c[i]);
				}
			}
			out.println(ans);
		}
	}
	
	void AOJ0020(){	// Capitalize 大文字変換
		while(sc.hasNext())	out.println(sc.nextLine().toUpperCase());
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int d =a[n - 1] - a[0];
		System.out.println(d);
	}
}

Measured memory_bytes: 22996
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;

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

typedef long long int ll;


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

	int arr[3],k;
	cin >> arr[0] >> arr[1] >> arr[2] >> k;

	sort(arr , arr+3);
	while(k--)
	{
		arr[2] = 2*arr[2];	
	}
	cout << arr[1]+arr[0]+arr[2];
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> t(n+1);
	vector<int> x(n+1);
	vector<int> y(n+1);
	for(int i = 1; i <= n; i++) cin >> t.at(i) >> x.at(i) >> y.at(i);

	bool can = true;
	for(int i = 0; i < n; i++){
		int dt = t.at(i+1) - t.at(i);
		int dist = abs(x.at(i+1)-x.at(i)) + abs(y.at(i+1)-y.at(i));
		if(dt < dist) can = false;
		if(dt%2 != dist%2) can = false; 
	}
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include<algorithm>
#include<set>

using namespace std;

int n, m, s, t;

int u[100005], v[100005];
long long int a[100005], b[100005];

vector<int> Adj[100005];

long long int dist_yen[100005], dist_snu[100005];
int check[100005];

set<pair<long long int, int > > S;

pair<long long int, int> P, Q;

long long int dist;

long long int ans[100005];

int main(void) {

	cin >> n >> m >> s >> t;

	int tmp1;
		long long int tmp2;

		for (int i = 1; i <= m; i++) {
			cin >> tmp1; u[i] = tmp1;
			cin >> tmp1; v[i] = tmp1;
			cin >> tmp2; a[i] = tmp2;
			cin >> tmp2; b[i] = tmp2;
		}

		for (int i = 1; i <= m; i++) {
			Adj[u[i]].push_back(i);
			Adj[v[i]].push_back(i);
		}


		//===========yen =======================//
		for (int i = 1; i <= n; i++) { check[i] = 0; }
		for (int i = 1; i <= n; i++) { dist_yen[i] = 9999999999999999; }
		P.first = 0; P.second = s; check[s] = 1; dist_yen[s] = 0;
		S.insert(P);

		while (S.size() > 0) {
			P = *(S.begin()); S.erase(P);
			long long int distance=P.first; 
			int K = P.second;

			for (int h = 0; h<int(Adj[K].size()); h++) {
				int i = Adj[K][h]; // edge ID
				int M = u[i]; if (M == K) { M = v[i]; }//

				if (check[M] == 0) {
					dist_yen[M] = distance + a[i];
					Q.first = dist_yen[M]; Q.second = M;
					S.insert(Q); check[M] = 1;
				}
				else if (S.count(pair<long long int,int >(dist_yen[M],M))) {
					Q.first = dist_yen[M]; Q.second = M;
					S.erase(Q);
					Q.first = min(Q.first, distance + a[i]); dist_yen[M] = Q.first;
					S.insert(Q);
				}
			}
		}//while-loop fin

		//===========================
/*		cout << "yen" << endl;
		for (int i = 1; i <= n; i++) {
			cout << i << " " << dist_yen[i] << endl;
		}
*/
		//====== snuke ===//
		for (int i = 1; i <= n; i++) { check[i] = 0; }
		for (int i = 1; i <= n; i++) { dist_snu[i] = 9999999999999999; }
		P.first = 0; P.second = t; check[t] = 1; dist_snu[t] = 0;
		S.insert(P);

		while (S.size() > 0) {
			P = *(S.begin()); S.erase(P);
			long long int distance = P.first;
			int K = P.second;

			for (int h = 0; h<int(Adj[K].size()); h++) {
				int i = Adj[K][h]; // edge ID
				int M = u[i]; if (M == K) { M = v[i]; }//

				if (check[M] == 0) {
					dist_snu[M] = distance + b[i];
					Q.first = dist_snu[M]; Q.second = M;
					S.insert(Q); check[M] = 1;
				}
				else if (S.count(pair<long long int, int >(dist_snu[M], M))) {
					Q.first = dist_snu[M]; Q.second = M;
					S.erase(Q);
					Q.first = min(Q.first, distance + b[i]);  dist_snu[M] = Q.first;
					S.insert(Q);
				}
			}
		}//while-loop fin

		//===============================
	/*	cout << "snu" << endl;
		for (int i = 1; i <= n; i++) {
			cout << i << " " << dist_snu[i] << endl;
		}
*/
		//===========================//

		ans[n - 1] = dist_yen[n] + dist_snu[n];
		for (int i = n - 2; i >= 0; i--) {
			ans[i] = min(ans[i + 1], dist_yen[i + 1] + dist_snu[i + 1]);
		}

		for (int i = 0; i <= n - 1; i++) {
			cout << 1000000000000000-ans[i] << endl;
		}

	//system("pause");
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
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; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int x;
	cin >> x;
	for (int i = x;; i++) {
		bool flag = true;
		if (i == 1) flag = false;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) flag = false;
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
/*
 * FileName:     set_difference
 * CreatedDate:  2020-06-09 16:18:09 +0900
 * LastModified: 2020-06-09 16:25:27 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define ultra 2e9
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc((n+1)*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",a+i);
    a[n]=ultra;
    int m;scanf("%d",&m);
    int *b = malloc((m+1)*sizeof(int));
    for(int i=0;i<m;i++)scanf("%d",b+i);
    b[m]=ultra;
    int ia=0,ib=0;
    while(ia<n||ib<m){
        if(a[ia]<b[ib]){
            printf("%d\n",a[ia]);
            ia++;
        }
        else if(a[ia]>b[ib]){
            printf("%d\n",b[ib]);
            ib++;
        }
        else{
            ia++;
            ib++;
        }
    }
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 3064
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n, a, b;
    while (cin >> n>>a>>b)
    {
        if (a == 0)
        {
            cout << "0\n"; continue;
        }
        ll ans = n / (a + b) * a;
        n = n - n / (a + b) * (a + b);
        if (n > a)ans += a;
        else ans += n;
        
        cout << ans << '\n';
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[3030][3030];

int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int n=s.size(),m=t.size();

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  }

  string ans="";
  int lim=m;
  for(int i=n;i>0;i--){
    if(dp[i][lim]==dp[i-1][lim]) continue;
    ans=s[i-1]+ans;
    for(int j=lim;j>0;j--){
      if(t[j-1]==s[i-1]){
        lim=j-1;
        break;
      }
    }
    /*for(int j=lim-1;j>0;j--){
      if(dp[i][j]==dp[i][lim]-1){
        ans=t[j+1]+ans;
        lim=j;
        break;
      }
    }*/
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 71936
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    f = list(map(lambda x : int(x) - 1, input().split()))

    # f(0) = 0 is necessary
    ans = 0 + (f[0] != 0)
    f[0] = -1

    # we regard f as 0 rooted tree except for an edge 0 -> 0
    E = [[] for _ in range(n)]
    indeg = [0] * n
    for i in range(1, n):
        E[f[i]].append(i)
        indeg[i] += 1

    # topological sort
    stack = [0]
    order = []
    while stack:
        v = stack.pop()
        order.append(v)
        for nv in E[v]:
            stack.append(nv)
    order.reverse()

    dp = [-1] * n
    for v in order:
        res = 0
        for nv in E[v]:
            res = max(res, (dp[nv] + 1) % k)
        dp[v] = res

    ans += dp.count(k - 1)
    if dp[0] == k - 1:
        ans -= 1
    for v in E[0]:
        if dp[v] == k - 1:
            ans -= 1
    print(ans)
resolve()

Measured memory_bytes: 70508
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 2e5;

string s;

int len;
int a[MAXN];
set<int> go[MAXN];
int lb[MAXN];
int rb[MAXN];
int ad[MAXN];
int n;

void no() {
	cout << "NO\n";
	exit(0);
}

void add(int l, int r) {
	if (l * 2 >= len - 1) {
		l = len - 1 - l;
		r = len - 1 - r;
		swap(l, r);
	}
	go[l].insert(r);
}

int main() {
	cin >> s;
	len = s.size();
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> lb[i] >> rb[i], --lb[i], --rb[i];
	int n2 = len / 2;
	for (int i = 0; i < n2; ++i) {
		a[i] = s[len - 1 - i] - s[i];
		if (a[i] < 0)
			a[i] += 26;
	}
	for (int i = 0; i < n; ++i) {
		int l = lb[i];
		int r = rb[i];
		if (l * 2 <= len - 1 && r * 2 >= len - 1) {
			if (len - 1 - l == r) {
				continue;
			}
			else if (len - 1 - l < r) {
				add(len - l, r);
			}
			else
				add(l, len - 1 - r - 1);
		}
		else {
			add(l, r);
		}
	}
	int cur = 0;
	for (int i = 0; i < n2; ++i) {
		int en = -1;
		if (go[i].size()) {
			en = *go[i].begin();
			go[i].erase(go[i].begin());
		}
		if (go[i].size()) {
			if (go[i].size() > go[en + 1].size())
				swap(go[i], go[en + 1]);
			for (int j: go[i])
				go[en + 1].insert(j);
		}
		cur += ad[i];
		cur %= 26;
		if (cur != a[i]) {
			int nd = a[i] - cur;
			if (nd < 0)
				nd += 26;
			if (en == -1)
				no();
			ad[i] = (ad[i] + nd) % 26;
			ad[en + 1] = (ad[en + 1] - nd + 26) % 26;
			cur = (cur + nd) % 26;
		}
	}
	cout << "YES\n";
	return 0;
}




Measured memory_bytes: 18688
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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 main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n)cin >> l[i];
  int ma = *max_element(all(l));
  if(ma < accumulate(all(l), 0) - ma)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
    if(a<b&&b<c){
         System.out.println("Yes");
    }else{
        System.out.println("No");
    }
   }
}    


Measured memory_bytes: 26148
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m, q;
E a[200000];
int pa[200000];
int root(int x) {
	if (x == pa[x]) return x;
	return pa[x] = root(pa[x]);
}
void unite(int x, int y) {
	x = root(x), y = root(y);
	pa[x] = y;
}
bool c[200000];
signed main() {
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++) {
		pa[i] = i;
	}
	for (int i = 0; i < q; i++) {
		cin >> a[i].from >> a[i].to >> a[i].cost;
		if (a[i].cost == 0) {
			if (root(a[i].from) != root(a[i].to)) {
				unite(a[i].from, a[i].to);
				m--;
			}
		}
	}
	int sum = 0, res = 0;
	for (int i = 0; i < n; i++) {
		if (pa[i] == i) res++;
	}
	for (int i = 0; i < q; i++) {
		if (a[i].cost == 1) {
			if (root(a[i].from) == root(a[i].to)) {
				cout << "No\n";
				return 0;
			}
			c[root(a[i].from)] = 1;
			c[root(a[i].to)] = 1;
		}
	}
	for (int i = 0; i < n; i++) if (c[i]) sum++;
	if (sum == 2) sum++;
	if (sum > res) {
		cout << "No\n";
		return 0;
	}
	int x = sum;
	int y = res * (res - 1) / 2;
	if (x <= m && m <= y) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 5504
import sys
readline = sys.stdin.readline


def main():
    n = readline().rstrip()
    k = int(n[-1])
    if k in{2, 4, 5, 7, 9}:
        print("hon")
        return
    if k in{0, 1, 6, 8}:
        print("pon")
        return
    print("bon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main() {
    int arr[3];
    for (int i = 0; i < 3; i++) {
        cin >> arr[i];
    }
    int ctr = 0, ctr1 = 0;
    for (int i = 0; i < 3; i++) {
        if (arr[i] == 5)
            ctr++;
        if (arr[i] == 7)
            ctr1++;
    }
    if (ctr == 2 && ctr1 == 1)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	h := readInt()
	w := readInt()
	c := make([][]int, 10)
	for i := range c {
		c[i] = make([]int, 10)
		for j := range c[i] {
			c[i][j] = readInt()
		}
	}
	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = minInt(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	var ans int64
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			a := readInt()
			if a == -1 {
				continue
			}
			ans += int64(c[a][1])
		}
	}
	println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT3]={0};
  int check[LIMIT3]={0};
  int dp[LIMIT3]={0};
  map<ll,ll> prime;
  string s;
  
  cin >> n;
  k=0;
  rep(i,n){
    cin >> a[i];
    dp[a[i]]++;
    k = max(k,a[i]);
  }
  int flag=0;
  for(i=2;i<=k;i++){
    ll sum=0;
    for(j=i;j<=k;j+=i){
      sum += dp[j];
    }
    if(sum>=2){
      flag=1;
      break;
    }
  }
  if(flag==0){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  ll tmp2=a[0];
  for(i=1;i<n;i++){
    tmp2 = gcd(tmp2,a[i]);
  }
  if(tmp2==1){
    cout << "setwise coprime" << endl;
  }else{
    cout << "not coprime" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] count = new int[101];
		while(sc.hasNext()) {
			int n = sc.nextInt();
			count[n]++;
		}
		int max = 0;
		for(int i=1;i<=100;i++) {
			max = Math.max(max,count[i]);
		}
		for(int i=1;i<=100;i++) {
			if (max == count[i]) {
				System.out.println(i);
			}
		}
	}

}

Measured memory_bytes: 18092
n,l=map(int,input().split())
array=[l+i-1 for i in range(1,n+1)]
f = sum(array)
closest = -10 ** 100
for i in range(n):
    tmp = [t for t in array]
    del tmp[i]
    if abs(f - sum(tmp)) < abs(f - closest):
        closest = sum(tmp)
print (closest)

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

int V, E;
std::vector<std::vector<int>> link_from;
std::vector<int> flag;

void search(int idx) {
    if (flag[idx] != 0) {
        return;
    }
    for (auto i : link_from[idx]) {
        search(i);
    }

    flag[idx] = 1;
    std::cout << idx << std::endl;
}


int main() {
    std::cin >> V >> E;

    link_from = std::vector<std::vector<int>>(V);
    flag = std::vector<int>(V, 0);
    for (int i = 0; i < E; i++) {
        int s, t;
        std::cin >> s >> t;
        link_from[t].emplace_back(s);
    }

    for (int i = 0; i < V; i++) {
        if (flag[i] == 0) {
            search(i);
        }
    }
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

double x[1000], y[1000];
double sol = 0, fn = 1;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> y[i];

    for (int i = 0; i < n; ++i)
    {
        
        for (int j = 0; j < n; ++j)
            if (i != j)
                sol += hypot(x[i] - x[j], y[i] - y[j]);
    }
    cout << setprecision(6) << fixed << sol / n;
}


Measured memory_bytes: 256
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]

hundred_num = N//100
ten_num = (N-hundred_num*100)//10
one_num = (N-hundred_num*100-ten_num*10)

if hundred_num==7 or ten_num==7 or one_num==7:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27116
#include<stdio.h> 
int main(void) 
{ 
int a,b,c,tmp;
scanf("%d %d %d\n",&a,&b,&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int n;
  cin >> n;
  vector <int64_t> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  int tmp = 0;
  rep(i, n-1) {
    if (v.at(i) == v.at(i+1)) {
      cout << "NO" << endl;
      tmp++;
      break;
    }
  }
  if (tmp == 0) {
    cout << "YES" << endl;
  }
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll X,Y;
    cin >> X >> Y;
    ll cnt = 0;
    if(X <= 3){
        cnt += 4-X;
    }
    if(Y <= 3){
        cnt += 4-Y;
    }
    if(X == 1 && Y == 1){
        cnt += 4;
    }
    cout << cnt * 100000 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  ll a[5]={};
  rep(i,n){
    string g;
    cin  >>g;
    if(g[0]=='M'){a[0]++;}
    if(g[0]=='A'){a[1]++;}
    if(g[0]=='R'){a[2]++;}
    if(g[0]=='C'){a[3]++;}
    if(g[0]=='H'){a[4]++;}
  }
  ll ans=0;
  rep(i,5){
    for(int r=i+1;r<5;r++){
      for(int t=r+1;t<5;t++){
        ans+=a[i]*a[r]*a[t];
      }
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3612
n = int(input())
a = 0
b = 0
for i in range(n):
    word = list(input().split())
    new_word = sorted(word)
    if word[0] == word[1]:
        a += 1
        b += 1
    elif new_word == word:
        b += 3
    else:
        a += 3
print('{} {}'.format(a, b))


Measured memory_bytes: 5600
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M, A[Mmax], B[Mmax];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++) cin >> A[i] >> B[i];

	vector<pair<int, int>> xs;
	for(int i=0; i<M; i++){
		xs.push_back({2*B[i], i});
		xs.push_back({2*A[i]+1, i});
	}
	sort(xs.begin(), xs.end());

	int ans = 0;
	set<int> current;
	for(int i=0; i<2*M; i++){
		if(xs[i].first%2){
			current.insert(xs[i].second);
		} else{
			auto it = current.find(xs[i].second);
			if(it == current.end()) continue;
			ans++;
			current.clear();
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4208
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
    }

    let mut ans = n+1;
    let max_range = (n as f64).sqrt().ceil() as usize;
    for i in 1..max_range+1{
        if n % i == 0 {
            let d = n / i;
            ans = std::cmp::min(ans, d+i);
        }
    }

    println!("{}", ans-2);

}

Measured memory_bytes: 4476
A, B, K = [int(i) for i in input().split()]

b1 = A - K

o1 = b1 if (b1 > 0) else 0

b2 = -b1

o2 = B - b2 if (b2 > 0) else B

o3 = o2 if (o2 > 0) else 0

o = str(o1) + " " + str(o3)

print(o)

Measured memory_bytes: 3068
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
const LL N=1005;
LL a[N],b[N];
LL n,m;
bool vis[N*N];
bool in[N*N];
int main()
{
	memset(in,false,sizeof(in));
	memset(vis,false,sizeof(vis));
	scanf("%lld%lld",&n,&m);
	for (LL u=1;u<=n;u++) 	{scanf("%lld",&a[u]);in[a[u]]=true;}
	for (LL u=1;u<=m;u++)	{scanf("%lld",&b[u]);vis[b[u]]=true;}
	LL ans=1;
	LL t1=0,t2=0;//有多少填过的行   有多少填过的列 
	LL now=0;//填了多少个数 
	for (LL u=n*m;u>=1;u--)//填每一个数 
	{
		if (in[u]==true&&vis[u]==true)	{t1++;t2++;}
		if (in[u]==true&&vis[u]==false)	{ans=ans*t2%MOD;t1++;}
		if (in[u]==false&&vis[u]==true)	{ans=ans*t1%MOD;t2++;}
		if (in[u]==false&&vis[u]==false) {ans=ans*(t1*t2-now)%MOD;}
		now++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
ll inf = 1000000000 + 7;



string inp;

int main() {
	int K, q;

	cin >> inp;
	cin >> K;

	q = inp.size();

	rep(i, inp.size()) {
		if(inp[i] != '1'){
			q = i;
			break;
		}

	}

	if (q+1 > K) {
		cout << '1' << endl;
	}
	else {
		cout << inp[q] << endl;

	}





	return 0;
}

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

template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;

struct MComb {
    std::vector<mint> fact;
    std::vector<mint> inversed;
    MComb(int n) { // O(n+log(mod))
        fact = std::vector<mint>(n+1,1);
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
        inversed = std::vector<mint>(n+1);
        inversed[n] = fact[n] ^ (MOD-2);
        for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
    }
    mint ncr(int n, int r) {
        return (fact[n] * inversed[r] * inversed[n-r]);
    }
    mint npr(int n, int r) {
        return (fact[n] * inversed[n-r]);
    }
    mint nhr(int n, int r) {
        assert(n+r-1 < (int)fact.size());
        return ncr(n+r-1, r);
    }
};

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	mint fact = 1;
	for (int i = 1; i <= n; i++) fact *= i;
	
	int next_div = 2;
	mint sum = 0;
	std::queue<mint> que;
	for (int i = n; i; i--) que.push(fact / i), sum += fact / i;
	
	mint res = 0;
	for (int i = 0; i < n; i++) {
		res += sum * a[i];
		sum -= que.front();
		que.pop();
		sum += fact / next_div++;
	}
	
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 1024
a = int(input())
b = list(map(int, input().split()))
d = 10 ** 9
e = min(b)
f = max(b)
for i in range(e, f + 1):
    g = 0
    for j in b:
        g += abs(j - i) ** 2
    d = min(d, g)
print(d)


Measured memory_bytes: 3060