akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 2010;
int n , u , v , k;
vector< int > g[N];
int cur;

int a =0 , b = 0;

void DFS(int node,int prnt,int d){
	if(d == cur){
		b++;
		return;
	}
	a++;
	for(int i = 0 ;i < (int)g[node].size();i++){
		if(g[node][i] == prnt) continue;
		DFS(g[node][i] , node , d + 1);
	}
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i = 0 ;i < n - 1;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	cur = k / 2 + 1;
	int sum = 0 , mx = 0;
	for(int i = 1;i <= n;i++){
		sum = mx = 0;
		for(int j = 0 ;j < (int)g[i].size();j++){
			a = b = 0;
			DFS(g[i][j] , i , 1);
			sum += a;
			mx = max(mx,b);
		}
		if(k & 1)
			ans = max(ans , sum + mx + 1);
		else
			ans = max(ans , sum + 1);
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int n,i,sum_J = 0;
    scanf("%d", &n);
    double x[n], sum_B = 0.0;
    char u[n][3];
  
    for(i = 0; i < n; i++){
      scanf("%lf %s", &x[i], u[i]);
    }
   
    for(i = 0; i < n; i++){
      if(u[i][0] == 'J'){
        sum_J += x[i];
      }
      if(u[i][0] == 'B'){ 
        sum_B += 380000.0 * x[i];
      }
    }
    printf("%f",sum_J + sum_B);
  
  return 0;
}

Measured memory_bytes: 128
N = gets.to_i
As = gets.split.map(&:to_i)

h = ->(a){a.each_with_object(Hash.new{|h, k| h[k] = 0}){|v, h| h[v] += 1}}
lh, rh = h[As.map.with_index{_2 + _1}], h[As.map.with_index{_2 - _1}]
puts lh.keys.inject(0){|s, k| s + lh[k]*rh[k]}

Measured memory_bytes: 60028
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		long A = sc.nextLong();
		long B = sc.nextLong();
		long gcd = GCD(Math.max(A, B), Math.min(A, B));
		
		int count = 0;
		for(long i = 2; i * i <= gcd; i++){
			if(gcd % i == 0){
				do{
					gcd /= i;
				}while(gcd % i == 0);
				count++;
			}
		}
		if(gcd != 1)count++;
		System.out.println(count + 1);
		
	}
	
	static private long GCD(long X, long Y) {
		while(Y != 0){
			long temp = X % Y;
			X = Y;
			Y = temp;
		}
		return X;
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

struct Wside{
	int vertex;
	int weight;
	Wside(int a, int b){
		vertex=a; weight=b;
	}
};

vector<Wside>* info;
vector<int> scanned;
int* result;
int n, mark;

bool isScanned(int v){
	for(int i=0,sz=scanned.size(); i<sz; ++i){
		if(v==scanned[i]) return 1;
	}
	return 0;
}

int scan(){
	int nextvtx = -1;
	for(int j=0, scn=scanned[scanned.size()-1], sz=info[scn].size(); j<sz; ++j){
		int vtx = info[scn][j].vertex;
		if(isScanned(vtx)) continue;
		int wgh = info[scn][j].weight;
		result[vtx] = result[vtx] > result[scn] + wgh ? (result[scn] + wgh) : result[vtx];
	}

	for(int i=0; i<n; ++i){
		if(!isScanned(i)){
			if(nextvtx == -1){
				nextvtx = i;
				continue;
			}
			nextvtx = result[nextvtx] < result[i]? nextvtx : i ;
		}
	}
	scanned.push_back(nextvtx);
	return 0;
}

int main()
{
	scanf("%d",&n);
	scanned.reserve(n);
	info = new vector<Wside> [n];
	result = new int [n];
	for(int i=0; i<n; ++i){
		result[i] = 0xfffffff;
	}

	int org,k,v,c;
	for(int i=0; i<n; ++i){
		scanf("%d %d",&org,&k);
		info[org].reserve(k);
		for(int j=0; j<k; ++j){
			scanf("%d %d",&v,&c);
			info[org].push_back(Wside(v,c));
		}
	}

	scanned.push_back(0);
	result[0] = 0;
	while(scanned.size()!=n){
		scan();
	}

	for(int i=0; i<n; ++i){
		cout << i << " " << result[i] << endl;
	}

	delete[] info;
	delete[] result;

	return 0;
}



Measured memory_bytes: 3200
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int r = sc.nextInt();
		int[] rlist = new int[r];
		for(int i = 0; i < r; i++){
		    rlist[i] = sc.nextInt() - 1;
		}
		int[][] dist = new int[n][n];
		for(int i = 0; i < m; i++){
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    int c = sc.nextInt();
		    dist[a][b] = c;
		    dist[b][a] = c;
		}
		
		// 計算
		int result = Integer.MAX_VALUE;
		wf(dist);
		Permutation perm = new Permutation(r);
		for(String s : perm.list){
		    int tmp = 0;
		    int from = rlist[s.charAt(0) - '0' - 1];
		    for(int i = 1; i < s.length(); i++){
		        int to = rlist[s.charAt(i) - '0' - 1];
		        tmp += dist[from][to];
		        from = to;
		    }
		    result = min(result, tmp);
		}
		
		// 出力
		System.out.println(result);
		
	}
	
	static void wf(int[][] dist) {
		int n = dist[0].length;
		int INF = 1001001001;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist[i][j] == 0) dist[i][j] = INF;
				if(i == j) dist[i][j] = 0;
			}
		}

		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
	}
}

class Permutation {
    int n;
    String s;
    ArrayList<String> list;
    long cnt = 0;
    
    public Permutation(String s){
        this.n = s.length();
        this.s = s;
        
        boolean[] used = new boolean[n];
        ArrayList<String> list = new ArrayList<String>();
        dfs("", used, list);
        this.list = list;
    }
    
    public Permutation(int n){
        this.n = n;
        StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
		    sb.append(i+1);
		}
        this.s = sb.toString();
        
        boolean[] used = new boolean[n];
        ArrayList<String> list = new ArrayList<String>();
        dfs("", used, list);
        this.list = list;
    }
    
    private void dfs(String s, boolean[] used, ArrayList<String> list){
        this.cnt++;
        if(s.length() == used.length){
            list.add(s);
            return;
        }
        for(int i = 0; i < used.length; i++){
            if(used[i]) continue;
            used[i] = true;
            dfs(s + this.s.charAt(i), used, list);
            used[i] = false;
        }
    }
}


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

#define read(x) scanf("%d",&x)
#define ll long long

int n;

int main() {
	read(n);
	ll ans=0;
	ans=((ll)(n-1)*(ll)(n)/2);
	printf("%lld",ans);
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>DP(200000,int(1e9+7));
  DP[0]=0;
  vector<int>A{1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
  for(int i=0;i<N;i++)
    for(int j=0;j<12;j++)
      DP[i+A[j]]=min(DP[i+A[j]],DP[i]+1);
  cout<<DP[N]<<endl;
}

Measured memory_bytes: 3984
#include <iostream>
using namespace std;
int main()
{
	int n;
	int l;
	
	int sum=0;
	cin >> n >> l;
	int a=l;
	if (n + l - 1 < 0)
	{
		for (int i = 1; i <= n - 1; i++)
			sum = sum + l + i - 1;
	}
	else if (l > 0)
	{
		for (int i = 2; i <= n ; i++)
			sum = sum + l + i - 1;
	}
	else
	{
		for (int i = 1; i <= n; i++)
			sum = sum + l + i - 1;
		for (int i = 1; i <= n; i++)
		{
			if (abs(l + i - 1) <abs( a))
				a = abs(l + i - 1);
		}
		sum = sum - a;
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  if(N == 2) {
    if(S[0] == S[1]) cout << 1 << ' ' << 2 << endl;
    else cout << -1 << ' ' << -1 << endl;
    return 0;
  }
  rep(i, N-2) {
    if(S[i] == S[i+1] || S[i] == S[i+2] || S[i+1] == S[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << endl;
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int INF=1000000007;

int main() {
 int n; cin >> n;
 vector<int> a(n),cnt(n,0);
 for(int i=0;i<n;i++){
   cin >> a[i];
 }

 for(int i=0;i<n;i++){
   cnt[a[i]]++;
 }
 bool ok=true;
 if(n%2==1){
     if(cnt[0]!=1)ok=false;
 for(int i=1;i<n;i++){
    if(i%2==1){
      if(cnt[i]!=0)ok=false;
    }
    else if(i%2==0){
      if(cnt[i]!=2)ok=false;
    }
  }
  if(ok){
    long long ans=1;
    for(int i=1;i<=(n-1)/2;i++){
      ans*=2;
      ans=ans%INF;
    }
    cout << ans << endl;
  }
  else{
    cout << '0' << endl;
  }
}

  else if(n%2==0){
    for(int i=0;i<n;i++){
      if(i%2==0){
        if(cnt[i]!=0)ok=false;
      }
      if(i%2==1){
        if(cnt[i]!=2)ok=false;
      }
    }
    if(ok){
      long long stl=1;
      for(int i=1;i<=n/2;i++){
        stl*=2;
        stl=stl%INF;
      }
      cout << stl << endl;
    }
    else{
      cout << '0' << endl;
    }
  }
 }


Measured memory_bytes: 1024
from math import ceil
t = 0
a = [int(input()) for _ in range(5)]
m = min(map(lambda x: (x - 1) % 10 + 1, a))
for c in a:
    if (c - 1) % 10 + 1 == m:
        m = c
a.remove(m)
t += sum(map(lambda x: ceil(x / 10), a))
t *= 10
print(t + m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i; map<string, int> M; cin >> N; string S[N]; 
for(i=0; i<N; i++){ cin >> S[i]; M[S[i]]--; }
vector< pair<int, string> > V;
for(i=0; i<N; i++){ V.push_back(make_pair(M[S[i]], S[i])); }
sort(V.begin(), V.end());
cout << V[0].second << "\n";
for(i=1; i<N; i++){
  if(V[i].first==V[0].first&&V[i].second!=V[i-1].second){ cout << V[i].second << "\n"; }
}
}

Measured memory_bytes: 30836
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n==0) break;
			int m=sc.nextInt()-1, c=sc.nextInt()-1, d=sc.nextInt();
			int g[] = new int[n];
			for(int i=0;i<n;i++) g[i] = i;
			HashSet<P> s = new HashSet<P>();
			for(int i=0;i<d;i++) {
				int l = Integer.valueOf((new StringBuilder(sc.next()).reverse().toString()), 2) << 1;
				for(int j=1;j<=n-1;j++) {
					if(((l>>j)&1) == 1) {
						swap(g, j,  j-1);
					}
					else if( ((l>>(j-1))&1) == 0 && ((l>>(j+1))&1) == 0 ){
						s.add(new P(g[j], g[j-1], i, j));
//						debug(g[j], g[j-1], i, j);
					}
//					debug(g);
				}
			}
//			for(P p: s) debug(p.v1, p.v2, p.x, p.y);
//			debug(g);
			if( g[c] == m ) System.out.println(0);
			else {
				int t = g[c];
				if( t < m ) {
					int tmp = t; 
					t = m;
					m = tmp;
				}
				boolean f = false;
				for(P p: s) {
					if( p.v1 == m && p.v2 == t ) {
						System.out.println((p.x+1) + " " + p.y);
						f = true;
					}
				}
				if(!f) System.out.println(1);
			}
		}
	}
	
	void swap(int[] s, int a, int b) {
		int tmp = s[a];
		s[a] = s[b];
		s[b] = tmp;
	}
	
	class P {
		int v1, v2;
		int x, y;
		P(int v1, int v2, int x, int y) {
			this.v1 = min(v1, v2); this.v2 = max(v1, v2);
			this.x = x; this.y = y;
		}
		
		public boolean equals(Object o) {
			if( o instanceof P) {
				return v1 == ((P)o).v1 && v2 == ((P)o).v2;
			}
			return false;
		}
		
		public int hashCode() {
			return v1*100 + v2;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 20776
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll gcd(ll a, ll b) {
	if (a == 0)return b;
	if (b == 0)return a;
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	if (a == 0 || b == 0) return 0;
	ll g = gcd(a, b);
	return (a / g) * b;
}

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

	ll N, M;
	cin >> N >> M;
	vector<ll>a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i] /= 2LL;
	}

	ll l = a[0];
	for (int i = 1; i < N; i++) {
		l = lcm(l,a[i]);
		if (l > M) {
			puts(0);
			return 0;
		}
	}

	for (int i = 0; i < N; i++) {
		ll sho = l/a[i];
		if (sho % 2 == 0) {
			puts(0);
			return 0;
		}
	}

	puts((M+l)/(2LL*l));


	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int m, f, r;
    
    while(scanf("%d %d %d", &m, &f, &r), m > -1 || f > -1 || r > -1){
        if(m < 0 || f < 0){
            putchar('F');
        }
        
        else if(m + f >= 80){
            putchar('A');
        }
        
        else if(m + f >= 65){
            putchar('B');
        }
        
        else if(m + f >= 50){
            putchar('C');
        }
        
        else if(m + f >= 30){
            
            if(r >= 50){
                putchar('C');
            }
            
            else {
                putchar('D');
            }
        }
        
        else {
            putchar('F');
        }
        
        putchar('\n');
    }
    
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b, c, d, e, f, s, r;
	REP(i, 3) {
		s = e = 0;
		in >> a >> b >> c >> d >> e >> f;
		s = a * 3600 + b * 60 + c;
		r = d * 3600 + e * 60 + f;
		r -= s;
		out << r / 3600 <<" ";
		r %= 3600;
		out << r / 60 << " ";
		r %= 60;
		out << r << endl;

	}
	return 0;

}

Measured memory_bytes: 3056
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
long long n;
int we=0,i,wei=10,now=0;
int che[10];
cin>>n;
che[0]=n%10;
now+=che[0];
for(i=1;i<10;i++)
{
che[i]=((n-now)%(wei*10))/wei;
now+=che[i]*wei;
wei*=10;
}
for(i=0;i<10;i++)
{we+=che[i];}
if(n%we==0)
{cout<<"Yes";}
else
{cout<<"No";}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> vec(pow(10, 5), 0);
  int left = 0;
  int right = pow(10, 5)+1;
  REP(i, M) {
    int j, k;
    cin >> j >> k;
    left = max(left, j);
    right = min(right, k);
  }
  if (left > right) {
    cout << 0 << endl;
  } else {
    cout << right - left + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define length size()
#define endl "\n"
signed main(void){
 float a,b,c;
  cin >> a >> b >> c;
  cout << (int)(c*(ceil(a/b)))+0 << endl;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
/*
ID: arun.ga1
LANG: C++
TASK: 
 */

using namespace std;

#define prime 1000000007
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }

/////////////////////////////////////////////////////////////////////

void quick_sort (int *a, int n,int *b) 
{
	int i,j,p,t;
	if(n<2)
	{
		return;
	}
	p=a[n/2];
	for(i=0,j=n-1;;i++,j--)
	{
		while(a[i]<p)
		{
			i++;
		}
		while(p<a[j])
		{
			j--;
		}
		if(i>=j)
		{
			break;
		}
		t=a[i];
		a[i]=a[j];
		a[j]=t;

		t=b[i];
		b[i]=b[j];
		b[j]=t;
	}
	quick_sort(a,i,b);
	quick_sort(a+i,n-i,b+i);
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b,i;
	cin >> a >> b;
	string q;
	REP(i,a)
	{
		cin >> q;
		cout << q << "\n" << q << "\n";
	}
	return 0;
}


Measured memory_bytes: 384
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    W, a, b = map(int, readline().split())

    if a <= b <= a + W or a <= b + W <= a + W:
        ans = 0
    else:
        ans = min(abs(a - b), abs(a + W - b), abs(a - b - W), abs(a + W - b - W))

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

string join(const vector<string>& v, const char* delim = 0) {
	string s;
	if (!v.empty()) {
		s += v[0];
		for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
			if (delim) s += delim;
			s += v[i];
		}
	}
	return s;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

template<typename T>
void print_vec(ostream& ostream, vector<T> a) {
	rep(i, a.size() - 1) ostream << a[i] << " ";
	ostream << a.back() << endl;
}

template<class T>
T pow_n(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

struct Point {
	int y, x;
};

class Solver {
public:
	int H, W;

	bool grid_ok(int y, int x) {
		return 0 <= y && y < H && 0 <= x && x < W;
	}
	
	int A, B, X;

	void solve() {
		cin >> A >> B >> X;
		bool f = (A <= X and X <= A + B);
		cout << (f ? "YES" : "NO") << endl;
	}

};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}


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

using namespace std;

int n, A, a[55];
long long dp[55][2 * 55 * 55];

long long calc(int i, int d){
	if(i == n) return (d == 0);
	if(dp[i][d + 55 * 55] != -1) return dp[i][d + 55 * 55];
	long long v1 = calc(i + 1, d);
	long long v2 = calc(i + 1, d + a[i] - A);
	long long res = v1 + v2;
	return dp[i][d + 55 * 55] = res;
}

void init(){
	scanf("%d%d",&n,&A);
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	memset(dp,-1,sizeof(dp));
	long long res = calc(0, 0) - 1;
	printf("%lld\n",res);
}

int main(){
	
	init();
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
using namespace std;
#define MAX 3001
#define MOD 998244353
#define INF 2000000000
long long dp[MAX][MAX][4];
int V[MAX][MAX];
int n,m,k;
long long MaxVal(int r,int c,int con)
{
    if(dp[r][c][con]!=-1)
    {
        //printf("dp->dp[%d][%d][%d]=%lld\n",r,c,con,dp[r][c][con]);
        return dp[r][c][con];
    }
    if(r==n-1&&c==m-1)
    {
        if(con==0||V[r][c]==0) dp[r][c][con]=0;
        else dp[r][c][con]=V[r][c];
        //printf("def->dp[%d][%d][%d]=%lld\n",r,c,con,dp[r][c][con]);
        return dp[r][c][con];
    }
    dp[r][c][con]=0;
    if(r+1<n)
    {
        dp[r][c][con]=max(dp[r][c][con],MaxVal(r+1,c,3));
        if(V[r][c]>0&&con>0) dp[r][c][con]=max(dp[r][c][con],V[r][c]+MaxVal(r+1,c,3));
    }
    if(c+1<m)
    {
        dp[r][c][con]=max(dp[r][c][con],MaxVal(r,c+1,con));
        if(V[r][c]>0&&con>0) dp[r][c][con]=max(dp[r][c][con],V[r][c]+MaxVal(r,c+1,con-1));
    }
    //printf("rec->dp[%d][%d][%d]=%lld\n",r,c,con,dp[r][c][con]);
    return dp[r][c][con];
}
int main()
{
    scanf("%d %d %d",&n,&m,&k);
    int i,j,l,v;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            for(l=0;l<4;l++)
            {
                dp[i][j][l]=-1;
            }
        }
    }
    for(l=0;l<k;l++)
    {
        scanf("%d %d %d",&i,&j,&v);
        i--;
        j--;
        V[i][j]=v;
    }
    long long ans=MaxVal(0,0,3);
    printf("%lld",ans);
    return 0;
}


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

template <typename T>
string join_vector(std::vector<T> data)
{
  ostringstream buf;
  auto delimiter = " ";
  for (auto i = data.begin(); i != data.end(); i++)
  {
    buf << *i;
    if (std::distance(i, data.end()) > 1)
    {
      buf << delimiter;
    }
  }

  return buf.str();
}

template <typename T>
void print_vector(std::vector<T> data)
{
  cout << join_vector(data) << endl;
}

int card_num(string a)
{
  return stoi(a.substr(1, a.size()));
}

vector<string> bubble_sort(vector<string> vec, int n)
{
  auto a = vector<string>(vec);
  for (auto i = n - 1; i >= 0; i--)
  {
    for (auto j = n - 1; j >= 0; j--)
    {
      if (j - 1 >= 0)
      {
        auto should_swap = card_num(a[j - 1]) > card_num(a[j]);
        if (should_swap)
          swap(a[j - 1], a[j]);
      }
    }
  }

  return a;
}

vector<string> selection_sort(vector<string> vec, int n)
{
  auto a = vector<string>(vec);
  for (auto i = 0; i < n; i++)
  {
    auto minj = i;
    for (auto j = i; j < n; j++)
    {
      if (card_num(a[minj]) > card_num(a[j]))
      {
        minj = j;
      }
    }

    swap(a[minj], a[i]);
  }

  return a;
}

bool is_stable(vector<string> original, vector<string> a)
{
  return true;
}

void print_stability(bool flag)
{
  if (flag)
  {
    cout << "Stable" << endl;
  }
  else
  {
    cout << "Not stable" << endl;
  }
}

template <typename T>
bool is_same_vector(vector<T> a, vector<T> b)
{
  if (a.size() != b.size())
  {
    return false;
  }

  for (auto i = 0; i < a.size(); i++)
  {
    if (a[i] != b[i])
    {
      return false;
    }
  }

  return true;
}

int main()
{
  int n;
  auto a = std::vector<string>{};

  cin >> n;
  for (auto i = 0; i < n; i++)
  {
    string card;
    cin >> card;
    a.push_back(card);
  }

  auto bubble = bubble_sort(a, n);
  print_vector(bubble);
  print_stability(true);

  auto selection = selection_sort(a, n);
  print_vector(selection);
  if (is_same_vector(bubble, selection))
  {
    print_stability(true);
  }
  else
  {
    print_stability(false);
  }

  return 0;
}



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

int par[100010], dep[100010], siz[100010];

void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    dep[i] = 0;
    siz[i] = 1;
  }
  return;
}

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

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

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y)
    return;
  
  if(dep[x] > dep[y]){
    par[y] = x;
    siz[x] += siz[y];
  }
  else{
    par[x] = y;
    siz[y] += siz[x];
    if(dep[x] == dep[y])
      dep[y]++;
  }
  
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  
  init(n);
  
  vector<vector<int>> fri(n, vector<int>(0));
  
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    unite(a, b);
    fri[a].push_back(b);
    fri[b].push_back(a);
  }
  
  vector<vector<int>> block(n, vector<int>(0));
  
  for(int i = 0; i < k; i++){
    int c, d;
    cin >> c >> d;
    c--; d--;
    block[c].push_back(d);
    block[d].push_back(c);
  }
  
  for(int i = 0; i < n; i++){
    int cnt = 0;
    for(int j = 0; j < block[i].size(); j++){
      if(root(block[i][j]) == root(i))
        cnt++;
    }
    for(int j = 0; j < fri[i].size(); j++){
      if(root(fri[i][j]) == root(i))
        cnt++;
    }
    
    cout << siz[root(i)] - cnt -1 << " ";
    
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 19192
N, M = gets.chomp.split(" ").map(&:to_i)
A = []
B = []
M.times do |i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  A << a-1
  B << b-1
end

class UnionFind
  def initialize(n)
    @parent = Array.new(n, -1)
  end

  def root(x)
    children = []
    r = x
    while @parent[r] >= 0
      children << r
      r = @parent[r]
    end
    children.each {|a| @parent[a] = r }
    r
  end

  def size(x)
    -@parent[root(x)]
  end

  def size_list
    @parent.select {|v| v < 0 }.map {|v| -v }
  end

  def same?(x, y)
    root(x) == root(y)
  end

  def unite(x, y)
    lhs = root(x)
    rhs = root(y)
    return if lhs == rhs
    ls = -@parent[lhs]
    rs = -@parent[rhs]
    if ls < rs
      @parent[rhs] -= ls
      @parent[lhs] = rhs
    else
      @parent[lhs] -= rs
      @parent[rhs] = lhs
    end
  end
end

ans = Array.new(M)
ans[M-1] = N * (N-1) / 2

uf = UnionFind.new(N)
(M-1).downto(1) do |i|
  if uf.same?(A[i], B[i])
    ans[i-1] = ans[i]
  else
    new_route = uf.size(A[i]) * uf.size(B[i])
    ans[i-1] = ans[i] - new_route
  end
  uf.unite(A[i], B[i])
end
ans.each do |a|
  puts a
end


Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c31 = 0, c30 = 0, c28 = 0;
    cin >> a >> b ;
    
    if(a == 2){
        c28++;
    } else if(a == 4 || a == 6 || a == 9 || a == 11){
        c30++;
    } else {
        c31++;
    }
    
    if(b == 2){
        c28++;
    } else if(b == 4 || b == 6 || b == 9 || b == 11){
        c30++;
    } else {
        c31++;
    }
    
    //*
    if(2 == c28 || 2 == c30 || c31 == 2 ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << a.at(0) - 'a' + 'A' << b.at(0) - 'a' + 'A' << c.at(0) - 'a' + 'A' << endl;

    return 0; 
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

#define ran 101101

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

char s[ran];
int pw[ran];

int main() {
	scanf("%s", s);
	int len = strlen(s);
	
	int dig_cnt = 0;
	for(int i=0;i<len;i++)
		if(s[i]=='1') dig_cnt++;
	pw[0] = 1;
	for(int i=1;i<=dig_cnt;i++)
		pw[i] = ma.mul(pw[i-1], 2);
	int ans = pw[dig_cnt];
	
	int mul = 1;
	for(int i=len-1;i>=0;i--, mul = ma.mul(mul, 3)) {
		if (s[i]=='0') continue;
		
		dig_cnt --;
		ans = ma.add(ans, ma.mul(pw[dig_cnt], mul));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;
int main()
{
    ios;

  ll a,b,c,d,mx2,mx1,mx3,mx4;
  cin >>a>>b>>c>>d;

  mx1=a*c;
  mx2=a*d;
  mx3=b*c;
  mx4=(b*d);
  cout<<max(max(mx1,mx2),max(mx3,mx4))<<"\n";
  return 0;
}


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

//Goldbach's Conjecture
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean[] p = new boolean[1<<15];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=2;i<1<<15;i++)if(p[i])for(int j=i+i;j<1<<15;j+=i)p[j]=false;
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int c = 0;
			for(int i=2;i<=n/2;i++)if(p[i]&&p[n-i])c++;
			System.out.println(c);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 11000
def add(a, w, d)
  while a <= d.size - 1
    d[a] += w
    a += a & -a
  end
end

def sum(i, d)
  ret = 0
  x = i
  while x > 0
    ret += d[x]
    x -= x & -x
  end
  return ret
end


def calc_area(p, x, y)
  i, j = p.split.map(&:to_i)
  return (x[i+1] - x[i])*(y[j+1] - y[j])
end

n = gets.to_i

r = []
x = {}
y = {}
ii = 0
done = {}
n.times{
  line = gets.chomp
  unless done[line]
    r[ii] = line.split.map(&:to_i)
    x[r[ii][0]]=1
    y[r[ii][1]]=1
    x[r[ii][2]]=1
    y[r[ii][3]]=1
    done[line] = 1
    ii += 1
  end
}

sx = x.keys.sort
xi = {}
sx.each_with_index{|v, i|
  xi[v] = i
}
sy = y.keys.sort
yi = {}
sy.each_with_index{|v, i|
  yi[v] = i
}

d = Array.new(sx.size){Array.new(sy.size+1){0}}

r.size.times{|i|
  xi[r[i][0]].upto(xi[r[i][2]]-1){|j|
    add(yi[r[i][1]]+1,  1, d[j])
    add(yi[r[i][3]]+1, -1, d[j])
  }
}

sum = 0
(sx.size-1).times{|i|
  (sy.size-1).times{|j|
    sum += (sx[i+1]-sx[i])*(sy[j+1]-sy[j]) if sum(j+1,d[i]) > 0
  }
}
p sum

Measured memory_bytes: 135524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  ll c1, c2, c3;
  c1 = a * x + b * y;
  c2 = c * max(x, y);
  if (x < y) {
    c3 = x * c + (y - x) * b;
  } else if (x > y) {
    c3 = y * c + (x - y) * a;
  } else {
    c3 = c2;
  }
  cout << min(c1, min(c2, c3)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
int main() {
	scanf("%d", &n);
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (n == i*j)n = 0;
		}
	}
	if (n)printf("No\n");
	else printf("Yes\n");
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(begin(v), end(v));
    double m = v[0];
    for(int i = 1; i < n; ++i){
        m = (m + v[i]) / 2;
    }
    cout << m << "\n";
    return 0;
}

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

int main() {
  int a,b,c;
  int da, db, dc;
  int i;
  scanf("%d %d %d", &a, &b, &c);
  if (a%2 == 1 || b%2 == 1 || c%2 == 1){
    printf("0\n");
  }
  else if (a==b && b==c){
    printf("-1\n");
  }
  else {
    da = abs(a-b);
    db = abs(b-c);
    dc = abs(c-a);
    i = 0;
    do {
      da = da/2;
      db = db/2;
      dc = dc/2;
      i = i+1;
    } while (da%2 != 1 && db%2 != 1 && dc%2 != 1);
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,M,K,suma=0,l,r,f=0;
  cin>>N>>M>>K;
  if((K-M)%2){
    cout<<"Borys"<<endl;
  }else{
    cout<<"Alice"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*#define _USE_MATH_DEFINES
#include<cmath>*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}	

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	char c; cin >> c;
	cout << char(c + 1) << "\n";

	return 0;
}


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

int n, a[1<<20], p[1<<20], ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], p[i] = i;
    sort(p, p + n, [&] (int x, int y) { return a[x] < a[y]; });
    for (int i = 0; i < n; i++) if (i%2 != p[i]%2) ans++;
    cout << ans/2;
}

Measured memory_bytes: 2688
#include"bits/stdc++.h"

using namespace std;
 
long long arr[100000];
int k;
 
int main() {
	
	cin >> k;

	for (int i = 0; i < k; i++) cin >> arr[i];
	long long mini = 2, maxi = 2;
	if (arr[k - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = k - 1; i >= 0; i--) {

		mini = (mini + arr[i] - 1) / arr[i] * arr[i];

		maxi = maxi / arr[i] * arr[i] + arr[i] - 1;

		if (mini > maxi) {

			cout << -1 << endl;

			return 0;
		}
	}

	cout << mini << " " << maxi << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  vector<int> a(n);
  rep(i,n) {
    R a[i];
    a[i]--;
  }
  vector<int> v;
  while(n--) {
    vector<int> b;
    int k=-1;
    rrep(i,a.size()) {
      if(a[i]==i) {
        k=i;
        break;
      }
    }
    if(k==-1) {
      pr(-1);
      return;
    }
    v.pb(k+1);
    rep(i,a.size()) {
      if(i==k) continue;
      b.pb(a[i]);
    }
    a=b;
  }
  rrep(i,v.size()) pr(v[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
let () =
  let n, k = Scanf.scanf "%d %d\n" (fun n k -> n, k) in
  let xycs = Array.init n (fun _ -> Scanf.scanf "%d %d %c\n" (fun x y c -> x, y, c)) in
  let candidates = Array.make_matrix (2 * k) (2 * k) 0 in
  Array.iter (function (x, y, c) ->
    begin if c = 'W' then [ (0, 0); (k, k) ]
    else [ (0, k); (k, 0) ] end
    |> List.map (fun (i, j) -> ((i - x + 2 * k * x) mod (2 * k), (j - y + 2 * k * y) mod (2 * k)))
    |> List.map (fun (x, y) ->
        if x < k then [(x, y)] else [(x, y); (x - 2 * k, y)])
    |> List.concat
    |> List.map (fun (x, y) ->
        if y < k then [(x, y)] else [(x, y); (x, y - 2 * k)])
    |> List.concat
    |> List.iter (fun (x, y) ->
        candidates.(max 0 x).(max 0 y) <- candidates.(max 0 x).(max 0 y) + 1;
        begin if x < k then
          candidates.(x + k).(max 0 y) <- candidates.(x + k).(max 0 y) - 1 end;
        begin if y < k then
          candidates.(max 0 x).(y + k) <- candidates.(max 0 x).(y + k) - 1 end;
        begin if x < k && y < k then
          candidates.(x + k).(y + k) <- candidates.(x + k).(y + k) + 1 end)) xycs;
  for j = 0 to 2 * k - 1 do
    for i = 1 to 2 * k - 1 do
      candidates.(i).(j) <- candidates.(i - 1).(j) + candidates.(i).(j)
    done
  done;
  for i = 0 to 2 * k - 1 do
    for j = 1 to 2 * k - 1 do
      candidates.(i).(j) <- candidates.(i).(j - 1) + candidates.(i).(j)
    done
  done;
  Array.map (Array.fold_left max 0) candidates
  |> Array.fold_left max 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 39548
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;

	double aa = (double)a;
	double bb = (double)b;
	double hh = (double)h;
	double mm = (double)m;

	const double PI = 3.14159265358979323846;

	//短針　h/12進む→360*((h+m/60)/12)
	double anglea = (double)(2*PI * (hh+mm/60)/12);
	//長針　m/60進む→360*(m/60)
	double angleb = (double)(2*PI * (mm/60));
	//角度
	double angle = abs(anglea - angleb);

	if (angle > PI)angle=2 * PI - angle;


	//余弦定理
	double length =(double)( aa * aa + bb * bb - 2 * aa * bb * cos(angle));

	cout <<fixed<<setprecision(11)<< (double)sqrt(length) << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll x ; 
  cin >> x ;
  intll k = 100 ; 
  intll ans = 0 ;
  
  while( k < x){
    intll a = k /100  ;
    k += a ;
    ans ++ ;
  }
  
  cout << ans ;

}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

#define NMAX 101

template<typename T>
void print(std::vector<T> &x) {
	for(int i=0; i<x.size(); ++i) {
		if (i==0) std::cout << x[i];
		else std::cout<< "," << x[i];
	}
	std::cout << std::endl;
}

void print(char *x, int n) {
	for(int i=0; i<n; ++i) {
		if (i==0) std::cout << x[i];
	 	else std::cout << "," << x[i];
	}
	std::cout << std::endl;
}	

std::set<char> Product(std::set<char> &left, std::set<char> &right) {
	std::set<char> out;
	for (std::set<char>::iterator it = left.begin();it != left.end(); ++it) {
		if (right.find(*it) != right.end()) {
			out.insert(*it);
		}
	}
	return out;
}

using namespace std;

int main(){
	int N;
	cin >> N; 
	char S[NMAX];
	// 改行コード読み飛ばし
	scanf("%c", &S[0]); 
	for(int i=0; i<N; ++i) scanf("%c", &S[i]); 
	//print(S,N);
	int cnt = 0;
  for (int i=1; i<N-1; ++i) {
		set<char> L(S, S+i);
		set<char> R(S+i, S+N);	
		set<char> P = Product(L,R);
		cnt = max(cnt, (int)P.size());
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
n, d = gets.chomp.split.map(&:to_i)

xs = Array.new(d)

n.times do |i|
  xs[i] = gets.chomp.split.map(&:to_i)
end

cnt = 0

n.times do |i|
  x1 = xs[i]
  
  (i + 1).upto(n - 1) do |j|
    x2 = xs[j]
    
    sum = 0
      
    res = x1.zip(x2) do |a, b|
      sum += (a - b) ** 2
    end
    
    sum = sum **(1/2.0)
    
    cnt += 1 if sum == sum.to_i
  end
end

puts cnt

Measured memory_bytes: 1788
fn main() {
    let x: i32 = read();
    if x < 1200 {
        println!("ABC");
    } else {
        println!("ARC");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
	

Measured memory_bytes: 4352
from collections import defaultdict

n = int(input())

factor_list = defaultdict(int)
for i in range(1, n+1):
    p = 2
    t = i
    while p <= n**0.5+5:
        if t%p == 0:
            factor_list[p] += 1
            t //= p
        else:
            p += 1
    if t > 1:
        factor_list[t] += 1

nums = [0 for _ in range(1000)]

for k, v in factor_list.items():
    nums[v] += 1

for i in range(998, -1, -1):
    nums[i] += nums[i+1]

print(nums[74]+nums[24]*(nums[2]-1)+nums[14]*(nums[4]-1)+ \
    nums[4]*(nums[4]-1)*(nums[2]-2)//2)


Measured memory_bytes: 3316
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXA = 1e6 + 10, MAXN = 2e5 + 10, MOD = 1e9 + 7;

int cnt[MAXA], a[MAXN];

set <int> s;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt[a[i]]++;
		s.insert(a[i]);
		
	}
	for(int i = 0; i < n; i++){
		if(cnt[a[i]] > 1) continue;
		bool flag = 1;
		for(int j = 1; j * j <= a[i]; j++){
			if(a[i] % j == 0){
				if(s.count(j)){
					flag = 0;
					break;
				}
				if(a[i] / j != a[i] && s.count(a[i] / j)){
					flag = 0;
					break;
				}
			}
		}
		ans += flag;
	}
	if(cnt[1] == 1) ans++;
	cout << ans << '\n';
}

Measured memory_bytes: 16780
/*
❤️❤️❤️I_love_QMsh❤️❤️❤️
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // <int> .find_by_order(int) .order_of_key(int)

template<typename T> bool smin(T &a, const T &b) { bool ret = b < a; return a = (ret ? b : a), ret; }
template<typename T> bool smax(T &a, const T &b) { bool ret = a < b; return a = (ret ? b : a), ret; }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd;

const int M = (int)1e9 + 7;

int bpow(int n, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) {
      res = (1ll * res * n) % M;
    }
    n = (1ll * n * n) % M;
    p /= 2;
  }
  return res;
}

const int N = 2e5 + 30;
int f[N];
int invf[N];

int cnk(int n, int k) {
  return (1ll * f[n] * invf[k] % M) * invf[n - k] % M;
}


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  f[0] = 1;
  invf[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = (1ll * f[i - 1] * i) % M;
    invf[i] = bpow(f[i], M - 2);
  }


  int n, m, a, b;
  cin >> n >> m >> a >> b;

  int ans = cnk(n + m - 2, n - 1);
  for (int i = 0; i < b; i++) {
    ans = ((ans - 1ll * cnk(i + n - a - 1, i) * cnk(m - i + a - 2, a - 1)) % M + M) % M;
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	int n, m;
	cin >> n >> m;
	int sum = 0;
	vint a(m);
	rep(i, m) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum > n) {
		cout << -1 << rt;
	}
	else {
		cout << n - sum << rt;
	}

	please AC;
}
//参考：---;

Measured memory_bytes: 3648
#include <iostream>
typedef long long i64;
#define N 100005

i64 n, a, b, xarr[N];

int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);
	for(int i = 1; i <= n; ++i) scanf("%lld", xarr + i);
	i64 ans = 0;
	for(int i = 2; i <= n; ++i)
		ans += std::min((xarr[i] - xarr[i - 1]) * a, b);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024