akhauriyash/Code-Regression huggingface dataset:
x, n = map(int, input().split())
p_l = list(map(int, input().split()))
p_l.sort()
if p_l == [] :
    print(x)
else :
    ans = [x, x]
    while True :
        if ans[0] not in p_l :
            print(ans[0])
            break
        elif ans[1] not in p_l :
            print(ans[1])
            break
        else :
            ans[0] -= 1
            ans[1] += 1


Measured memory_bytes: 9160
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
if x[n-1]<Y and X<y[0] and x[n-1]<y[0]:
  print("No War")
else:
  print("War")

Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
using namespace std;

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

typedef long long ll;

int main() {
	
	//入力;
	int D;
	ll G;
	cin >> D >> G;

	vector<int> p;
	vector<ll> c;
	p.resize(D);
	c.resize(D);
	REP(i, D) {
		cin >> p[i] >> c[i];
	}

	//bit用vector;
	vector<int> B;
	B.resize(D);

	int ans = 10 * 100 + 1; //必要最小の問題数;
	
	REP(bit, 1 << D) {

		//B[i]=1 点数(i+1)*100点区分の問題を全て解く B[i]=0 １問も解かない;
		REP(i,D) {
			if (bit & 1 << i) B[i] = 1;
			else B[i] = 0;
		}

		ll score = 0;
		ll mondai = 0;

		REP(i, D) {
			if (B[i] == 1) { //全部解いた区分のスコア合計を足す:
				score += (ll)100 * (i + 1) * p[i] + c[i];
				mondai += p[i];
			}
		}

		if (score >= G) { //この時点で目標スコアを超えた場合;
			if (mondai < ans) ans = mondai;
		}

		else { //そうではない場合;

			int chuto = -1;//中途半端な得点区分を表す変数(if chuto=1 → 200点区分が中途半端;
			REP(i, D) {
				if (B[i] == 0) chuto = i;
			}

			if (G - score > (p[chuto] - 1) * (chuto + 1) * 100) { //この区分の問題数-1×得点よりも目標スコアとの差額が大きい場合、達成不可能であるから、スコアの更新を行わない;
			}
			else {
				FOR(i, 1, p[chuto]) {
					if (G - score <= i * (chuto + 1) * 100) {
						mondai += i;
						if (mondai < ans) ans = mondai;
						break;
					}
				}
			}
		}
		
	}
	cout << ans << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};


int32_t main(){
 	fastIO;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int st=1;
	while(true){
		if(a<=0){
			cout<<"No"<<endl;
			break;
		}
		else if(c<=0){
			cout<<"Yes"<<endl;
			break;
		}
		if(st)
			c-=b;
		else
			a-=d;
		st^=1;
	}
}		



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INTF = 1e9 + 7;

int dp[3005][3005];
int pre[3005];

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

  dp[1][1] = 1;

  for(int i=1; i<=n; i++)
    pre[i] = (pre[i-1] + dp[1][i])%INTF;

  for(int i=2; i<=n; i++)   
  {
    for(int j=1; j<=i; j++)  
    {
      int L, R;
      if(s[i-2] == '<')
      {
        L = 1, R= j-1;
      }
      else
      {
        L = j, R= i-1;
      }

      dp[i][j] = (1ll*dp[i][j] + 1ll*pre[R] - 1ll*pre[L-1] + INTF)%(1ll*INTF);
    }
    for(int k=1; k<=n; k++)
      pre[k] = (1ll*pre[k-1] + 1ll*dp[i][k])%(1ll*INTF);
  }

  int ans = 0;
  for(int i=1; i<=n; i++)
    ans = (1ll*ans + 1ll*dp[n][i])%(1ll*INTF);

  cout<<ans;
  return 0;
}


Measured memory_bytes: 34176
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        int result = n/x;
        if(n%x == 0){
            System.out.println(result * t);
        }
        else{
            System.out.println((result+1) * t);
        }
    }
}

Measured memory_bytes: 35772
#include <iostream>

using namespace std;

int main(void){
  int n;
  int i, sum = 0;
  cin >> n;
  for(i = 0; i < n; i++){
    if(i<9){
      sum++;
    }
    else if(i<99){	
    }
    else if(i<999){
      sum++;
    }
    else if(i<9999){
    }
    else if(i<99999){
      sum++;
    }
  }
  cout << sum;
  return 0;
  
}

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

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int L = A + B;
	int R = C + D;

	if (L == R) {
		cout << "Balanced";
	} else if (L > R) {
		cout << "Left";
	} else {
		cout << "Right";
	}

	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
const ll mod=1000000007;
ll Pow(ll a,ll b){
	ll x=1;
	while(b){
		if(b&1)x=(x*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return x;
}
ll f[100100];
ll inv[100100];

ll NCR(int a,int b){
	ll ans=f[a];
	ans*=inv[b];
	ans%=mod;
	ans*=inv[a-b];
	ans%=mod;
	return ans;
}

int main()
{
	f[0]=1;
	for(int i=1;i<100100;i++){
		f[i]=(f[i-1]*1LL*i)%mod;
	}
	inv[100100-1]=Pow(f[100100-1],mod-2);
	for(int i=100100-2;i>=0;i--){
		inv[i]=(inv[i+1]*1LL*(i+1))%mod;
	}
	int n,m;
	cin>>n>>m;
	ll ans=1;
	for(int i=2;i*i<=m;i++){
		int c=0;
		while(m%i==0){
			m/=i;
			c++;
		}
		if(c){
			// cout<<i<<' '<<c<<endl;
			ans=(ans*NCR(c+n-1,c))%mod;
		}
	}
	if(m!=1){
		ans=(ans*NCR(1+n-1,1))%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void inorder( Node );
void preorder( Node );
void insert( int );
//-----------------------------------------------------------
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    /*if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else*/ if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }/* else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }*/
  }

  return 0;
}
/*
//----------------------------------------------------------
Node treeMinimum(Node x){


}

//------------------------------------------------------------
Node treeMaximum(Node x){


}

//----------------------------------------------------------
Node treeSearch(Node u, int k){


}

//----------------------------------------------------------
Node treeSuccessor(Node x){


}

//----------------------------------------------------------
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}*/

//-----------------------------------------------------------
void insert(int k){
  Node y = NIL;   //y is parent of the k 
  Node x = root;   //x is the root node
  Node z;   //z is new node for the k

  //initialization
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  //decide where to place the z node
  while(x != NIL){  //when Binary Tree T is not empty.
      y = x;  //substitute x for y as a parent
      if(z->key < x->key) x = x->left;
      else  x = x->right;
  }
  z->parent = y;
  //connect them
  if(y == NIL) root = z;//when Binary Tree T is empty
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

//-------------------------------------------------------------
void inorder(Node u){
    if(u != NIL){
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
    }
    return ;
}

//-------------------------------------------------------------
void preorder(Node u){
    if(u != NIL){
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
    }
    return ;
}



Measured memory_bytes: 25212
#include <iostream>
#include <utility>
#include <stdint.h>
#include <map>

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  uint64_t p=2;

  map<uint64_t, uint64_t> M;
  
  while (N>=p) {
    //cerr << "p=" << p << " N=" << N << endl;
    if (N%p==0) {
      N /= p;
      if (M.count(p)==0) {
	M[p] = 1;
      } else {
	++M[p];
      }
    } else {
      if (p==2)
	++p;
      else if (p*p>N)
	p = N;
      else
	p += 2;
    }
  }

  uint64_t ans = 0;

  for (auto m : M) {
    uint64_t n=1;
    for (; 2*m.second >= n*(n+1) ; ) {
      ++n;
    }
    --n;
    ans += n;
  }

  cout << ans << endl;

  return 0;
}


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

int l;

void debug(const vector<char>& v) {
    for (int i = 0; i < l - 1; ++i) {
        cout << (i < v.size() ? v[i] : '?');
    }
    cout << "\n";
}

bool check(const vector<int>& a, const vector<char>& v, int sum) {
    int s = a[0];
    for (int i = 0; i < l - 1; ++i) {
        if (v[i] == '+') s += a[i + 1];
        else             s -= a[i + 1];
    }
    return s == sum;
}

int main() {
    string s;
    cin >> s;
    l = s.length();
    vector<int> a(l);
    for (int i = 0; i < l; ++i) {
        a[i] = s[i] - '0';
    }
    vector<vector<char>> ans;
    stack<vector<char>> st;
    st.push(vector<char>());
    while (!st.empty()) {
        vector<char> v = st.top();
        st.pop();
        // debug(v);
        if (v.size() == l - 1) {
            if (check(a, v, 7))
                ans.push_back(v);

            continue;
        }
        v.push_back('+');
        st.push(v);
        v.pop_back();
        v.push_back('-');
        st.push(v);
    }
    if (ans.size() == 0) return 0;
    for (int i = 0; i < l; ++i) {
        cout << a[i];
        if (i < l - 1) {
            cout << ans[0][i];
        }
    }
    cout << "=7\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

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

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	in(n);
	int p[200004] = {}, cnt = 0, max = 200004;

	rep(i, n) cin >> p[i];

	rep(i, n) {
		if (max > p[i]) {
			max = p[i];
			++cnt;
		}
	}

	out(cnt);

	return 0;
}


Measured memory_bytes: 1024
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()
    const a = r.nn()

    let xsum = a[0]

    for (let i = 1; i < N; i++) {
      xsum = xsum ^ a[i]
    }
    const res = a.map((ai) => {
      return ai ^ xsum
    })

    return res.join(' ')
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 68232
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n,m;
   cin >> n>>m;
   if(n>=(m/2)){
     cout <<m/2<<endl;
   }
   else{
     ll k=m-n*2;
     cout <<n+k/4<<endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	string s; cin >> s;
	int mi=0;
	int now=0;
	while(now!=n){
		for(int i=k;i>=0;i--){
			if(now+i<=n&&s[now+i]=='0'&&i){
				now+=i;
				mi++;
				break;
			}
			if(i==0){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	now=n;
	vector<int> ans;
	while(now){
		for(int i=k;i>=1;i--){
			if(now-i>=0&&s[now-i]=='0'){
				ans.push_back(i);
				now-=i;
				break;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	for(int p:ans){
		cout << p << endl;
	}
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    while (1)
    {
        cin >> N >> M;
        if (N == 0 && M == 0)
            return 0;
        long long H[N], W[M];
        for (int i = 0; i < N; i++)
        {
            cin >> H[i];
        }
        for (int i = 0; i < M; i++)
        {
            cin >> W[i];
        }
        long long S_H[N + 1] = {0};
        long long S_W[M + 1] = {0};
        for (int i = 0; i < N; i++)
        {
            S_H[i + 1] = S_H[i] + H[i];
        }
        for (int i = 0; i < M; i++)
        {
            S_W[i + 1] = S_W[i] + W[i];
        }
        map<long, long> x, y;
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N; j++)
            {
                if (i < j)
                    x[S_H[j] - S_H[i]]++;
            }
        }
        for (int i = 0; i <= M; i++)
        {
            for (int j = 0; j <= M; j++)
            {
                if (i < j)
                    y[S_W[j] - S_W[i]]++;
            }
        }
        long long cnt = 0;
      	for(auto p:x){
          cnt+=x[p.first]*y[p.first];
        }
        cout << cnt << endl;
    }
}


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

int main(){
	char c[8][8];
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			cin>>c[i][j];
			}
		}
		cout<<"90"<<endl;
		for(int i=0;i<8;i++){
			for(int j=7;j>-1;j--){
				cout<<c[j][i];
				if(j==0){cout<<endl;}
				}
			}
			
		cout<<"180"<<endl;
		for(int i=7;i>-1;i--){
			for(int j=7;j>-1;j--){
				cout<<c[i][j];
				if(j==0)cout<<endl;
				}
			}
			
		cout<<"270"<<endl;
		for(int i=7;i>-1;i--){
			for(int j=0;j<8;j++){
				cout<<c[j][i];
				if(j==7)cout<<endl;
				}
			}		
		return 0;	
			
	}

Measured memory_bytes: 2988
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, m): (usize, usize) = read();
    let mut from1: Vec<bool> = vec![false; n];
    let mut ton: Vec<bool> = vec![false; n];

    for i in 0..m {
        let (a, b): (usize, usize) = read();
        if a == 1 {
            from1[b-1] = true;
        } else if b == n {
            ton[a-1] = true;
        }
    }

    let mut ok = false;
    for i in 1..(n-1) {
        if from1[i] && ton[i] {
            ok = true;
        }
    }
    println!("{}", if ok { "POSSIBLE" } else { "IMPOSSIBLE" })
}

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

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

const ll MOD = 1000000007;

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

    int cnt = n;
    while(1) {
        int tmp_n = cnt;
        int num = tmp_n % 10;
        tmp_n /= 10;
        if ( num != tmp_n % 10 ) {
            cnt++;
            continue;
        }
        tmp_n /= 10;
        if ( num != tmp_n % 10 ) {
            cnt++;
            continue;
        }
        break;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 384
#include <cstdio>
int N, A, B;
int main() {
	scanf("%d %d %d", &N, &A, &B);
	if (N > 1LL * A * B || A + B > N + 1) printf("-1\n");
	else {
		int cur = N, cnt = 0;
		for (int i = 0; i < A; i++) {
			int x = B;
			if (cur - x < A - i - 1) x = cur - (A - i - 1);
			for (int j = N - cur + x; j >= N - cur + 1; j--) {
				if (cnt++) printf(" ");
				printf("%d", j);
			}
			cur -= x;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100];
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=1e9;
  for(int i=-100;i<=100;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      sum+=(a[j]-i)*(a[j]-i);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++)
    cin>>b[i];
  int e=0;
  vector<int> a(m);
  for(int i=0;i<n;i++){
    int d=0;
    for(int j=0;j<m;j++){
      cin>>a[j];
      d+=a[j]*b[j];
    }
    if(d>-c)
    e++;
    }
    cout<<e;
    }
    

Measured memory_bytes: 256
//{{{ #include <bits/stdc++.h>
#ifndef __clang__
#include <bits/stdc++.h>
#endif
using namespace std; //}}}
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n)                                                              \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)                                                                \
    sort(all(c));                                                              \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) {
    return 1LL << x;
}
template <class T>
inline int size(const T &a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T> &v, const char &c) {
    return make_pair(v, c);
}
template <class T>
inline istream &operator>>(istream &is, vector<T> &v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto &x : v)
        is >> x;
    return is;
}
template <class T>
inline ostream &operator<<(ostream &os, const pair<vector<T>, char> &v) {
    bool t = 0;
    for (const T &x : v.first) {
        if (t)
            os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream &operator<<(ostream &os, vector<T> &v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} __before_main;
//}}}TEMPLATE_END

int a[110000], b[110000];
int in[110000];
int ans[110000];
vector<int> G[110000];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, n-1+m) {
        cin >> a[i] >> b[i];
        in[b[i]]++;
        G[a[i]].push_back(b[i]);
    }

    int par = -1;
    for(int i = 1; i <= n; i++){
        if(in[i] == 0) par = i;
    }

    queue<int> q;
    q.push(par);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(int w: G[v]) {
            in[w]--;
            if(in[w] != 0) continue;
            ans[w] = v;
            q.push(w);
        }
    }

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



Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			
			int r = sc.nextInt();
			int d = sc.nextInt();
			int x[] = new int[11];
			x[0] = sc.nextInt();
			
			for(int i = 1; i <= 10; i++) {
				x[i] = r * x[i-1] - d;
				System.out.println(x[i]);
			}
		}
	}
}


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

using namespace std;

int mod=1e9+7;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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

    int h,w;
    cin>>h>>w;

    char s[60][60];

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }

    for(int i=0;i<=w+1;i++){
        s[0][i]='.';
        s[h+1][i]='.';
    }

    for(int i=0;i<=h+1;i++){
        s[i][0]='.';
        s[i][w+1]='.';
    }

    bool ans=true;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                bool f=false;
                for(int k=0;k<4;k++){
                    if(s[i+dy[k]][j+dx[k]]=='#')f=true;
                }
                ans=(ans&&f);
            }
        }
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#import
#import math
#import numpy as np
#= int(input())
#= input()
W, H, N = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
A = [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

xmin = 0
xmax = W
ymin = 0
ymax = H

for obj in A:
    x = obj[0]
    y = obj[1]
    a = obj[2]

    if a == 1:
        xmin = max(x, xmin)
    elif a == 2:
        xmax = min(x, xmax)
    elif a == 3:
        ymin = max(y, ymin)
    elif a == 4:
        ymax = min(y, ymax)

x = xmax - xmin
y = ymax - ymin

if x > 0 and y > 0:
    print(x * y)
else:
    print(0)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	cin>>a;
  if(a==7||a==5||a==3)
    cout<<"YES"<<endl;
  else 
    cout<<"NO"<<endl;
 /* else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define ll              long long 
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)   
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
 
 
template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
  }
};
 
 
#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
 
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}
 
//////////////////////////////code//////////////////////////////
 
int32_t main()
{
  fast();
  
  string s;
  cin>>s;
  int n=s.size();
  
  int dp[2019]={0},temp[2019]={0};
  int ans=0;
  
  for(int i=0;i<n;i++)
  {  
    temp[s[i]-'0']++;
    
    for(int j=0;j<2019;j++)
    {
    	int curr = (j*10+s[i]-'0')%2019;
    	
    	temp[curr]+=dp[j];
    }
    
    for(int j=0;j<2019;j++)
    dp[j]=temp[j];
    
    memset(temp,0,sizeof(temp));
    
    ans+=dp[0];
    
   }
  
  cout<<ans;
  
 
}

Measured memory_bytes: 3772
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

#define int ll

signed main()
{
    int X[3];
    int K;
    for (int i = 0; i < 3; i++)
    {
        cin >> X[i];
    }
    cin >> K;
    vector<int> taste[3];
    vector<int> sum_data;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < X[i]; j++)
        {
            int tmp;
            cin >> tmp;

            taste[i].push_back(tmp);
        }
    }

    for (int i = 0; i < X[0]; i++)
    {
        for (int j = 0; j < X[1]; j++)
        {
            sum_data.push_back(taste[0][i] + taste[1][j]);
        }
    }

    sort(taste[2].begin(), taste[2].end(), greater<int>());
    sort(sum_data.begin(), sum_data.end(), greater<int>());

    priority_queue<int> ans;
    for (int i = 0; i < K; i++)
    {
        for (int j = 0; j < K; j++)
        {
            if (i >= sum_data.size() || j >= taste[2].size())
                continue;
            ans.push(sum_data[i] + taste[2][j]);
        }
    }
    for (int i = 0; i < K; i++)
    {
        cout << ans.top() << endl;
        ans.pop();
    }
}

Measured memory_bytes: 43256
days = int(input())
mat = [[0 for x in range(3)] for y in range(days)] 
a = [[0 for x in range(3)] for y in range(days)] 


for day in range(days):
    ln = input()
    ln = ln.split()
    for act in range(0,3):
        a[day][act] = int(ln[act])
        #print(mat[day][act])
        

for i in range(0,days):
    for act in range(0,3):
        if(i==0):
           mat[i][act] = a[i][act]
        else:
            if(act == 0):
                mat[i][0] = max(mat[i-1][1] + a[i][act],  mat[i-1][2] + a[i][act])
            elif(act == 1):
                mat[i][1] = max(mat[i-1][0] + a[i][act],  mat[i-1][2] + a[i][act])
            elif(act == 2):        
                mat[i][2] = max(mat[i-1][1] + a[i][act],  mat[i-1][0] + a[i][act])
        
        
pts = max(mat[days-1][0], mat[days-1][1])  
pts = max(pts, mat[days-1][2])
print(pts)

'''    
a= [int(act) for act in input().split()]
'''
    



Measured memory_bytes: 72028
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <cmath>
using namespace std; 
#define ll long long
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rep2(i,a,b) for(ll i=a;i>=b;i--)
int main(int argc, char** argv) {
	ll a,b,c;
	cin>>a>>b>>c;
	if(c>a+b&&(c-a-b)*(c-a-b)>4*a*b)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;
using int64 = long long int;

bool IsPrime(int value)
{
    int bound = (int) sqrt(value);

    for (int i = 2; i <= bound; i++)
    {
        if (value % i == 0)
        {
            return false;
        }
    }

    return true;
}

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

    for (int i = x; ; i++)
    {
        if (IsPrime(i))
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin>>n;
	int d[n];
	rep(i,n)cin>>d[i];
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1]<<endl;
	return 0;

}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int n;
    int match;
    int data[5000][4],x[1001][3]={{0}};
    int i,j;
    int hoge=0,hoge2=0;
    int cnt = 1;

    scanf("%d",&n);
    match = n*(n-1)/2;
    for(i = 1;i <= n; i++)x[i][1] = i;
    /*勝ち点決め*/
    for(i = 1;i <= match; i++){
        for(j = 0;j < 4; j++)scanf("%d",&data[i][j]);
        if(data[i][2] > data[i][3])x[data[i][0]][0] += 3;
        else if(data[i][3] > data[i][2])x[data[i][1]][0] += 3;
        else {
            x[data[i][0]][0] += 1;
            x[data[i][1]][0] += 1;
        }
    }
    /*ソート*/
    for(i = 1;i <= n; i++){
        for(j = 1;j <= n; j++){
            if(x[i][0] > x[j][0]){
               hoge = x[i][0];
               x[i][0] = x[j][0];
               x[j][0] = hoge;
               hoge2 = x[i][1];
               x[i][1] = x[j][1];
               x[j][1] = hoge2;
            }
        }
    }
    /*順位決め*/
    for(i = 1;i <= n; ){
        for(;;){
            if(x[i][0] == x[i+cnt][0]){
                cnt++;
            }
            else{
             for(j = i;j < cnt+i; j++)x[j][2] = i;
             i += cnt;
             cnt = 1;
             break;
            }
        }
    }
    /*ソート（戻す）*/
    for(i = 1;i <= n; i++){
        for(j = 1;j <= n; j++){
            if(x[i][1] < x[j][1]){
                hoge = x[i][1];
                x[i][1] = x[j][1];
                x[j][1] = hoge;
                hoge2 = x[i][2];
                x[i][2] = x[j][2];
                x[j][2] = hoge2;
            }
        }
    }
    /*出力*/
    for(i = 1;i <= n; i++)printf("%d\n",x[i][2]);
    return 0;
}

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

int main() {

    int r, D ,x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {

        x =  r * x - D;

        cout << x << endl;
    }
    


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

int main(){
  string n;
  ll dp[20][2]={};
  for(int i=0;i<20;i++)dp[i][0]=dp[i][1]=-1e9;
  dp[0][0]=0;
  cin>>n;
  for(ll i=0;i<n.size();i++){
    dp[i+1][0]=max(dp[i+1][0],dp[i][0]+n[i]-'0');
    dp[i+1][1]=max(dp[i][1]+9,dp[i+1][1]);
    dp[i+1][1]=max(dp[i+1][1],dp[i][0]+n[i]-'1');
  }
  
  cout<<max(dp[n.size()][0],dp[n.size()][1])<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL keta(LL num,LL k){
  return (num>>k) % 2;
}

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

  LL N, K;
  cin >> N >> K;

  vector<LL> A(N);

  REP(i,N){
    cin >> A[i];
  }

  vector<LL> V(53, 0);

  REP(i,N){
    REP(j,53){
      V[j] += keta(A[i], j);
    }
  }

  LL ans = 0;

  for (LL j = 52; j >= 0;--j){
    LL hoge = 1LL << j;
    if (K >= hoge)
    {
      if(V[j]<N-V[j]){
        V[j] = N - V[j];
        K -= hoge;
        ans += hoge;
      }
    }
  }

  LL sum = 0;

  REP(i,N){
    sum += A[i] ^ ans;
  }

  cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define erep(i, n) for(ll i = 0; i <= (n); i++)
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
// input
ll weight[110], value[110];
// dp table
ll dp[110][1000010];

int main(void) {
  int n, w;
  cin >> n >> w;
  rep(i, n)cin >> weight[i] >> value[i];
  rep(i, n)erep(j, w){
    if(j >= weight[i])maxs(dp[i+1][j], dp[i][j-weight[i]] + value[i]);
    maxs(dp[i+1][j],dp[i][j]);
  }
  cout << dp[n][w] << '\n';
  return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,q,t,l,r,ans;
    string s;
    char c;
    vector<set<ll>> a(26);
    cin >> n >> s >> q;

    rep(i,s.size()) a[s[i]-'a'].insert(i);
    rep(i,q){
        cin >> t;
        if(t==1){
            cin >> l >> c;
            a[s[l-1]-'a'].erase(l-1);
            a[c-'a'].insert(l-1);
            s[l-1] = c;
        }else{
            cin >> l >> r;
            ans = 0;
            rep(j,26){
                auto itr = a[j].lower_bound(l-1);
                if(itr!=a[j].end() && *itr<r) ans++;
            }
            print(ans);
        }
    }
    return 0;
}

Measured memory_bytes: 24276
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 10;
int A[N], B[N];

int main() {
	ios_base::sync_with_stdio(0);
	int a=0,b=0,n,T,cas=0;
	cin>>n;
	for(int i=0;i<n;++i) cin>>A[i];
	for(int i=0;i<n;++i) cin>>B[i];

	vector<int> v;
	int to=1;
	for(int i=1;i<=n;++i) {
		v.push_back(i);
		to*=i;
	}
	
	for(int i=1;i<=to;++i) {
		int check=1;
		for(int j=0;j<n;++j) {
			if(A[j]!=v[j]) {
				check=0;
				break;
			}
		}
		if(check) a=i;

		check=1;
		for(int j=0;j<n;++j) {
			if(B[j]!=v[j]) {
				check=0;
				break;
			}
		}
		if(check) b=i;

		if(a&&b) break;

		next_permutation(v.begin(), v.end());
	}
	cout<<abs(a-b);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() { 
    vector<int> vec(3);
    rep (i, 3) cin >> vec[i];
    if (vec[0] == vec[1] and vec[0] == vec[2]) cout << 1 << endl;
    if (vec[0] == vec[1] and vec[0] != vec[2]) cout << 2 << endl;
    if (vec[0] != vec[1] and vec[0] == vec[2]) cout << 2 << endl;
    if (vec[0] != vec[1] and vec[1] == vec[2]) cout << 2 << endl;
    if (vec[0] != vec[1] and vec[0] != vec[2] and vec[1] != vec[2]) cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
fn main(){
    let buf = getline();
    let mut pr = 700;
    for c in buf.trim().chars() {
        if c == 'o' {
            pr += 100;
        }
    }
    println!("{}", pr);
}

fn getline() -> String{
    let mut r = String::new();
    std::io::stdin().read_line(&mut r).ok();
    return r;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int n;
  scanf("%d", &n);
  printf("%d\n", (1000 - n % 1000) % 1000);
  return 0;
}

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

struct edge1 {
  int to, cost;
};
struct edge2 {
  int from, cost;
};
int main() {
  int l;
  cin>>l;
  vector<edge1> g[20];
  vector<edge2> tmp;
  int cur = 0;
  --l;
  int n_edge = 0;
  while (l > 0) {
    int cost;
    if (l % 2 == 0) {
      cost = l / 2 + 1;
      g[cur].push_back({cur+1, cost});
      g[cur].push_back({cur+1, 0});
      tmp.push_back({cur, cost - 1});
      n_edge += 3;
    } else {
      cost = (l + 1) / 2;
      g[cur].push_back({cur+1, cost});
      g[cur].push_back({cur+1, 0});
      n_edge += 2;
    }
    ++cur;
    l -= cost;
  }
  for (auto e: tmp) {
    g[e.from].push_back({cur, e.cost});
  }
  cout<<cur+1<<" "<<n_edge<<endl;
  for (int i=0; i<cur; i++) {
    for (auto e: g[i]) {
      cout<<i+1<<" "<<e.to+1<<" "<<e.cost<<endl;
    }
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d", &n);

	char s[100][101];
	int p[100];

	REP(i, n)scanf("%s%d", &s[i], &p[i]);
	int ans[100];
	REP(i, n)ans[i] = i;
	REPS(i, n - 1) {
		RFOR(j, 1, i+1) {
			if (strcmp(s[ans[j-1]], s[ans[j]]) > 0) {
				int tmp = ans[j-1];
				ans[j-1] = ans[j];
				ans[j] = tmp;
			}
			else if (strcmp(s[ans[j-1]], s[ans[j]]) == 0) {
				if (p[ans[j-1]] < p[ans[j]]) {
					int tmp = ans[j - 1];
					ans[j - 1] = ans[j];
					ans[j] = tmp;
				}
			}
			else {
				break;
			}
		}
	}
	REP(i, n) {
		PRINTD(ans[i]+1);
	}
}


Measured memory_bytes: 128
//
//  main.c
//  Kakezan
//
//  Created by x15071xx on 2016/06/16.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>

int syori (int keta,int n,int count[2],int a) {
    
    int seki[6],seki_syori=0,i,x=1,y=0,z,max=-1;
    for (i = 1; i < keta; i++) {
        x *= 10;
    }
    
    while (1) {
        
        for (i = 0; i < keta-1; i++) {
            y = n / x;
            
            z = n - (y*x);
            
            seki[seki_syori] = y*z;
            seki_syori++;
            x /= 10;
            
            
        }
        count[0]++;
        //?????§????????????n
        
        for (i=0; i<seki_syori; i++) {
            if (seki[i] > max) {
                max = seki[i];
            }
        }
        
        n = max;
        
        if (n < 10 || count[1] == 1) {
            count[1] = 1;
            break;
        } else if ((n >= 10 && n < 100)&&count[1]==0) {
            count[0] = syori(2,n,count,a);
        } else if ((n >= 100 && n < 1000)&&count[1]==0) {
            count[0] = syori(3,n,count,a);
        } else if ((n >= 1000 && n < 10000)&&count[1]==0) {
            count[0] = syori(4,n,count,a);
        } else if ((n >= 10000 && n < 100000)&&count[1]==0) {
            count[0] = syori(5,n,count,a);
        } else if ((n >= 100000 && n < 1000000)&&count[1]==0) {
            count[0] = syori(6,n,count,a);
        }
        
        if (count[1] == 1) {
            break;
        }
        
    }
    
    return *count;
}


int main(int argc, const char * argv[]) {
    
    int q,i;
    
    scanf("%d",&q);
    
    for (i=0; i<q; i++) {
        int count[2],n,inf = 0,a=0;
        count[0]=0;
        count[1]=0;
        scanf("%d",&n);
        
        if (n < 10) { //??????
            count[0] = 0;
            
        } else if (n >= 10 && n < 100) {
            count[0] = syori(2,n,count,a);
        } else if (n >= 100 && n < 1000) {
            count[0] = syori(3,n,count,a);
        } else if (n >= 1000 && n < 10000) {
            count[0] = syori(4,n,count,a);
        } else if (n >= 10000 && n < 100000) {
            count[0] = syori(5,n,count,a);
        } else if (n >= 100000 && n <= 1000000) {
            count[0] = syori(6,n,count,a);
        }
        
        if (inf==1) {
            printf("-1\n");
        } else {
            printf("%d\n",count[0]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int y=gcd(a,b);
  int cnt=0,now=y;
  int ans=0;
  while(k>cnt){
    if(y%now==0){cnt++;}
    now--;
  }
  ans = now+1;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# ITP2_9_A: Set Operation - Set Union


def union(n, m, a, b):
    i, j = 0, 0
    while i < n and j < m:
        if a[i] < b[j]:
            yield a[i]
            i += 1
        elif a[i] > b[j]:
            yield b[j]
            j += 1
        else:
            yield a[i]
            i += 1
            j += 1

    while i < n:
        yield a[i]
        i += 1
    while j < m:
        yield b[j]
        j += 1


def run():
    n = int(input())
    a = [int(i) for i in input().split()]
    m = int(input())
    b = [int(j) for j in input().split()]

    for v in union(n, m, a, b):
        print(v)


if __name__ == '__main__':
    run()



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

using namespace std;

int s,n,t,p,m;
string weekday,tim;
int enable=0;
int day(int t){
	return 1<<((t/(60*24))%7);
}
int Day = 1<<0;
int Night = 1<<1;
int zone(int t){
	if(t%(60*24)>=6*60 && t%(60*24)<18*60){
		return Day;
	}
	return Night;
}
long double f(int start){
	int cnt = 0;
	for(int i=0;i<m;i++){
		int p = start+i*t;
		int q = start+i*t+s; //[p,q]
		if(tim == "All"){
			if((q-p<60*24)
				&&((day(p)&enable)!=0)
				&&((day(q)&enable)!=0))cnt++;
		}else if(tim == "Day"){
			if((q-p)<60*12
				&&((day(p)&enable)!=0)
				&&((day(q)&enable)!=0)
				&&((zone(p)&Day)!=0)
				&&((zone(q)&Day)!=0))cnt++; 
		}else{
			if((q-p)<60*12
				&&((day(p)&enable)!=0)
				&&((day(q)&enable)!=0)
				&&((zone(p)&Night)!=0)
				&&((zone(q)&Night)!=0))cnt++; 
		}
	}
	cnt *= n;
	long double pp = ((long double)p-1.0)/(long double)p;
	return 1.0-powl(pp,cnt);
}
bool solve(){
	cin >> s >> n >> t >> weekday >> tim >> p >> m;
	if(p==0)return false;
	if(weekday == "All")enable = (1<<7)-1;
	if(weekday == "Mon")enable = (1<<0);
	if(weekday == "Tue")enable = (1<<1);
	if(weekday == "Wed")enable = (1<<2);
	if(weekday == "Thu")enable = (1<<3);
	if(weekday == "Fri")enable = (1<<4);
	if(weekday == "Sat")enable = (1<<5);
	if(weekday == "Sun")enable = (1<<6);

	long double ans = 0.0;
	for(int i=0;i<60*24*7;i++){
		ans = max(ans,f(i));
	}
	cout << fixed << setprecision(30) << ans << endl;
	return true;
}

int main(){
	while(solve()){}
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int X,Y;
  int sum;
  cin >> X >> Y;
  REP(i, X + 1){
    sum = 2 * i + 4 * (X - i);
    if(sum == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
    cout << "No" << endl;
}

Measured memory_bytes: 3624