akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n;
  vector<tuple<string,ll,ll>> array(n); vl num(n);
  
  rep(i,n){
    string s; ll x; cin >> s >> x;
    array[i] = make_tuple(s,-x,i+1);
  }
  
  sort(all(array));
  
  rep(i,n){
    ll a = get<2>(array[i]);
    cout << a << endl;
  }
  
  
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int d[N];for(int i=0;i<N;i++)cin>>d[i];
  set<int> values;
  for(int i=0;i<N;i++){values.insert(d[i]);}
  cout<<values.size()<<endl;
}

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

typedef long long ll;
typedef pair<int,int> p;

int n,ans=0;
int a[114514];

void selectionSort(int n){
  for(int i=0;i<n;i++){
    int minj=i;
    bool flag=false;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj])minj=j,flag=true;;
    }
    swap(a[i],a[minj]);
    if(flag)ans++;
  }
}

int main(){
  int n;
  cin>>n; 
  for(int i=0;i<n;i++)cin>>a[i];
  selectionSort(n);
  for(int i=0;i<n;i++){
      if(i!=n-1)cout<<a[i]<<" ";
      else cout<<a[i]<<endl;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3104
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    N = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))

    cnt_a = Counter(a)
    cnt_b = Counter(b)

    acc_a = [0] * 200001
    acc_b = [0] * 200001

    for i in range(1, 200001):
        acc_a[i] = acc_a[i - 1] + cnt_a[i]
        acc_b[i] = acc_b[i - 1] + cnt_b[i]
        if cnt_a[i] + cnt_b[i] > N:
            return print("No")

    ans = 0
    for i in range(200000, 0, -1):
        score = acc_b[i] - acc_a[i - 1]
        ans = max(ans, score)

    print("Yes")

    res = b[ans:] + b[:ans]
    print(*res)

if __name__ == '__main__':
    main()


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

typedef long long ll;

const int Maxn = 200005;

int n;
int a[Maxn];
ll L[Maxn], R[Maxn];
ll bestL[Maxn], bestR[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        L[i] = a[i];
        if (i >= 2) L[i] += L[i - 2];
    }
    for (int i = 1; i < n; i += 2)
        bestL[i] = max(L[i - 1], a[i] + (i - 2 >= 0? bestL[i - 2]: 0));
    if (n % 2 == 0) {
        printf("%lld\n", bestL[n - 1]);
        return 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        R[i] = a[i];
        if (i + 2 < n) R[i] += R[i + 2];
    }
    for (int i = n - 2; i >= 0; i -= 2)
        bestR[i] = max(R[i + 1], a[i] + (i + 2 < n? bestR[i + 2]: 0));
    ll res = L[n - 2];
    for (int i = 0; i + 1 < n; i++)
        if (i % 2 == 0) {
            ll cand = 0;
            if (i - 1 >= 0) cand += bestL[i - 1];
            if (i + 2 < n) cand += R[i + 2];
            res = max(res, cand);
        } else {
            ll cand = 0;
            if (i - 1 >= 0) cand += L[i - 1];
            if (i + 2 < n) cand += bestR[i + 2];
            res = max(res, cand);
        }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10792
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let w: u64 = iter.read();
	let h: u64 = iter.read();
	let x: u64 = iter.read();
	let y: u64 = iter.read();

	let s = (w as f64) / 2.0 * (h as f64);

	let m: u64 = if w == 2 * x && h == 2 * y { 1 } else { 0 };

	println!("{} {}", s, m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N, std::vector<long long> A){
    vector<ll> res(10000005);
    ll ans = 0;
    rep(i,N){
        ll d = A[i];
        if(res[d] != 0){
            res[d] = 2;
            continue;
        }
        for(ll j = d; j <= 10000005; j += d){
            res[j] += 1;
        }
    }
    rep(i,N){
        ll d = A[i];
        if(res[d] == 1) ans++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 83020
import heapq
n=int(input())
v=list(map(int,input().split()))
heapq.heapify(v)
for i in range(n-1):
    a=heapq.heappop(v)
    b=heapq.heappop(v)
    heapq.heappush(v,(a+b)/2)
ans=heapq.heappop(v)
print(ans)

Measured memory_bytes: 38384
// 0582.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int len[3], result[4] = { 0 };
	while (1) {
		for (int i = 0; i < 3; ++i) {
			cin >> len[i];
		}

		sort(len, len + 3);

		if (len[0] + len[1] > len[2]) {
			result[0]++;
		}
		else {
			goto EXIT;
		}

		int left = len[0] * len[0] + len[1] * len[1], right = len[2] * len[2];
		if (left == right) {
			result[1]++;
		}
		else {
			if (left > right) {
				result[2]++;
			}
			else {
				result[3]++;
			}
		}
	}

EXIT:

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

    return 0;
}

Measured memory_bytes: 3112
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int y = scan.nextInt();
    int[] a = new int[y];
    int[] b = new int[y];

    for (int i=0;i<y;i++){
        a[i] = scan.nextInt();
        b[i] = scan.nextInt();
    }

    long[] c = new long[20000];
    Arrays.fill(c,1000000000);
    c[0] = 0;
    for (int i=0;i<y;i++){
      for (int j=0;j<x;j++){
        c[j+a[i]] = (long) Math.min(c[j+a[i]],c[j] + b[i]);
      }
    }

    long min = 1000000000;
    for (int t = 19999;t>=x;t--){
      min = (long) Math.min(min,c[t]);
    }
    System.out.println(min);
  }

}


Measured memory_bytes: 40024
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	vector<int> P(N);
	vector< vector<int> > G(N);
	for(int i = 0; i < N; i++) cin >> P[i];
	for(int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	vector<int> comp(N, -1);
	int C = 0;
	for(int i = 0; i < N; i++) if(comp[i] == -1) {
		queue<int> q;
		comp[i] = C;
		q.push(i);
		while(!q.empty()) {
			ALL_THE(G[q.front()], it) if(comp[*it] == -1) {
				comp[*it] = C;
				q.push(*it);
			}
			q.pop();
		}
		C++;
	}

	vector<int> pos(N);
	for(int i = 0; i < N; i++) pos[P[i]-1] = i;
	int ans = 0;
	for(int i = 0; i < N; i++) if(comp[i] == comp[pos[i]]) ans++;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll g;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		/* code */
		if(i)
			g = __gcd(g,a[i]);
		else
			g = a[i];
	}
	if(g!=1)
	{
		cout<<"not coprime"<<endl;
		return;
	}
	map<ll,bool> m;
	bool flag = true;
	for (int i = 0; i < n; ++i)
	{
		ll x = a[i];
		set<ll> s;
		for(ll i = 2; i*i<= x; i++)
		{
			while(x%i==0)
			{
				x/=i;
				s.insert(i);
			}
		}
		if(x>1)
			s.insert(x);
		for(auto t:s)
		{
			if(m[t])
			{
				flag = false;
				break;
			}
			else
				m[t] = true;
		}
	}
	if(flag)
		cout<<"pairwise coprime"<<endl;
	else
		cout<<"setwise coprime"<<endl;

}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

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


ll com[52][52];
void nCr() {
  com[0][0]=1;
  rep(i, 1, 52) {
    rep(j, 0, i+1) {
      com[i][j]+=com[i-1][j];
      if (j>0) com[i][j]+=com[i-1][j-1];
    }
  }
}

int main() {
  int n, a,b;
  cin>>n>>a>>b;
  vector<ll> v(n);
  rep(i, 0, n) cin>>v[i];

  nCr();
  sort(v.begin(), v.end(), greater<ll>());
  ll sum=0;
  rep(i, 0, a) sum+=v[i];
  double res1=(double)(sum)/a;
  ll res2=0;
  int cnt=0;
  rep(i, 0, n) if (v[a-1]==v[i]) cnt++;
  if (v[0]==v[a-1]) rep(i, a, b+1) res2+=com[cnt][i];
  else {
    int tmp=0;
    rep(i, 0, a) if (v[a-1]==v[i]) tmp++; 
    res2=com[cnt][tmp];
  }
  cout<<setprecision(10)<<res1<<endl;
  cout<<res2<<endl;
}

Measured memory_bytes: 256
import std.stdio;

void main(){
	int n, outCount, score;
	int runner;
	string s;
	
	outCount = 3;
	readf("%d\n", &n);
	while ((s = readln()).length) {
		if (outCount == 3) { // initialize
			runner = 0;
			score = 0;
			outCount = 0;
		}
		if (s == "HIT\n") {
			if (runner >= 3) score++;
			else runner++;
		}else if (s == "OUT\n") {
			outCount++;
			if (outCount == 3) writeln(score);
		}else if (s == "HOMERUN\n") {
			score += runner + 1;
			runner = 0;
		}
	}
}

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

int main()
{
    string str;
    string answer;
    cin >> str;

    for (int i = 0; i < str.length(); i++) {
        if (str[i] == '0' || str[i] == '1') {
            answer.push_back(str[i]);
        } else if (str[i] == 'B' && !answer.empty()) {
            answer.pop_back();
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;

struct point {
	double x,y;

	point() {
		x = y = 0;
	}
	point(double xx, double yy) {
		x = xx;
		y = yy;
	}
	point operator+(point &a) {
		point b;
		b.x = x + a.x;
		b.y = y + a.y;
		return b;
	}
};
	
int main()
{
	point p, q;
	int n;
	double x, y, s;
	int i;
	double t;

	cout<<setprecision(2);
	cout<<setiosflags(ios::fixed);
	while (cin>>n) {
		if (n == -1) break;
		p = point(1.0, 0.0);
		for (i = 0; i < n-1; i++) {
			s = atan2(p.y,p.x) + M_PI_2;
			q = point(cos(s), sin(s));
			p = p+q;
		}
		cout<<p.x<<endl;
		cout<<p.y<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
n = gets.to_i
job = []

n.times do
  input = gets.chomp.split(" ").map(&:to_i)
  job << {:a => input[0] , :b => input[1]}
end

job.sort_by!{|hash| hash[:b]}

time = 0
job.each do |j|
  time += j[:a]
  if time > j[:b]
    puts "No"
    exit
  end
end

puts "Yes"

Measured memory_bytes: 66168
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n,m,s;
  int i,j;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    int card[105][2]={};
    rep(i,n){
      cin>>s;
      card[s][0]++;
      card[0][0]+=s;
    }
    rep(i,m){
      cin>>s;
      card[s][1]++;
      card[0][1]+=s;
    }
    int diff=card[0][0]-card[0][1];
    bool ans=true;
    if(diff==0){
      for(i=1;i<=100;i++)
	if(card[i][0] && card[i][1]){
	  cout<<i<<" "<<i<<endl;
	  ans=false;
	  break;
	}
    }else if(abs(diff)%2){
      ;
    }else if(diff>0){
      diff/=2;
      for(i=1;i+diff<=100;i++)
	if(card[i+diff][0] && card[i][1]){
	  cout<<i+diff<<" "<<i<<endl;
	  ans=false;
	  break;
	}
    }else{
      diff=abs(diff);
      diff/=2;
      for(i=1;i+diff<=100;i++)
	if(card[i][0] && card[i+diff][1]){
	  cout<<i<<" "<<i+diff<<endl;
	  ans=false;
	  break;
	}
    }
    if(ans)
      cout<<"-1"<<endl;
  }

}

Measured memory_bytes: 3068
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
int ans=99999;

void dfs(int cnt,string s,vector<int>num,int n){
    if(cnt<=0){
        if(s[0]=='0') return;
        int m=stoi(s);
        if(ans>=m && m>=n) ans=m;
        return;
    }else{
        for(int i=0;i<num.size();i++){
            dfs(cnt-1,s+to_string(num[i]),num,n);
        }
    }
}

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    for(int i=0;i<k;i++) {
        string m; cin>>m;
        s+=m;
    }
    vector<int>num;
    for(int i=0;i<=9;i++) {
        if(s.find(to_string(i))==string::npos) num.push_back(i); 
    }
    dfs(to_string(n).length(),"",num,n);
    dfs(to_string(n).length()+1,"",num,n);
    cout<<ans<<endl;
    
    


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int F(int x){
int count=0;
for(int i =0;i<31;i++){
if(x%2 != 0){
break;
}
x/=2;
count++;
}
return count;
}
int main() {
int N,x,ans=31;
cin >>N;
for(int i=0;i<N;i++){
cin>>x;
ans=min(ans,F(x));
}
cout<<ans<<endl;
}



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

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] numbers = new int[5];
        for (int i = 0; i < 5; i++) {
            numbers[i] = scanner.nextInt();
        }
        Arrays.sort(numbers);
        for (int i = numbers.length - 1; i > 0; i--) {
            System.out.print(numbers[i] + " ");
        }
        System.out.println(numbers[0]);
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K;
	cin >> N >> K;
	cout << ((K > 1) ? N-K : 0) << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
N, M = map(int, input().split())
cnt = [0 for _ in range(N + 1)]
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        cnt[b] += 1
    elif b == N:
        cnt[a] += 1
if 2 in cnt:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s;
    cin >> t;
    if(t.erase(size(t)-1) == s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = sc.nextInt();
    int W = sc.nextInt();

    String[][] S = new String[H][W];

    for (int i = 0; i < H; i++) {
      String s = sc.next();
      S[i] = s.split("");
    }

    sc.close();

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (S[i][j].equals(".")) {

          int count = 0;

          boolean checkU = true;
          boolean checkD = true;
          boolean checkR = true;
          boolean checkL = true;

          if (i == 0) {
            checkU = false;
          }
          if (i == H - 1){
            checkD = false;
          }
          if (j == 0) {
            checkL = false;
          }
          if (j == W - 1) {
            checkR = false;
          }

          if (checkU) {
            if (S[i-1][j].equals("#")){
              count++;
            }
          }

          if (checkD) {
            if (S[i+1][j].equals("#")){
              count++;
            }
          }

          if (checkL) {
            if (S[i][j-1].equals("#")){
              count++;
            }
          }

          if (checkR) {
            if (S[i][j+1].equals("#")){
              count++;
            }
          }

          if (checkU && checkL) {
            if (S[i-1][j-1].equals("#")){
              count++;
            }
          }

          if (checkU && checkR) {
            if (S[i-1][j+1].equals("#")){
              count++;
            }
          }

          if (checkD && checkL) {
            if (S[i+1][j-1].equals("#")){
              count++;
            }
          }

          if (checkD && checkR) {
            if (S[i+1][j+1].equals("#")){
              count++;
            }
          }

          S[i][j] = String.valueOf(count);

        }
      }
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        System.out.print(S[i][j]);
      }
      System.out.println("");
    }

  }

}

Measured memory_bytes: 23960
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for(int i = 0; i < n; i++) {
      int c = sc.nextInt();
      b[i] = c;
    }
    List<Integer> g = new ArrayList<>();
    int m = 10;
    int count = 0;
    do {
      int x = 1;
      m--;
      count = 0;
      for(int i = 0; i < n; i++) {
        int c = b[i];
        a[i] = c;
      }
      do {
        g.add(0, x);
        x = 3 * x + 1;
      } while(m > 0 && x < n / m);
      for(int i = 0; i < g.size(); i++) {
        for(int j = g.get(i); j < n; j++) {
          int v = a[j];
          int k = j - g.get(i);
          while(k >= 0 && v < a[k]) {
            a[k + g.get(i)] = a[k];
            k -= g.get(i);
            count++;
          }
          a[k + g.get(i)] = v;
        }
      }
    } while(count > Math.pow(n, 1.5));
    System.out.println(g.size());
    for(int i = 0; i < g.size(); i++) {
      if(i == g.size() - 1) {
        System.out.println(g.get(i));
      } else {
        System.out.print(g.get(i) + " ");
      }
    }
    System.out.println(count);
    for(int i = 0; i < n; i++) {
      System.out.println(a[i]);
    }
  }
}



Measured memory_bytes: 302124
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 100000000001
#define INFS 1000000
#define PI 3.141592653589793238

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x==0)cout << (n/x)*t << endl;
    else cout << (n/x)*t + t << endl;

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

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

        int res = N / 2;
        if(N % 2 != 0){
            res++;
        } 
        
        sc.close();
        
        System.out.println(res);
    }
}

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

int main(){
	int d,n,m,x[100000],c[10000];
	while(scanf("%d",&d),d){
		scanf("%d%d",&n,&m);
		x[0]=0;
		for(int i=1;i<n;i++) scanf("%d",&x[i]);
		for(int i=0;i<m;i++) scanf("%d",&c[i]);
		int p[100001];
		for(int i=0;i<n;i++) p[i]=x[i];
		p[n]=d;
		sort(p,p+n+1);
		int res=0;
		for(int i=0;i<m;i++){
			int *lb=lower_bound(p,p+n+1,c[i]);
			if(c[i]!=0) res+=min(lb[0]-c[i],c[i]-lb[-1]);
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 2024
A, B = gets.split(' ').map(&:to_i)
s = gets.chomp
ans = 'Yes'
if s[A] != '-'
  ans = 'No'
else
  s[A] = ''
  s.length.times do |i|
    if !(0..9).to_a.map(&:to_s).include?(s[i])
      ans = 'No'
    end
  end
end

puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int N, K; cin >> N >> K;
    double ans = 0;
    FOR(i, 1, N+1) {
        int count = 0;
        int cur = i;
        while (cur < K) {
            cur = cur * 2;
            count++;
        }
        ans += pow(0.5, count);
    }

    ans = ans / N;
    cout.precision(17);
    cout << ans << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

pair<vector<bool>, vector<int>> eratosthenes(int n){
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    for (int p = 2; p <= n; p++) {
        if (!is_prime[p]){
            continue;
        }
        for (int k = p * 2; k <= n; k += p){
            is_prime[k] = false;
        }
        res.push_back(p);
    }
    return make_pair(is_prime, res);
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint m, n;
    cin >> m >> n;
    lint res = 1;
    while(n > 0){
        if(n & 1){
            res *= m;
            res = res % MOD;
        }
        m *= m;
        m = m % MOD;
        n >>= 1;
    }
    res = res % MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>
int rank(int a){
    if(a == 1)
        return 300000;
    if(a == 2)
        return 200000;
    if(a == 3)
        return 100000;
    return 0;
}
int main(){
    int x, y;
    scanf("%d%d",&x,&y);
    int ans = 0;
    ans += rank(x);
    ans += rank(y);
    if(x == y && x == 1)
        ans += 400000;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
 
   long long int a,b,c,d=0,e,f,g,i,j,k,t=0,u=0,w,nt;
   double res;
   string x,y;
   char ch,ch1;
   vector<int> v;
   map<int,char> mp;
   map<int,char> mp2;
   vector<string> v1;
   set<int> s;
  cin>>a;
   res=2*3.1416*double(a);
  cout<<res<<endl;
 
 
 
 return 0;
}

Measured memory_bytes: 3708
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
pre = 0
e1, e2 = 0, 0
for a in A:
  if pre == a:
    if e1 == 0:
      e1 = a
    elif e2 == 0:
      e2 = a
    pre = 0
  else:
    pre = a
print(e1 * e2)

Measured memory_bytes: 14252
using System;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var times = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var drinkFig = ToInt32(ReadLine());
        var result = new int[drinkFig];
        for(var i = 0; i < drinkFig; i++)
        {
            var input = ReadLine().Split(' ');
            var sum = 0;
            for (var j = 0; j < times.Length; j++)
            {
                if (j == ToInt32(input[0])-1) { sum += ToInt32(input[1]);continue; }
                sum += times[j];
            }
            result[i] = sum;
        }
        foreach(var val in result)
        {
            WriteLine(val);
        }
    }
    
}



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

int main() {
	int n;
	cin >> n;
	int m;
	cin >> m;
	long long tot = 0;
	while(m--) {
		int x;
		cin >> x;
		tot += x;
	}
	cout << (n - tot < 0 ? -1 : n - tot);
}


Measured memory_bytes: 3112
import sys
# sys.setrecursionlimit(100000)
from collections import defaultdict
from functools import lru_cache


@lru_cache(None)
def gcd(x: int, y: int) -> int:
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x, y = y, r
    return x


def merge_dict(d1, d2):
    for k, v in d2.items():
        d1[k] += v
    return d1


def input():
    return sys.stdin.readline().strip()


def gen_prime_table(last: int, first=2) -> list:
    if last < 1:
        return [None]
    elif last < 2:
        return [None, None]
    table = [None] * (last + 1)

    for i in range(first, last + 1):
        if not table[i]:
            table[i] = i
            for j in range(i * 2, last + 1, i):
                table[j] = i
    return table


def prime_factorization(N: int, min_factor: list) -> dict:
    if N < 2:
        return {1: 1}
    primes = dict()
    primes[1] = 1
    while N != 1:
        p = min_factor[N]
        if p in primes.keys():
            primes[p] += 1
        else:
            primes[p] = 1
        N = N // p
    return primes


def main():
    n = int(input())
    A = [int(i) for i in input().split()]
    primes = defaultdict(int)
    is_pair_gcd = True
    set_gcd = A[0]
    min_factor = gen_prime_table(max(A))  # この部分の計算不可が大きい (n*log_log_n)
    for i in range(n):
        set_gcd = gcd(set_gcd, A[i])
        if is_pair_gcd:
            p = prime_factorization(A[i], min_factor)
            for k, v in p.items():
                if k == 1:
                    continue
                if k in primes.keys():
                    is_pair_gcd = False
                else:
                    primes[k] += v

    if is_pair_gcd:
        print("pairwise coprime")
        return

    if set_gcd == 1:
        print("setwise coprime")
    else:
        print("not coprime")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 349312
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

const int M = 1e9 +7;

bool arr[1001];

vector <int> prime;

void siv()
{
	for(int i=2;i<=1001;i++)
	{
		if(arr[i]==0)
		{
			prime.push_back(i);
			for(int j=i*i;j<=1001;j+=i) arr[j]=1;
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	siv();
	int ans = 1;
	for(auto &i : prime)
	{
		int x = n, cur =0;
		while(x)
		{
			x /= i;
			cur += x;
		}
		ans *= (cur+1)%M;
		ans %= M;
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  double v;

  while ( cin >> v )
    {
      cout << 1 + ceil( v * v / 98.0 ) << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string s="";
  for(int i=0;i<ty-sy;i++) s+="U";
  for(int i=0;i<tx-sx;i++) s+="R";
  for(int i=0;i<ty-sy;i++) s+="D";
  for(int i=0;i<=tx-sx;i++) s+="L";
  for(int i=0;i<=ty-sy;i++) s+="U";
  for(int i=0;i<=tx-sx;i++) s+="R";
  s+="DR";
  for(int i=0;i<=ty-sy;i++) s+="D";
  for(int i=0;i<=tx-sx;i++) s+="L";
  s+="U";
  cout<<s<<endl;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << "," << a.second << ")";return os;}

int main() {
    int n;
    map<string,int> mp;
    cin >> n;
    for (int i = 0;i < n;++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto& p : mp) mx = max(mx,p.second);
    for (auto& p : mp) if (p.second == mx) cout << p.first << "\n";
}

Measured memory_bytes: 25344
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  char c;
  cin >> c;
  if(c >= 'a' and c <= 'z') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

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

int main()
{
    int n; string s;
    cin>>n>>s;
    int counter=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            counter++;
            i+=2;
        }
    }
    cout<<counter<<endl;
    return 0;
}

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

#define    str     string
#define    ll      long long int
#define    li      long int
#define    con     continue
#define    rt      return 0
#define    fr      first
#define    sec     second
#define    pf      push_front
#define    pb      push_back
#define    vb      vct.begin()
#define    ve      vct.end()
#define    ib      it.begin()
#define    ie      it.end()
#define    itf     it->first
#define    its     it->second
#define    lb      lst.begin()
#define    le      lst.end()
#define    mb      mp.begin()
#define    me      mp.end()
#define    stb     st.begin()
#define    ste     st.end()
#define    sb      s.begin()
#define    se      s.end()
 
#define   yes       printf("YES\n")
#define   no        printf("NO\n")
#define   forone    for(i=1;i<=n;i++)
#define   forzero   for(i=0;i<n;i++)
#define   sortone   sort(ara+1,ara+n+1)
#define   sortzero  sort(ara,ara+n)

#define tc ll tc;scanf("%lld",&tc);while(tc--)

using namespace std;

int main( )
{
	 //tc
    
   {
     
    ll r,n,m,i,j,count=0,x,a,b,y;
    ll mn=0,mx=0,ans[9],k,pos=0,neg=0,ind;   
    cin>>n;  
            
    ll ara[mn+1];       
            
   /* for(i=1;i<=n;i++)    
    {
       for(j=i;j<=n;j++) 
        {
          ll x_or=i xor j;
             
          if(x_or<j || x_or>n) con;
        //cout<<i<<"^"<<j<<":"<<x_or<<" ";        
           if(i+j>x_or) count++;      
        }
       //cout<<endl; 
    } */
      if(n==1) cout<<0<<endl; 
     else cout<<1<<endl;                    
    }   
    return 0;
 } 












Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    //ld ans = 0;
    ll N;
    cin >> N;
    vector<vector<pair<ll,ll>>> A(N);
    for1(i,N-1) {
        ll u,v,w;
        cin >> u >> v >> w;
        --u;
        --v;
        A[u].push_back(make_pair(v,w));
        A[v].push_back(make_pair(u,w));
    }
    vector<ll> ans(N,-1);
    stack<pair<ll,ll>> sta;
    sta.push(make_pair(0,0));
    while (!sta.empty()) {
        pair<ll,ll> item = sta.top();
        sta.pop();
        ll location = item.first;
        ll distance = item.second;
        ans[location] = distance % 2;
        for (auto b : A[location]) {
            if (ans[b.first] == -1) {
                sta.push(make_pair(b.first, distance + b.second));
            }
        }
    }
    for1(i,N) {
        cout << ans[i] << endl;
    }

    return 0;
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 8704
//2020.1.23
//s1270188 xxxmk2
//alds1_11b

#include<stdio.h>
#define N 100

//global
int data[N+1][N], num, vi[N+1], t=0, re[N+1][2];

//prototype
void dfs(void);
void visit(int);

int main(){
  int i, j, a, b;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++) scanf("%d",&data[a][j]);
    data[a][j]=0;
  }

  //dfs
  dfs();
  
  return 0;
}

void dfs(void){
  int u;

  //reset
  for(u=1;u<=num;u++) vi[u]=0;

  for(u=1;u<=num;u++){
    if(vi[u]==0) visit(u);
  }

  for(u=1;u<=num;u++) printf("%d %d %d\n",u,re[u][0],re[u][1]);
}

void visit(int u){
  int v;
  
  vi[u]=1;
  re[u][0]=++t;

  for(v=0;data[u][v]!=0;v++)
    if(vi[data[u][v]]==0) visit(data[u][v]);

  vi[u]=2;
  re[u][1]=++t;
}



Measured memory_bytes: 2088
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
//#include "pch.h"    
using namespace std;
unordered_map<int, bool> here;
 
using ll = long long;
const int nax = 5e5 + 2;
const ll mod = 1e9 + 7;

int main() {
    
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC\n";
    }else{
        cout << "ABC\n";
    }
    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if(a == 1)a=14;
    if(b == 1)b=14;
    if(a == b)cout << "Draw" << endl;
    else if(a > b)cout << "Alice" << endl;
    else if(a < b)cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var tmp = input.split("\n");
    var NM = tmp[0].split(" ");
    var MarI = tmp[1].split(" ");

    var N = NM[0];
    var M = NM[1];

    function numberorder(a,b){return b-a}
    MarI.sort(numberorder);

    var sum=0

    for(var i=0;i<MarI.length;i++){
        sum = sum + parseInt(MarI[i],10);
    }
    border = sum / (4*M);

    //console.log(N+","+M);
    //console.log(MarI);
    //console.log(sum+","+border);

    if(MarI[parseInt(M,10)-1] >= border){
        console.log("Yes");
    }else{
        console.log("No");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22084
#include <iostream>
#include <cmath>
#include <numeric>

using namespace std;


long long gcd(long long x, long long y) {
    long long r = x % y;
    while (r != 0) {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}


int main() {
    long long A, B;
    cin >> A >> B;

    long long gcd_ans = gcd(A, B);
    int ans = 1;
    for (int i = 2; i <= sqrt(gcd_ans); i++) {
        if (gcd_ans % i == 0){
            ans++;
            while (gcd_ans % i == 0) {
                gcd_ans /= i;
            }
        }
    }
    if (gcd_ans > 1) {
        ans++;
    }

     cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// C++11
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}


int main(void)
{
  int A, B, X;
  cin >> A >> B >> X;
  string ans;
  cout << (A <= X && A + B >= X ? "YES" : "NO") << endl;


  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    edges = [[] for _ in range(n)]
    exceptions = []
    for _ in range(m):
        a, b = map(int, input().split())
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)
        exceptions.append((a-1, b-1))

    ans = 0
    for from_, to in exceptions:
        res = dfs(n, edges, exception={(from_, to), (to, from_)})
        if not res:
            ans += 1
    print(ans)


def dfs(nodes, edges, exception):
    seen = [False] * nodes
    todo = [0]
    while todo:
        node = todo.pop()
        if seen[node]:
            continue
        seen[node] = True

        for to in edges[node]:
            if (node, to) in exception:
                continue
            todo.append(to)

    return sum(seen) == nodes


if __name__ == "__main__":
    main()


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

vector <int> g[100001];
int vis[100001],ans[100001];
int dfs(int i)
{
	int max=0,k;
	for(auto it:g[i])
	{
		if(vis[it]==0)
        {
          vis[it]=1;
		k=1+dfs(it);
        }
		else
		k=1+ans[it];
		if(k>max)
		max=k;
	}
	return ans[i]=max;
}
int main()
{
	
	int n,m,i,x,y,k,max=0;
	
	
	memset (vis,0,100001);
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		
		g[x].push_back(y);
	}
	
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			k=dfs(i);		
		}
		else
		k=ans[i];
		
		if(k>max)
		max=k;
     // cout<<ans[i]<<" "<<i<<"\n";
	}
	cout<<max;
}

Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

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

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

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

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}


int n,m,a,b;
vi v[2*M];


int main() {
	cin>>n>>m;
	rep(i,0,m){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
	queue<int> que;
	int ans[M]={};

	// 初期条件 (頂点 0 を初期ノードとする)
	que.push(1);

				 // BFS 開始 (キューが空になるまで探索を行う)
	while (!que.empty()) {
		int x = que.front(); // キューから先頭頂点を取り出す
		que.pop();

		// v から辿れる頂点をすべて調べる
		for (int nv : v[x]) {
			if (ans[nv] != 0) continue; // すでに発見済みの頂点は探索しない

										  // 新たな白色頂点 nv について距離情報を更新してキューに追加する
			ans[nv] = x;
			que.push(nv);
		}
	}
	bool f=true;


	rep(i,2,n+1)
		if(ans[i]==0)f=false;
	if(!f){
		print("No");
		rep(i,2,n+1)print(ans[i]);
		return 0;
	}else{
		print("Yes");
		rep(i,2,n+1)
			print(ans[i]);

	}






}

Measured memory_bytes: 18040
#include <stdio.h>
#include <stdlib.h>
int min(int a,int b,int c,int d){
	int min =a;
	if(min>b)min=b;
	if(min>c)min=c;
	if(min>d)min=d;
	return min;
}
int main(void){
	int N,A,B,C;
	int tempA,tempB,tempC;
	int l[8]={};
	int i,j;
	scanf("%d%d%d%d",&N,&A,&B,&C);
	for(i=0;i<N;i++){
		scanf("%d",&l[i]);
	}
	int function(int a,int b,int c,int d,int n,int l[8]){
		if(d==n && a*b*c>0){
			return abs(A-a)+abs(B-b)+abs(C-c) -30;
		}else if(d==n){
			return 1e9;
		}
		else{
			int r1 = function(a,b,c,d+1,n,l);
			int r2 = function(a+l[d],b,c,d+1,n,l)+10;
			int r3 = function(a,b+l[d],c,d+1,n,l)+10;
			int r4 = function(a,b,c+l[d],d+1,n,l)+10;
			return min(r1,r2,r3,r4);
		}
	}
	int ans = function(0,0,0,0,N,l);
	printf("%d",ans);
}

Measured memory_bytes: 128