akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const long long MOD = 998244353;


ll gcd (ll a, ll b){ return b == 0? a : gcd(b, a % b); }
ll lcm (ll a, ll b){ return a * (b / gcd(a, b));}

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}

//* calculate C(n, 0), C(n, 1), ... C(n, n) mod p in O(n) 
vll mod_comb_list(ll n, ll p){
    vll res(n+1, 1);
    for(ll k=1; k <= n; k++){
        res[k] = (res[k-1] * (n - k + 1)) % p;
        res[k] = (res[k] * mod_inverse(k, p)) % p;
    }
    return res;
}

void solve(long long N, long long M, long long K){
    vll colorWay(N, 0);
    colorWay[0] = M % MOD;
    for(ll t=1; t < N; t++){
        colorWay[t] = (colorWay[t-1] * (M-1)) % MOD;
    }
    vll combList = mod_comb_list(N-1, MOD);
    ll ans = 0;
    for(ll k = 0; k<= K; k++){
        ll t = N-k;
        ans += (combList[t-1] * colorWay[t-1]) % MOD;
        ans = ans % MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 5944
#!/usr/bin/ruby
# AOJ
# ALDS1_3 A
# Revers polish notation

operands = gets.split(' ')
stack = []

operands.each do |ope|
  if /^\d+$/.match ope
    stack.push ope.to_i
  else
    tmp = stack.pop
    case ope
    when '+' then
      ans = stack.pop + tmp
    when '-' then
      ans = stack.pop - tmp
    when '*' then
      ans = stack.pop * tmp
    when '/' then
      ans = stack.pop / tmp
    end
    stack.push ans
  end
end

puts stack.pop

Measured memory_bytes: 8648
import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.HashMap[Int,Int]()
  val n = in.readLine.toInt
  Iterator.continually(in.readLine)
    .take(n)
    .map(_.toInt)
    .foreach(e => {
      if(!map.contains(e)) map += e -> 1
      else map(e) = map(e) + 1
    })

  val ans = map.count(e => (e._2&1)==1)

  println(ans)
}

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

const int inf = 1e5;

int main(){
  int N; cin >> N;
  vector<vector<int>> to(N);
  
  int dist[210][210]; 
  
  for(int i = 0; i < 210; i++){
    for(int j = 0; j < 210; j++){
      dist[i][j] = inf;
    }
  }
  
  for(int i = 0; i < 210; i++){
    dist[i][i] = 0;
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      char c; cin >> c; 
      if( c == '1'){ to[i].push_back(j);
                    dist[i][j] = 1;
                   }
    }
  }
  
  queue<int> Q; Q.push(0);
  vector<int> color(N,0);
  color[0] = 1; // 二部グラフ判定
  
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    
    for(auto v : to[p]){
      if( color[v] != 0){
        //すでに塗られていて、これがpと色が同じなら二部グラフにはできないから矛盾判定
        if( color[v] == color[p]){ cout << -1 << endl; return 0;}
       
      }
      else{
        
        color[v] = color[p]+1; Q.push(v);
      }
    }
  }
  
  //　二部グラフができたら、次にwarshall-floydで直径を求める
  
  
  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]);
      }
    }
  }
  int res = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      res = max( res, dist[i][j]);
    }
  }
  
  cout << res+1 << endl; return 0;
}
  
  
  
        

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

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

      

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int a; cin >> a;
  int b; cin >> b;
  forrange(i , a  , b) {
    cout << ((b % i == 0) ? (a + b) : (b - a)) << endl;
    break;
  }
 
  
   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

int main()
{
	string S;
	cin >> S;
	int A = 0;
	if (S[0] == '1') ++A;
	if (S[1] == '1') ++A;
	if (S[2] == '1') ++A;
	cout << A;
	return 0;
}

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

template<class Ty>
class priority {
	vector<Ty> inst;
public:
	bool empty() const { return inst.empty(); }
	size_t size() const { return inst.size(); }
	void shrink_to_fit() { inst.shrink_to_fit(); }
	void reserve(size_t s) { inst.reserve(s); }
	void insert(const Ty & a) {
		size_t i = size();
		inst.push_back(a);
		while (inst(i) < inst((i - 1) / 2)) {
			swap(inst[i], inst[(i - 1) / 2]);
			i = (i - 1) / 2;
		}
	}
	void insert(Ty && a) {
		size_t i = size();
		inst.push_back(a);
		while (i != 0) {
			if (inst[i] >= inst[(i - 1) / 2]) break;
			swap(inst[i], inst[(i - 1) / 2]);
			i = (i - 1) / 2;
		}
	}
	const Ty &get() {
		return inst.front();
	}
	void pop() {
		swap(inst.front(), inst.back());
		inst.pop_back();
		size_t i = 0;
		while (true) {
			if (size() <= i * 2 + 1) break;
			if (size() > i * 2 + 2) {
				int j = (inst[i * 2 + 1] < inst[i * 2 + 2]) ? (i * 2 + 1) : (i * 2 + 2);
				if (inst[j] < inst[i]) {
					swap(inst[j], inst[i]);
					i = j;
					continue;
				}
			}
			else if (size() > i * 2 + 1) {
				if (inst[i * 2 + 1] < inst[i]) {
					swap(inst[i * 2 + 1], inst[i]);
					i = i * 2 + 1;
					continue;
				}
			}
			break;
		}
	}
	Ty pick() {
		Ty buf = move(inst.front());
		pop();
		return move(buf);
	}
};

int main(){
	int n, q; cin >> n >> q;
	vector<priority<int>> Q(n);
	vector<int> ans;

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int t, v; cin >> t >> v;
			Q[t].insert(-v);
		}
		if (c == 1) {
			int t; cin >> t;
			if(!Q[t].empty()) ans.push_back(- Q[t].get());
		}
		if (c == 2) {
			int t; cin >> t;
			if (!Q[t].empty()) Q[t].pop();
		}
	}
	for (int i : ans) cout << i << endl;

	return 0;
}



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

int main()
{
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k = 0;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}



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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;

    cin >>n;
    vector<vector<pii>> say(n);

    for (int i = 0; i < n; i++){
        int ai;
        cin >>ai;

        for (int j = 0; j < ai; j++){
            int x,y;
            cin >>x>>y;

            say[i].emplace_back(--x,y);
        }
    }

    for (int i = 0; i < (1<<n); i++){

        map<int,int>tru,fal;
        int tmp=0;
        for (int j = 0; j < n;j++){
            if((i>>j)%2==1){
                tru[j]=1;
                ++tmp;

                //cout<<1<<",";
            }else{
                fal[j]=1;
                
                //cout<<0<<",";
            }
        }
        //cout << endl;

        bool br=false;
        for (int j = 0; j < n; j++){

            if(tru[j]==1){
                for(pii s:say[j]){
                    if(s.se == 0){
                        if(tru[s.fi]==1){
                            br=true;
                            //cout <<"true:"<<j<<" ,but "<<s.fi<<" also true"<<endl;
                            break;
                        }
                    }else{
                        
                        if(fal[s.fi]==1){
                            br=true;
                            //cout <<"true:"<<j<<" ,but "<<s.fi<<" is fal"<<endl;
                            break;
                        }
                    }
                }
            }
        }
        if(br)continue;
        ans = max(ans,(ll)tmp);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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


// 高橋君の家の窓の横方向の長さは A であり、横方向の長さが B のカーテンが 2 枚取り付けられています。(カーテンは縦方向には窓を覆うのに十分な長さがあります。)
// 窓のうちカーテンで隠されていない部分の横方向の長さが最小になるようにカーテンを閉めます。 このとき、窓のカーテンで隠されていない部分の合計の横方向の長さを求めてください。
int main()
{
    int a,b;
    cin >> a >> b;
    cout << ((a-b*2) < 0 ? 0 : a-b*2);
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

solver :: [Int] -> Int
solver [] = 0
solver xs =
    let ys  = filter even xs
        ys' = map (\x -> x `div` 2) ys
        in length ys' + solver ys'

main :: IO ()
main = do
    _ <- getLine
    s <- (map read) . words <$> getLine
    print $ solver s


Measured memory_bytes: 6524
def int2chr(n: int):
    if n == 0:
        return 'z'
    else:
        return chr(n + 96)


n = int(input())

name = ""
pow_index = 1
while True:
    m = n % 26
    name = int2chr(m) + name
    n -= m
    n //= 26
    if m == 0:
        n -= 1
    if n == 0:
        break
print(name)


Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int LIS(vi in){//Longest Increasing Subsequence
	int n=in.size();
	int r=1;
	vi out(n+1,inf);
	out[0]=-1;
	rep(i,n){
		for(int j=r;i>=0;j--){
			if(out[j]<in[i]){
				out[j+1]=in[i];
				r=max(r,j+1);
				break;
			}
		}
	}
	return r;
}
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	cout<<LIS(in)<<endl;
}

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

#define BeatMeScanf    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tc(x)          int x; cin >> x; while(x--)
#define ll             long long
#define vi             vector<int>
#define pii            pair<int,int>
#define mii            map<int,int>
#define inf            1<<28
#define mem(x,y)       memset(x, y, sizeof(x))
#define ps(x,y)        fixed<<setprecision(y)<<x
#define show(val)      cout<< #val << " -> " << val << endl
#define Case           cout<< "Case "<< ++cs << ": "
#define all(v)         (v).begin(), (v).end()
#define rall(v)        (v).rbegin(), (v).rend()
#define MOD            1000000007
#define MAX            100005

int main()
{
	BeatMeScanf;
	int r;
	cin >> r;
	double ans = 2.00*3.14159265358979323*r;
	cout<< fixed<<setprecision(20)<<ans <<'\n';
	return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <ios>
#include <vector>
#include <numeric>
using namespace std;

const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> freq(N, 0);
    for (int n = 0; n != N; ++n){
        int a;
        cin >> a;
        freq[a] += 1;
    }
    if (freq[0] != (N % 2)) {
        cout << 0 << endl;
        return 0;
    }
    if (N % 2){
        for (int i = 1; i <= N - 1; ++i){
            if (freq[i] != 2 * (1 - (i % 2))){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        for (int i = 1; i <= N - 1; ++i){
            if (freq[i] != 2 * (i % 2)){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    long long pow2 = 1LL;
    for (int i = 0; i != N/2; ++i) pow2 = (pow2 * 2) % mod;
    cout << pow2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(){
   int n,m,q,i,j,k,score=0,max;
    scanf("%d%d%d", &n, &m, &q);
    int seq[n],a[50],b[50],c[50],d[50];
    for(i=0; i<q; i++){
        scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    }
    for(i=0;i<n;i++){
       seq[i]=1;
    }
    max=score;
    while(1){
        score=0;
        for(i=0;i<q;i++){
            if((seq[b[i]-1]-seq[a[i]-1])==c[i]){
                score+=d[i];
            }
        }
        if(max<score){
            max=score;
        }

        if(seq[0]==m){
           break;
        }

        seq[n-1]++;

        if(seq[n-1]>m){
            for(j=n-1; j>=0; j--){
                if(seq[j]>m){
                    seq[j-1]++;
                    for(k=j; k<n; k++){
                        seq[k]=seq[j-1];
                    }
                }
                else{
                   break;
                }
            }
        }
    }

    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 1736
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		out.println((3 * ni() + ni()) / 2);
	}
		
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new Main().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 21076
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    
    let mut s = String::new();
    sin.read_line(&mut s).ok();
    s = s.replace("\n", "");    // remove new line

    let mut p = String::new();
    sin.read_line(&mut p).ok();
    p = p.replace("\n", "");    // remove new line

    let s2 = format!("{}{}", s, s);

    // println!("s : {}", s);
    // println!("p : {}", p);
    // println!("s2: {}", s2);

    if s2.contains(&p) {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5036
// ABC175-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll x,k,d,xx,max_,ans;
    cin>>x>>k>>d;
    xx=abs(x);
    max_=xx/d; 
    if(k<=max_) ans=xx-d*k;
    else{
        ll now1=xx-d*max_,now2=abs(now1-d);
        if((k-max_)%2==0) ans=now1;
        else ans=now2;
    } 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    to=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v=LI1()
        to[u].append(v)
        to[v].append(u)
    dp=[0]
    ans=[0]*n

    def dfs(u=0,pu=-1):
        a=aa[u]
        i=bisect_left(dp,a)
        end=(i==len(dp))
        if end:dp.append(a)
        else:
            pre=dp[i]
            dp[i]=a
        ans[u]=len(dp)-1
        for v in to[u]:
            if v==pu:continue
            dfs(v,u)
        if end:dp.pop()
        else:dp[i]=pre

    dfs()
    print(*ans,sep="\n")

main()

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

int main() {
    double n = 0;
    double ans = 0;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
    sort(v.begin(), v.end());
    for (int j = 1; j < n; j++) {
		v[j] = (v[j] + v[j-1])/2;
        ans = v[j];
	}
    cout << ans << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int number;
		short numberOfTimes, checkTime = 0, count = 0;
		numberOfTimes = Short.parseShort(in.readLine());
		while (true) {
			if (checkTime == numberOfTimes) {
				break;
			}
			number = Integer.parseInt(in.readLine());
			for (int x = 2; x <= number; x++) {
				if (x > Math.sqrt(number)) {
					count++;
					break;
				}
				if (number % x == 0) {
					if (number != x) {
						break;
					} else if (number == x) {
						count++;
					}
				}
			}
			checkTime++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22700
#include <bits/stdc++.h>
#include <numeric>
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef long long ll;
string text="abcdefghijklmnopqrstuvwxyz";
const int mx=1e5+7;
const ll m=1e9+7;
ll lazy[4*mx];
int a[mx];
ll tree[4*mx];
//void init(int node,int b,int e)
//{
//    if(b==e){
//        tree[node]=a[b];
//        return;
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    init(l,b,m);
//    init(r,m+1,e);
//    tree[node]=tree[l]*tree[r];
//}
//int query(int node,int b,int e,int i,int j)
//{
//    if(i>e || j<b)return 1;
//    if(b>=i && e<=j){
//        return tree[node];
//    }
//    int l=node*2;
//    int r=node*2+1;
//    int m=(b+e)/2;
//    int p1=query(l,b,m,i,j);
//    int p2=query(r,m+1,e,i,j);
//    return p1*p2;
//}
//void update(ll node, ll b, ll e, ll i, ll j, ll x)
//{
//    if (i > e || j < b)
//        return;
//    if (b >= i && e <= j)
//    {
//        tree[node].sum += ((e - b + 1) * x);
//        tree[node].prop += x;
//        return;
//    }
//    ll Left = node * 2;
//    ll Right = (node * 2) + 1;
//    ll mid = (b + e) / 2;
//    update(Left, b, mid, i, j, x);
//    update(Right, mid + 1, e, i, j, x);
//    tree[node].sum = (tree[Left].sum+ tree[Right].sum + ((e - b + 1) * tree[node].prop));
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int l = node * 2;
//    int r = node * 2 + 1;
//    int m = (b + e) / 2;
//    update(l, b, m, i, newvalue);
//    update(r, m + 1, e, i, newvalue);
//    tree[node] = (tree[l] * tree[r]);
//}
//void update(int node,int b,int e,int l,int r,int val)
//{
//    if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>e || b>r || e<l)return;
//    if(b>=l && e<=r){
//        tree[node]+=(e-b+1)*val;
//        if(b!=e){
//            lazy[node*2]+=val;
//            lazy[node*2+1]+=val;
//        }
//        return;
//    }
//    int mid=(b+e)/2;
//    update(node*2,b,mid,l,r,val);
//    update(node*2+1,mid+1,e,l,r,val);
//    tree[node]=tree[node*2]+tree[node*2+1];
//}
//int query(ll node,ll b,ll e,ll l,ll r)
//{
//     if(b>e || b>r || e<l)return 0;
//     if(lazy[node]!=0){
//        tree[node]+=(e-b+1)*lazy[node];
//        if(b!=e){
//            lazy[node*2]+=lazy[node];
//            lazy[node*2+1]+=lazy[node];
//        }
//        lazy[node]=0;
//    }
//    if(b>=l && e<=r){
//        return tree[node];
//    }
//    ll mid=(b+e)/2;
//    ll p1=query(node*2,b,mid,l,r);
//    ll p2=query(node*2+1,mid+1,e,l,r);
//    return p1+p2;
//}
vector <ll> v;
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        v.push_back(x);
    }
    ll sum=0;
    sum=accumulate(v.begin(),v.end(),0);
    sort(v.rbegin(),v.rend());
    cout << (v[k-1] * 4 * k >= sum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        int[][] data = new int[n][2];
        for (int i=0;i<n;i++){
            String s = sc.next();
            int count = 0;
            boolean b = true;
            for (int j=0;j<s.length();j++){
                if (!b)count++;
                if (s.charAt(j)!='.'){
                    a[i]=a[i]*10+s.charAt(j)-'0';
                }else {
                    b=false;
                }
            }
            while (count<9){
                a[i]*=10;
                count++;
            }
            long ins = a[i];
            while (ins%2==0){
                ins/=2;
                data[i][0]++;
            }
            ins = a[i];
            while (ins%5==0){
                ins/=5;
                data[i][1]++;
            }
        }
        int[][] table = new int[19][19];
        int baseAll = 0;
        int[] base2 = new int[19];
        int[] base5 = new int[19];
        for (int i=0;i<n;i++){
            if (data[i][0]>=18&&data[i][1]>=18)baseAll++;
            else if (data[i][0]>=18){
                for (int j=18-data[i][1];j<19;j++)base2[j]++;
            }
            else if (data[i][1]>=18){
                for (int j=18-data[i][0];j<19;j++)base5[j]++;
            }
            else {
                for (int j=18-data[i][0];j<19;j++){
                    for (int k=18-data[i][1];k<19;k++){
                        table[j][k]++;
                    }
                }
            }
        }
        long ans = 0;
        for (int i=0;i<n;i++){
            int pos2 = Math.min(data[i][0],18);
            int pos5 = Math.min(data[i][1],18);
            int def = baseAll+base2[pos5]+base5[pos2]+table[pos2][pos5];
            if (pos2>=9&&pos5>=9)def--;
            ans+=def;
        }
        System.out.println(ans/2);
    }
}


Measured memory_bytes: 66672
import sys
from collections import deque

input = sys.stdin.readline

N,M = map(int,input().split())
edge = [list(map(int,input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
indegree = [0 for _ in range(N)]

for i in range(M):
    graph[edge[i][0]-1].append(edge[i][1]-1)
    indegree[edge[i][1]-1] += 1

queue = deque()
for i in range(N):
    if indegree[i] == 0:
        queue.append(i)

dp = [0]*N

while queue:
    node = queue.popleft()
    for adj in graph[node]:
        indegree[adj] -= 1
        if indegree[adj] == 0:
            queue.append(adj)
            dp[adj] = dp[node]+1

print(max(dp))

Measured memory_bytes: 71388
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = a[0], l = a[1];

		var m = l > 0 ? l : l + n - 1 >= 0 ? 0 : l + n - 1;
		Console.WriteLine(Enumerable.Range(l, n).Sum() - m);
	}
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

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

    // up -> down
    ll sum = a[0], op1 = 0;
    if (sum <= 0) {
        op1 += -sum + 1;
        sum = 1;
    }
    for (int i = 1; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 1 && 0 <= sum) {
            op1 += sum + 1;
            sum = -1;
        }
        else if (i % 2 == 0 && 0 >= sum) {
            op1 += -sum + 1;
            sum = 1;
        }
    }

    // down -> up
    ll op2 = 0;
    sum = a[0];
    if (sum >= 0) {
        op2 += sum + 1;
        sum = -1;
    }
    for (int i = 1; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 0 && 0 <= sum) {
            op2 += sum + 1;
            sum = -1;
        }
        else if (i % 2 == 1 && 0 >= sum) {
            op2 += -sum + 1;
            sum = 1;
        }
    }

    cout << min(op1, op2) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);
const int N = 1e6+10;

int n;
string s;

void solve(){
    cin >> n >> s;
    int cnt = 0;
    rep(i,0,n)
        cnt += s[i]=='W';
    reverse(s.begin(),s.end());
    int sum = 0;
    rep(i,0,cnt)
        sum += s[i]=='R';
    cout << sum << '\n'; 
}

signed main(){
    Rushia_mywife
    solve();
}

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

int main(){
    string s;
    cin >> s;
    int num = 0;
    for (auto i = 0; i < 3; i++)
    {
        if(s[i] == 'o'){
            num += 1;
        }
    }

    cout << 700 + 100 * num << endl;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, dp[max_n];
vector<int> g[max_n];

pair<int, int> dfs(int v, int p, int h) {
    pair<int, int> res = make_pair(h, v);
    for (int to : g[v]) {
        if (to != p) {
            res = max(res, dfs(to, v, h + 1));
        }
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    pair<int, int> p = dfs(1, -1, 0);
    p = dfs(p.second, -1, 0);
    int d = p.first + 1;
    dp[1] = 1;
    dp[2] = 0;
    for (int i = 3; i <= d; ++i) {
        if (dp[i - 1] == 0 || dp[i - 2] == 0) {
            dp[i] = 1;
        } else {
            dp[i] = 0;
        }
    }
    if (dp[d]) {
        puts("First");
    } else {
        puts("Second");
    }
    return 0;
}


Measured memory_bytes: 27648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a,a+N);
    ll ans = a[N-1] - a[0];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    V=list(map(int,input().split()))
    ans=0
    for i in range(K//2+1):
        for j in range(min(K-i+1,N)):
            l=V[:j]+V[max(j,N-(K-i-j)):]
            l.sort()
            for k in range(i+1):
                ans=max(ans,sum(l[k:]))
    print(ans)
            
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 42092
"use strict";

function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0], 10);
  var works = [];

  for (var i = 1; i <= N; i++) {
    var work = input[i].split(" ");
    works.push([parseInt(work[0]), parseInt(work[1])]);
  }

  works.sort(function (a, b) {
    return a[1] - b[1];
  }); //console.log(works);

  var t = 0;

  for (var _i = 0; _i < works.length; _i++) {
    var w = works[_i];
    t += w[0];

    if (t > w[1]) {
      console.log("No");
      return;
    }
  }

  console.log("Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 66708
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



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

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

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    
    ll s1 = A/C - !(A%C);
    ll g1 = B/C;
    ll s2 = A/D - !(A%D);
    ll g2 = B/D;
    
    ll L = lcm(C, D);
    ll s3 = A/L - !(A%L);
    ll g3 = B/L;
    
//    ll ans = (g1-s1 + g2-s2 + g3-s3);
    
    cout << B - A + 1 - (g1-s1 + g2-s2 - (g3-s3)) << endl;
    
    
    return 0;
    
}



Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{

    ll i,j,k=0,c1=0,c2=0;
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)
    {
        cout<<0<<endl;
    }
    else if(n==1)
    {
        if(a!=b)
            cout<<0<<endl;
        else
            cout<<1<<endl;
    }
    else
        cout<<(n-2)*(b-a)+1<<endl;



    //cout<<endl;
}


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



int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> Ans(N);
    
    int now = 0;
    char befC = 'R';
    int Rnum = 0;
    int Lnum = 0;
    int Rind = 0;
    int Lind = 0;
    while(now < N){
        if(S.at(now) == 'R'){
            if(befC == 'L'){
                 if((Rnum + Lnum) %2 == 0){
                Ans.at(Rind) = (Rnum + Lnum) / 2;
                Ans.at(Lind) = (Rnum + Lnum) / 2;
            }else if(Rnum > Lnum){
                if(Rnum%2 ==0){
                    Ans.at(Rind) = (Rnum + Lnum) / 2;
                    Ans.at(Lind) = (Rnum + Lnum) / 2 + 1;
                }else{
                    Ans.at(Rind) = (Rnum + Lnum) / 2 + 1;
                    Ans.at(Lind) = (Rnum + Lnum) / 2;
                }
            }else{
                if(Lnum%2 == 0){
                    Ans.at(Rind) = (Rnum + Lnum) / 2 + 1;
                    Ans.at(Lind) = (Rnum + Lnum) / 2 ;
                }else{
                    Ans.at(Rind) = (Rnum + Lnum) / 2;
                    Ans.at(Lind) = (Rnum + Lnum) / 2 + 1;
                }
            }
            Rnum = 0;
            Lnum = 0;
            }
            Rnum ++;
            befC = 'R'; 
        }
        if(S.at(now) == 'L'){
            if(befC == 'R'){
                Rind = now - 1;
                Lind = now;
            }
            Lnum ++;
            befC = 'L';
        }
        if(now == N - 1){
                 if((Rnum + Lnum) %2 == 0){
                Ans.at(Rind) = (Rnum + Lnum) / 2;
                Ans.at(Lind) = (Rnum + Lnum) / 2;
            }else if(Rnum > Lnum){
                if(Rnum%2 ==0){
                    Ans.at(Rind) = (Rnum + Lnum) / 2;
                    Ans.at(Lind) = (Rnum + Lnum) / 2 + 1;
                }else{
                    Ans.at(Rind) = (Rnum + Lnum) / 2 + 1;
                    Ans.at(Lind) = (Rnum + Lnum) / 2;
                }
            }else{
                if(Lnum%2 == 0){
                    Ans.at(Rind) = (Rnum + Lnum) / 2 + 1;
                    Ans.at(Lind) = (Rnum + Lnum) / 2;
                }else{
                    Ans.at(Rind) = (Rnum + Lnum) / 2;
                    Ans.at(Lind) = (Rnum + Lnum) / 2 + 1;
                }
           
        }
        }
        now++;
    }

    for(int i = 0; i < N; i++){
        cout << Ans.at(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

int main()
{
	int n; std::cin >> n;
	int* A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int q; std::cin >> q;
	
	for (int i=0; i<q; i++) {
		int b, m, e;
		std::cin >> b >> m >> e;
		std::rotate(A + b, A + m, A + e);
	}
	
	std::cout << A[0];
	for (int i=1; i<n; i++) std::cout << " " << A[i];
	std::cout << std::endl;
	
	delete[] A;
	
	return 0;
}



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

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

    int ans = 0;
    int l = 0, r = n-1;
    while(l < r){
        if(s.at(l) == s.at(r)){
            l++;
            r--;
        } else if(s.at(l) == 'x'){
            l++;
            ans++;
        } else if(s.at(r) == 'x'){
            r--;
            ans++;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a=n/100,b=n%100;
	bool ym=false,my=false;
	if(a<=12&&a!=0)
	{
		my=true;
	}
	if(b<=12&&b!=0)
	{
		ym=true;
	}
	if(ym==true&&my!=true)
	{
		cout<<"YYMM"<<endl;
	}
	else
	if(ym!=true&&my==true)
	{
		cout<<"MMYY"<<endl;
	 } 
	else
	if(ym==true&&my==true)
	{
		cout<<"AMBIGUOUS"<<endl;
	}
	else
	{
		cout<<"NA"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
    long long int N;
    cin >> N;
    int digit=log10(N)+1;
    N++;
    int ans;
    long long int pow10 = pow(10,digit-1);
    ans = (digit-1)*9 + N/pow10 - 1;
    cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
int c[100][100];
int main() {
	int n,k;
	while(scanf("%d %d",&n,&k),n|k) {
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
			c[i][j]=(i==j)?0:(1<<29);
		}
		for(int i=0;i<k;i++) {
			int t,a,b,e;
			scanf("%d",&t);
			if(t==0) {
				scanf("%d %d",&a,&b);a--;b--;
				printf("%d\n",c[a][b]>=(1<<29)?-1:c[a][b]);
			}else {
				scanf("%d %d %d",&a,&b,&e);a--;b--;
				if(c[a][b]>e) {
					c[a][b]=c[b][a]=e;
					for(int x=0;x<n;x++) {
						for(int y=0;y<n;y++) {
							c[x][y]=min(c[x][y],min(c[x][a]+c[a][b]+c[b][y],c[x][b]+c[b][a]+c[a][y]));
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 20000
 
struct edge{
    int from, to, cost;
 
    edge(int from = -1, int to = -1, int cost = -1) 
	: from(from), to(to), cost(cost) {}
 
    bool operator < (const edge &e)const{
	return cost < e.cost;
    }
};
 
int main(){
    int N, M, t, s, d;
 
    while(cin >> N >> M , N){
	edge e[MAX];
 
	for(int i = 0 ; i < M ; i++){
	    cin >> t >> s >> d;
	    e[i] = edge(s-1, d-1, t);
	}
     
	sort(e, e+M);
	bool check[MAX] = {false};
	check[0] = true;
 
	for(int i = 0 ; i < M ; i++){
	    if(check[e[i].from]){
		check[e[i].to] = true;
	    }
	}
     
	int ans = 0;
	for(int i = 0 ; i < N ; i++){
	    if(check[i]) ans++;
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3288
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ((a + b) == c || (a + c) == b || (b + c) == a)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

vector<int> ans;
Sieve sieve; 

// bool canAppend(int prime){
//     cerr <<"prime" << prime <<"check" << endl;
//     cerr <<"size=" << ans.size() << endl;
//     for(int i=0;i<ans.size();i++){
     
//         for(int k=i+1;k<ans.size();k++){
//             for(int j=k+1;j<ans.size();j++){
//                 for(int l=j+1;l<ans.size();l++){
//                        cerr <<"i=" <<i <<"k="<<k <<"j="<<j<<"l="<<l<< endl;
//                     int num = ans[i] + ans[j] + ans[k] + ans[l] +prime;
//                     cerr <<"num=" << num <<endl;
//                     if(sieve.isPrime(num)){
//                         cerr << num << "is prime" << endl;
//                        return false; 
//                     }
//                 }

//             }
//         }
//     }
//     return true;
// }


void solve(long long N){
    sieve= Sieve(55555);
   
    int t=0;
    for(int i=0;i<N;i++){
        while(sieve.primes[t]%5 != 1){
            ++t;
        }
        int p = sieve.primes[t];
        ans.push_back(p);
        ++t;

    }
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof a)

const int maxn = 1e5 + 10;
int n,l;
int a[maxn],res[maxn];
LL sum = 0;

int main()
{
	//freopen("test.txt","r",stdin);
	cin >> n >> l;
	F(i,1,n) scanf("%d",a+i);
	int j = 0;
	F(i,1,n-1) if(a[i]+a[i+1] >= l)
	{
		j = i;
		break;
	}
	if(!j)
		puts("Impossible");
	else
	{
		puts("Possible");
		for(int i=n-1;i>j;--i)
			printf("%d\n",i);
		F(i,1,j-1)
			printf("%d\n",i);
		printf("%d\n",j);
	}
	return 0;
}


Measured memory_bytes: 1152
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P,int>PP;

int gcd(int a, int b) {
	if (!b)return a; return gcd(b, a%b);
}

int solve(set<PP>S, int d) {
	int l = inf; int ch = 0,cnt=0;
	for (auto itr = S.begin(); itr != S.end(); itr++) {
		if (itr->first.second == 0) {
			if (l == inf)l = itr->first.first;
			ch++;
		}
		else{
			ch--;
			if (ch == 0) {
				cnt += (itr->first.first - l) / d + 1;
				l = inf;
			}
		}
	}
	if (l != inf)assert(0);
	return cnt;
}

signed main() { 
	int n, x, d; cin >> n >> x >> d;
	vector<P>V;
	if (d < 0) {
		d *= -1;
		x *= -1;
	}
	rep(i, n+1) {
		int sd = i*(i - 1) / 2*d, ld = (2 * n - 1 - i)*i / 2*d;
		V.push_back(P(i*x+sd, i*x+ld));
	}

	if (!d) {
		if (!x)cout << 1 << endl;
		else cout << n + 1 << endl;
	}
	else {
		vector<P>V3;
		rep(i, n + 1) {
			V3.push_back(P(i*x% d, i));
		}
		sort(V3.begin(), V3.end());
		int cnt = 0;

		set<PP>S;
		int nm = V3[0].first;
		rep(i, n + 1) {
			if (V3[i].first != nm) {
				cnt += solve(S, d);
				S.clear();
			}
			nm = V3[i].first;
			int x = V3[i].second;
			S.insert(PP(P(V[x].first, 0),i));
			S.insert(PP(P(V[x].second, 1),i));
		}
		cnt += solve(S, d);

		cout << cnt << endl;
	}
}

Measured memory_bytes: 56428
math = input()
for i in range(2**3):
  op = format(i,"03b")
  op = op.replace('1', '+').replace('0', '-')
  ans = math[0]+op[0]+math[1]+op[1]+math[2]+op[2]+math[3]
  if eval(ans) == 7:
    print(ans+"=7")
    break


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

#define rep(i,n) for (int i = 0; i < n; ++i)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (998244353);

ll power(ll x, ll n) {
  if (n == 0) return 1;
  if (n%2 == 0) return power(x*x %MOD , n/2) %MOD;
  return power(x*x%MOD, n/2)*x%MOD;
}

int main() {
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  ll fact = 1;
  rep(i,n) fact = fact*(i+1)%MOD;
  vector<ll> inv(n+1);
  inv[n] = power(fact, MOD-2);
  for (int i = n; i > 0; --i) inv[i-1] = inv[i]*i % MOD;

  function<ll (ll,ll)> comb = [&inv, &fact] (ll n, ll r) {
    return fact * inv[r] %MOD * inv[n-r] %MOD;
  };

  ll res = 0;
  for (int i = 0; i <= n && a*i <= k; ++i) {
    if (((k-a*i)%b == 0)) {
      int j = (k-a*i)/b;
      if (j > n) continue;
      res = (res + comb(n, j)*comb(n, i)%MOD)%MOD;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	int n;
    cin>>n;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    p.pb(1e5+5);//最後の要素が合致していた場合、前のものとswapしなければいけないので番兵を追加
    int ans=0;
    rep(i,n){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);//前から貪欲に見ていくと前とswapするより後ろとswapした方が得
            ++ans;
        }
    }
    cout<<ans<<"\n";
    return;
}

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

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll A,B,C,ans;
  cin >> A>>B>>C;
  ans = max(0ll,C-A+B);
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256