akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==7){
		if(b==c && b==5)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(b==7){
		if(a==c && a==5)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(c==7){
		if(a==b && a==5)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let q: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let mut lrv = vec![(0usize, 0usize); q];
    for i in 0..q {
        lrv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        lrv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut tbl = vec![0usize; n];
    let cv: Vec<char> = s.chars().collect();
    for i in 1..n {
        tbl[i] = tbl[i - 1]
            + if cv[i - 1] == 'A' && cv[i] == 'C' {
                1
            } else {
                0
            };
    }

    for i in 0..q {
        println!("{}", tbl[lrv[i].1 - 1] - tbl[lrv[i].0 - 1]);
    }
}


Measured memory_bytes: 6908
program answer
  implicit none

  integer(16), allocatable :: A(:)
  integer(16) :: ans, N, i

  read(*,*) N
  allocate(A(N))
  read(*,*) (A(i), i=1,N)
  ans=1_16
 do i = 1, N
     if	(A(i)==0) then
	write(*,*) 0
      	stop
     end if
  end do

  do i = 1, N
     ans = A(i)*ans
  if (ans>10_16**18) then
      write(*,*)  -1
     stop
   end if
  end do
  write(*,*) ans

  deallocate(A)
  stop
end program answer


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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 1; i < n; i++) cin >> A[i];

  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int supervisor = A[i] - 1;
    ans[supervisor] += 1; 
  }

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


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  for (int i = 0; i < A+1; i++) {
    for (int j = 0; j < B+1; j++) {
      for (int k = 0; k < C+1; k++) {
        if (500*i + 100*j + 50*k == X) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def check(x):
    s = str(x)
    s_size = len(s)
    for pos in range(s_size // 2 + 1):
        if s[pos] != s[s_size - 1 - pos]:
            return False
    return True

ans = 0
for x in range(A, B+1):
    if check(x):
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int maxs = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

using pii = pair<int, int>;

void solve() {
	int n;
	cin >> n;
	vector<int> vp1(n), vp2(n);
	int x, y;
	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		vp1[i] = x + y;
		vp2[i] = x - y;
	}
	int dis1 = *max_element(all(vp1)) - *min_element(all(vp1));
	int dis2 = *max_element(all(vp2)) - *min_element(all(vp2));
	cout << max(dis1, dis2);
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


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

using namespace std;

int main()
{
    int N,X,Y;
    ios_base::sync_with_stdio(0);
    cin >> N >> X;
    for(int i = 2; i <= N; ++i)
    {
        cin >> Y;
        Y = __gcd(X,Y);
        X = Y;
    }
    cout << Y;
    return 0;
}


Measured memory_bytes: 256
is_chosen = [False]*9
bingo = {}
for i in range(3):
    for j, a in enumerate([int(i) for i in input().split()]):
        bingo[a] = i*3 + j

N = int(input())
for i in range(N):
    b = int(input())
    if(b in bingo):
        is_chosen[bingo[b]] = True

ans = False
for i in range(3):
    ans |= is_chosen[i] and is_chosen[3 + i] and is_chosen[6 + i]
    ans |= is_chosen[i*3] and is_chosen[i*3 + 1] and is_chosen[i*3 + 2]
ans |= is_chosen[0] and is_chosen[4] and is_chosen[8]
ans |= is_chosen[2] and is_chosen[4] and is_chosen[6]

if(ans):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#!/usr/bin/env python3
a, b = map(int, input().split())
if a > 0 and b > 0:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    if (b - a) % 2 > 0:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 9008
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int k  = sc.nextInt();
		
		int counter = 0;
		long ref = 1;
		
		while(n>=ref) {
			ref = ref*k;
			counter++;
		}

		System.out.println(counter);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 22996
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){
	char c=getchar();
	while(c<'0'||'9'<c) c=getchar();
	uint_fast32_t x=0;
	while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); }
	return x;
}

int main(void){
	long a=nextpint();
	long b=nextpint();
	long c=nextpint();
	long x = c-a-b;
	if(x<=0){
		puts("No");
	}else{
		x=x*x;
		long y=a*b*4;
		if(y<x){
			puts("Yes");
		}else{
			puts("No");
		}
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;

int main()
{
	int n,t,flag=1;
	cin>>n;
	map<int ,int> mp;
	for(int i=0;i<n;i++) {
		scanf("%d",&t);
		mp[t]++;
		if(mp[t]>1 && flag) {
			cout<<"NO\n";flag=0;
		}
	}
	if(flag) cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 9600
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (s, w) = get!(usize, usize);
    if w >= s {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	fast;
	//string s;
	vector<int> v;
	map<int,int> mp;
	int n,m,c=0,t=1;
	//cin>>t;
	while(t--){
		double sum=0;
		cin>>n>>m;
		double a[n],f;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
		}
		f=sum/(4*m);
		for(int i=0;i<n;i++){
			if(a[i]-f>=0) c++;
		}
		if(c>=m) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int count=0;
    for(int i = 1;i<=N;i++){
        if(i<10){
            count++;
        }else if(100<=i && i<1000){//10^2
            count++;
        }else if(10000<=i && i<100000){
            count++;
        }
        
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  long long sum=0;
  for(int i=0;i<n;++i)
    cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<k;++i)
    sum+=a[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class DLine {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N = 0;
	    int X = 0;
	    int Y = 0;
	    in >> N >> X >> Y;

	    vector<int> count(N + 1, 0);
	    for (int i = 1; i <= X; ++i) {
            for (int j = i + 1; j <= X; ++j) {
                ++count[j - i];
            }
            for (int j = X + 1; j <= Y; ++j) {
                const int index = min(j - i, X - i + Y - j + 1);
                ++count[index];
            }
            for (int j = Y + 1; j <= N ; ++j) {
                const int index = j - i - (Y - X) + 1;
                ++count[index];
            }
	    }
	    for (int i = X + 1; i <= Y; ++i) {
            for (int j = i + 1; j <= Y; ++j) {
                const int index = min(j - i, i - X + Y - j + 1);
                ++count[index];
            }
            for (int j = Y + 1; j <= N ; ++j) {
                const int index = min(j - i, i - X + j - Y + 1);
                ++count[index];
            }
	    }
	    for (int i = Y + 1; i < N; ++i) { // N - 1まででよい
	        for (int j = i + 1; j <= N; ++j) {
	            ++count[j - i];
	        }
	    }

	    for (int i = 1; i < N; ++i) {
	        out << count[i] << endl;
	    }
	}
};


int main() {
	DLine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main(){
  int k, x;
  cin >> k >> x;

  bool flag = false;
  rep(i, max(-1000000LL, x-k+1), min(1000000LL, x+k-1)+1){
    if(flag) cout << " ";
    cout << i;
    flag = true;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        for(int i=0;i<b;i++){
            printf("%d",a);
        }
    }else{
        for(int i=0;i<a;i++)printf("%d",b);
    }
    printf("\n");
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		Console.WriteLine(C+" "+A+" "+B);
	}
}

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

using namespace std;
using ll = long long;

const ll MOD_VAL = 1e9+7;
ll dp[22][2100000];
int adj[22][22];

int n;

ll func(int a, int b){
    if(dp[a][b] != -1) return dp[a][b];
    //b가 방문정보
    if(a==n) return 1;
    ll res = 0;
    for(int i=0;i<n;i++){
        if(adj[a][i] && (b>>i)%2==0){
            res += func(a+1, b + (1<<i));
            res %= MOD_VAL;
        }
    }
    return dp[a][b] = res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, -1, sizeof(dp));

    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>adj[i][j];
        }
    }

    cout<<func(0, 0);


    return 0;
}

Measured memory_bytes: 361216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
累積和おさえてもN^2
mapぽいんだけどどう管理するのか
5 4
1 4 2 3 5

1 0 2 3 1

1 0 2 0 1 //6

1 3 0 2 0 //3

1 1 1 1//5C2=10

Sj-Si)=j-i
Sj-j = Si-i

*/
int main(){
  ll N,K,ans=0; cin>>N>>K;
  vector<ll>A(N,0),S(N+1,0);
  map<ll,ll> M;
  for(ll i=0; i<N; i++) cin>>A[i];
  for(ll i=0; i<N; i++) S[i+1]=(S[i]+A[i]-1)%K;
  M[0]=1;
  for(ll i=1; i<=N; i++){
    if(i>=K) M[S[i-K]]--;//左端を捨てる
    ans+=M[S[i]];
//cout<<"i:"<<i<<" S[i]:"<<S[i]<<" M["<<S[i]<<"]:"<<M[S[i]]<<" ans:"<<ans<<endl;
    M[S[i]]++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include <stdio.h>

int main(){
    int n, m, a[20][20], b[20], c;
    int i, j, ans, cnt = 0;

    scanf("%d %d %d", &n, &m, &c);

    for(i=0; i<m; i++)
        scanf("%d", &b[i]);

    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }

    for(i=0; i<n; i++){
        ans = c;
        for(j=0; j<m; j++){
            ans += a[i][j] * b[j];
        }

        if(ans > 0)
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>

#define int long long

using namespace std;

class Solver {
};

signed main() {
		int n, m;
		cin >> n >> m;
		vector<tuple<int, int, int>> stes;
		while (true) {
			int s, t, e;
			cin >> s >> t >> e;
			if (s == 0)break;

			stes.emplace_back(make_tuple(s, t, e));
		}

		int l;
		cin >> l;
		for (int i = 0; i < l; i++) {
			vector<int> bs(m);
			for (int j = 0; j < m; j++) {
				cin >> bs[j];
			}
			vector<int> vals(n, 0);
			for (int j = 0; j < stes.size(); j++) {
				vals[get<0>(stes[j]) - 1]
					+= get<2>(stes[j]) * bs[get<1>(stes[j]) - 1];
			}

			for (int j = 0; j < n; j++) {
				cout << vals[j];
				if (j < n - 1)cout << ' ';
			}
			cout << endl;
		}
}


Measured memory_bytes: 4516
#参考コード
#https://atcoder.jp/contests/agc001/submissions/4594416
from collections import defaultdict,deque

N,K=map(int,input().split())
tree=[]
Graph=defaultdict(list)

for _ in range(N-1):
  edge=list(map(int,input().split()))
  Graph[edge[0]].append(edge[1])
  Graph[edge[1]].append(edge[0])
  tree.append(edge)
  
def DFSans(start,diam):
  visited=[0]*N
  q=deque()
  for s in start:
    q.append((s,0))
    visited[s-1]=1
  while q:
    search,start_diam=q.pop()
    if start_diam>=diam:
      continue
    for n in Graph[search]:
      if visited[n-1]:
        continue
      q.append((n,start_diam+1))
      visited[n-1]=1
    #print(q,visited)
  return N-sum(visited)

ans=99999999999999999999
if K%2==1:
  for i in range(N-1):
    ans=min(ans,DFSans(tree[i],(K-1)//2))
else:
  for i in range(1,N+1):
    ans=min(ans,DFSans([i],K//2))
print(ans)

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

using namespace std;

int main(){
    string N;
    long long int n = 0;
    cin >> N;
    for(int i=0;i<N.size();i++){
        n += N[i]-'0';
    }

    if(n%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3720
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string S;
	cin >> S;

	int size = S.size();

	int ans = 0;
	for (int ii = 0; ii < size; ++ii){
		for (int len = 0; len <= size - ii; ++len){
			string t = S.substr(ii, len);

			int tsize = t.size();
			bool ok = true;
			for (int jj = 0; jj < tsize; ++jj){
				if ( (t[jj]!='A') && (t[jj]!='C') &&(t[jj]!='G') &&(t[jj]!='T') ){
					ok = false;
					break;
				}
			}

			if (ok){
				ans = max(ans, tsize);
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		if(a==5&&b==5&&c==7){
			System.out.println("YES");
		}
		else if(a==5&&b==7&&c==5){
			System.out.println("YES");
		}
		else if(a==7&&b==5&&c==5){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 9428
import sys
sys.setrecursionlimit(10**6)

x = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

if x >= 30:
    print('Yes')
else:
    print('No')

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

vector <vector <int>> op;
vector <vector <int>> r;
vector <int> h;

int n;

void fel (int i, int o){

	if (r[o][i] != -1) return;

	fel(i-1,0);
	fel(i-1,1);
	fel(i-1,2);

	r[o][i] = max(r[(o+1)%3][i-1]+op[o][i], r[(o+2)%3][i-1]+op[o][i]);

	//cout << o << " " << i << endl;
	//cout << r[o][i] << endl;

	return;
}

int main (){

	cin >> n;

	op.assign(3,vector <int> (n,0));
	r.assign(3,vector <int> (n,-1));
	h.assign(n,0);

	for (int i=0; i<n; i++) cin >> op[0][i] >> op[1][i] >> op[2][i];

	r[0][0]=op[0][0];
	r[1][0]=op[1][0];
	r[2][0]=op[2][0];

	fel (n-1,0);
	fel (n-1,1);
	fel (n-1,2);

	cout << max (r[0][n-1], max (r[1][n-1], r[2][n-1])) << endl;

	return 0;
}

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

int n;
string s;
char animal[100010];

bool search(char x,char y){
  animal[0] = x;animal[1] = y;
  for(int i = 2;i < n;i++){
    if(s.at(i-1) == 'o' && animal[i-1] == 'S'){
      animal[i] = animal[i-2];
    }
    else if(s.at(i-1) == 'o' && animal[i-1] == 'W'){
      if(animal[i-2] == 'S') animal[i] = 'W';
      if(animal[i-2] == 'W') animal[i] = 'S';
    }
    else if(s.at(i-1) == 'x' && animal[i-1] == 'S'){
      if(animal[i-2] == 'S') animal[i] = 'W';
      if(animal[i-2] == 'W') animal[i] = 'S';
    }
    else if(s.at(i-1) == 'x' && animal[i-1] == 'W'){
      animal[i] = animal[i-2];
    }
  }
  bool ok = false,ok2 = false;
  if((s.at(n-1) == 'o' && animal[n-1] == 'S') || (s.at(n-1) == 'x' && animal[n-1] == 'W')){
    if(animal[0] == animal[n-2]) ok = true;
  }
  else{
    if(animal[0] != animal[n-2]) ok = true;
  }
  if((s.at(0) == 'o' && animal[0] == 'S') || (s.at(0) == 'x' && animal[0] == 'W')){
    if(animal[1] == animal[n-1]) ok2 = true;
  }
  else{
    if(animal[1] != animal[n-1]) ok2 = true;
  }
  if(ok == true && ok2 == true){
    return true;
  }
  else{
    return false;
  }
}

int main(){
  cin >> n;
  cin >> s;
  bool ok = false;
  for(int i = 0;i < 4;i++){
    if(i == 0) ok = search('S','S');
    if(i == 1) ok = search('S','W');
    if(i == 2) ok = search('W','S');
    if(i == 3) ok = search('W','W');
    if(ok == true){
      break;
    }
  }
  /*for(int i = 0;i < n;i++){
    cout << animal[i] << ' ' << i << endl;
  }*/
  if(ok == true){
    for(int i = 0;i < n;i++){
      cout << animal[i];
    }
    cout << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,k;
int main(){
  cin >> n >> k;
  cout << (n-k)+1 << endl;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t a[100000];

int main(void) {
    size_t N, M;

    scanf("%zu %zu\n", &N, &M);
    for (size_t i = 0; i < M; i++) {
        scanf("%zu", &(a[i]));
        if (i < M - 1) {
            scanf("\n");
        }
    }

    size_t dp[2];
    dp[0] = 1;
    size_t pos = 0;
    for (size_t i = 1; i <= N; i++) {
        if (i == 1) {
            if (a[pos] == i) {
                dp[1] = 0;
                pos++;
                while (true) {
                    if (pos < M - 1 && a[pos] == a[pos - 1]) {
                        pos++;
                    }
                    else {
                        break;
                    }
                }
            }
            else {
                dp[1] = 1;
            }
        }
        else {
            if (a[pos] == i) {
                dp[i%2] = 0;
                pos++;
                while (true) {
                    if (pos < M - 1 && a[pos] == a[pos - 1]) {
                        pos++;
                    }
                    else {
                        break;
                    }
                }
            }
            else {
                dp[i % 2] = (dp[0] + dp[1]) % 1000000007;
            }
        }
    }

    printf("%zu\n", dp[N%2]);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    int n, cnt = 1, last, judge = 0;
    cin >> n >> last;
    vector<int> a(n);
    rep(i,n-1){
        int x;
        cin >> x;
        if(judge == 0){
            if(last < x){
                judge = 1;
            }else if(last > x){
                judge = -1;
            }
        }else if((judge == 1 & last > x) || (judge == -1 & last < x)){
            cnt++;
            judge = 0;
        }
        last = x;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	long double N, M, vote = 0;
	cin >> N >> M;
	vector<long double> vec(N);
	rep(i, N)
	{
		cin >> vec[i];
		vote += vec[i];
	}
	long double pass = 0;
	rep(i, N)
	{
		if (vec[i] < vote / (4 * M))
		{
			//
		}
		else
		{
			pass++;
		}

	}

	if (pass < M)
	{
		cout << "No" << '\n';
	}
	else
	{
		cout << "Yes" << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
ll cal(ll a,ll b){
	if(a<b)swap(a,b);
	if(a==b)return a;
	ll k = (a-1)/b;
	return cal(a-k*b,b)+2*k*b;
}
int main()
{
	ll n,x;cin>>n>>x;
	cout << cal(n-x,x)+n << endl;
	return 0;
}


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

int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string w;
    cin>>w;
    for(int i=0;i<3;i++)
    {
        if(strcmp(&s[i][0],&w[0])==0 && i!=2){
            cout<<s[i+1];break;}
        else if(i==2){
            cout<<s[0];break;}
    }
    return 0;
}


Measured memory_bytes: 256
next (a,b,c,d,e,f,g,h,i) = (a',b',c',d',e',f',g',h',i') where
  a' = (b + c + d) `mod` 1000000007
  b' = (a + f + g) `mod` 1000000007
  c' = (b + h + i) `mod` 1000000007
  d' = (f + h + i) `mod` 1000000007
  e' = (f + 2*i) `mod` 1000000007
  f' = (a + e + f + g) `mod` 1000000007
  g' = (c + f + 2*i) `mod` 1000000007
  h' = (b + h + 2*i) `mod` 1000000007
  i' = (f + h + 2*i) `mod` 1000000007

solve n = let (a,b,c,d,e,f,g,h,i) = (!! (n - 3)) $ iterate next (1,1,1,1,1,1,1,1,1)
  in (4*a + 4*b + 2*c + d + 3*e + 12*f + 4*g + 9*h + 22*i) `mod` 1000000007
 
main = do
  n <- read <$> getLine
  print $ solve n


Measured memory_bytes: 508
sa = list(input())
sb = list(input())
sc = list(input())
turn = 0

while turn != 3:
    if turn == 0:
        if sa[0] == "a":
            turn = 0
        elif sa[0] == "b":
            turn = 1
        elif sa[0] == "c":
            turn = 2
        elif sa[0] == "x":
            turn = 3
            print("A")
            break
        sa.pop(0)
        if len(sa) == 0:
            sa.append("x")

    if turn == 1:
        if sb[0] == "a":
            turn = 0
        elif sb[0] == "b":
            turn = 1
        elif sb[0] == "c":
            turn = 2
        elif sb[0] == "x":
            turn = 3
            print("B")
            break
        sb.pop(0)
        if len(sb) == 0:
            sb.append("x")

    if turn == 2:
        if sc[0] == "a":
            turn = 0
        elif sc[0] == "b":
            turn = 1
        elif sc[0] == "c":
            turn = 2
        elif sc[0] == "x":
            turn = 3
            print("C")
            break
        sc.pop(0)
        if len(sc) == 0:
            sc.append("x")


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

int main() {
	int x = 1;
	int N, K; cin >> N >> K;
	for( int i = 0; i < N; i++ ){
		if( x > K ) x += K;
		else x *= 2;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
r = []
for i in range(1,n):
  l,u = [], []
  for j in range(n):
    if j < i:
      l.append(s[j])
    else:
      u.append(s[j])
  c = 0
  for k in l:
    if k in u:
      u = [t for t in u if t != k]
      c += 1
  r.append(c)
print(max(r))

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

int N;
vector<vector<int> > adj, chd;

void dfs(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        chd[u].push_back(v);
        dfs(v, u);
    }
}

int cc[100010];
int dp(int u) {
    int &ret = cc[u];
    if(ret != -1) return ret;

    vector<int> cnt(20, 0);
    int mask = 0;
    for(int i = 0; i < chd[u].size(); i++) {
        int v = chd[u][i];

        int nmask = dp(v);
        for(int j = 0; j < 20; j++) {
            if(nmask & (1 << j)) cnt[j]++;
        }
        mask |= nmask;
    }

    for(int i = 20; i--;) {
        if(cnt[i] > 1) {
            for(int j = i + 1; j < 20; j++) {
                if(mask & (1 << j)) continue;
                return ret = (mask | (1 << j)) & ((1 << 20) - (1 << j));
            }
        }
    }
    for(int i = 0; i < 20; i++) {
        if(mask & (1 << i)) continue;
        return ret = (mask | (1 << i)) & ((1 << 20) - (1 << i));
    }
}

int main() {
    scanf("%d", &N);
    adj.resize(N);
    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    chd.resize(N);
    dfs(0, -1);

    memset(cc, -1, sizeof(cc));
    int mask = dp(0);
    for(int i = 20; i >= 0; i--) {
        if(mask & (1 << i)) {
            printf("%d", i);
            return 0;
        }
    }
}


Measured memory_bytes: 22912
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<ll, ll> p;
typedef vector <int> VI;
typedef vector <string> VS;


int main(){

	ll n;
	cin >> n;

	VI tendiv(0);
	VI nontendiv(0);

	ll sum = 0;
	for(int i = 0; i < n; i++){
		ll tmp;
		cin >> tmp;
		sum += tmp;
		if(tmp % 10 == 0){
			tendiv.pb(tmp);
		}else{
			nontendiv.pb(tmp);
		}
	}

	ll ans = sum;
	if(sum % 10 == 0){
		if(nontendiv.size() == 0){
			ans = 0;
		}else{
			sort(all(nontendiv));
			ans -= nontendiv[0];
		}
	}

	cout << ans << endl;
	return 0;	
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector <vector <int> > students (N, vector<int>(2));
  for (int i = 0; i < N ; i++ ){
    for (int j = 0 ; j < 2 ; j++){
      cin >> students.at(i).at(j);
    }
  }
  
  vector <vector <int> > checkpoints (M, vector<int>(2));
  for (int i = 0; i < M ; i++ ){
    for (int j = 0 ; j < 2 ; j++){
      cin >> checkpoints.at(i).at(j);
    }
  }
    
  int X, Y;
  X = 999999999;
  for (int i = 0 ; i < N ; i++){
    for (int j = 0; j < M ; j++ ){
      int x = 0;
      x = abs(students[i][0] - checkpoints[j][0]) 
        + abs(students[i][1] - checkpoints[j][1]);
      if (x < X){ Y = j + 1 ; }
      X = min (x, X);
//      cout << x << " " << X << " " << Y <<endl;
    }
    cout << Y << endl;
    Y = 0;
    X = 999999999;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

long long n, k, a[2000000], mn = INF + 1;


int main()
{
    //ifstream cin ("input1.txt");
    //ifstream fin ("output1.txt");
    //ofstream cout ("output1.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(25);
    cin >> k >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i + n] = k + a[i];
    }
    for (int i = 0; i < n; i++)
    {
        mn = min(mn, a[i + n - 1] - a[i]);
    }
    cout << mn;
    //cout << mx - mn;
    return 0;
}


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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
	char c1,c2;
	cin>>c1>>c2;
	if (c1=='9' || c2=='9') cout<<"Yes"; else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}

const int mod = 1000000007;
ll qpow(ll n,ll k)
{
    ll ans=1;
    assert(k>=0);
    n%=mod;
    while(k>0)
    {
        if(k&1)
            ans=(ans*n)%mod;
        n=(n*n)%mod;
        k>>=1;
    }
    return ans%mod;
}
int ar[100009][3];
int sum[100009][3];
void run(int i, int pre, int n){
    if(i>=n) return;
    int sum1=0, sum2=0, sum3=0;
    if(pre!=0){
        if(sum[i+1][0] == -1 ) run(i+1, 0, n);
        sum1 = ar[i][pre] + sum[i+1][0];
    }
    if(pre!=1){
        if(sum[i+1][1] == -1 ) run(i+1, 1, n);
        sum2 = ar[i][pre] + sum[i+1][1];
    }
    if(pre!=2){
        if(sum[i+1][2] == -1 ) run(i+1, 2, n);
        sum3 = ar[i][pre] + sum[i+1][2];
    }
    sum[i][pre] = max(sum1, max(sum2, sum3));
}
int main()
{
    fast;
    int n, a, b, c;
    cin>>n;
    REP1(i, n){
        cin>>a>>b>>c;
        sum[i][0]= -1;
        sum[i][1]= -1;
        sum[i][2]= -1;
        ar[i][0] = a;
        ar[i][1] = b;
        ar[i][2] = c;
    }
    sum[n][0] = ar[n][0];
    sum[n][1] = ar[n][1];
    sum[n][2] = ar[n][2];
    run(1, 0, n);
    run(1, 1, n);
    run(1, 2, n);
    cout<< max(sum[1][0], max(sum[1][1], sum[1][2]) ) <<'\n';
    return 0;
}


Measured memory_bytes: 10368
fn main(){
  let n: usize = read(); 
  let mut va: Vec<u64> = read_vec();
  let mut vb: Vec<u64> = read_vec();
  let mut vc: Vec<u64> = read_vec();

  va.sort();
  vb.sort();
  vc.sort();
  
  let mut dpa: Vec<u64> = vec![0;n+1];

  for i in 0 .. n {
    dpa[i+1] = 1 +dpa[i];
  }
  
  let mut dpb: Vec<u64> = vec![0;n+1];
  let mut i: usize = 0;

  for j in 0 .. n {
    if va[i] >= vb[j] {
      dpb[j+1] = dpb[j];
      continue;
    }
    while i < n && va[i] < vb[j] { i += 1; }
    i -= 1;
    dpb[j+1] = dpb[j] + dpa[i+1];
  }
  
  let mut dpc: Vec<u64> = vec![0;n+1];
  i = 0;

  for j in 0 .. n {
    if vb[i] >= vc[j] {
      dpc[j+1] = dpc[j];
      continue;
    }
    while i < n && vb[i] < vc[j] { i += 1; }
    i -= 1;
    dpc[j+1] = dpc[j] + dpb[i+1];
  }
  
  println!("{}", dpc[n]);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
ll i,j,ans;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b, a % b);
}
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        ll aa = 0;
        scanf("%lld", &aa);
        ans = gcd(aa, ans);
    }
    printf("%lld", ans);
    return 0;
}

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

int main() {

    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int count = 0;

    rep(i, a + 1){
        rep(j, b + 1){
            rep(k, c + 1){
                if((i * 500 + j * 100 + k * 50) == x) count++;
            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 256
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
A = 'Yes'
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t_list.append(ti)
    x_list.append(xi)
    y_list.append(yi)
    if ((abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i]) > (t_list[i+1] - t_list[i]))):
        A = 'No'
        break
    if (x_list[i+1] + y_list[i+1] - t_list[i+1])%2 != 0:
        A = 'No'
        break
print(A)

Measured memory_bytes: 11796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int n = sc.nextInt();
		long[] x = new long[n];
		for(int i=0; i<n; i++) x[i] = sc.nextLong();
		long[] b = x.clone();
		Arrays.sort(x);
		long m1 = x[n/2-1];
		long m2 = x[n/2];
		PrintWriter pw = new PrintWriter(System.out);
		for(int i=0; i<n; i++) {
			if(b[i]<=m1) {
				pw.println(m2);
			} else {
				pw.println(m1);
			}
		}
		pw.close();
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 54000
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;


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

    int min_ = 99999, max_ = -1;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        min_ = min(min_, tmp);
        max_ = max(max_, tmp);
    }
    cout << max_ - min_ << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long S;
  cin>>S;
  long long N=pow(10,9);
  if (S==pow(10,18)){
      cout<<0<<" "<<0<<" "<<N<<" "<<0<<" "<<0<<" "<<N<<endl;
  }
  else{
    cout<<0<<" "<<0<<" "<<N<<" "<<1<<" "<<N-S%N<<" "<<S/N+1<<endl;
  }
}


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

using namespace std;
unsigned long long s;
int x;
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x;
    s=2;
    for(int i=1;i<=x;i++)
        s=s*2+2;
    cout << s;
    return 0;
}

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

int main() {
  int s1s2s3, a, b, c;
  cin >> s1s2s3;
  a = s1s2s3 % 2;
  b = (s1s2s3 - a) / 10 % 2;
  c = (s1s2s3 - a - b * 10) / 100;
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

string s;

void input() {
  cin >> s;
}

void solve() {
  string ans = "ABC";

  if (s == "ABC")
    ans = "ARC";

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3660
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


signed main(){
	int a;
	cin>>a;
	if(a==25)cout<<"Christmas"<<endl;
	if(a==24)cout<<"Christmas Eve"<<endl;
	if(a==23)cout<<"Christmas Eve Eve"<<endl;
	if(a==22)cout<<"Christmas Eve Eve Eve"<<endl;
	
}


















Measured memory_bytes: 256
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


N = int(input())
X = LIHW(N-1)

for i in range(N-1):
    time = [0]*N
    time[i] = X[i][1]+X[i][0]
    for j in range(i+1, N-1):
        if time[j-1] <= X[j][1]:
            time[j] = X[j][1]+X[j][0]
        else:
            if (time[j-1]-X[j][1]) % X[j][2] == 0:
                time[j] = time[j-1] + X[j][0]
            else:
                time[j] = time[j-1] + X[j][0]+X[j][2] - \
                    ((time[j-1]-X[j][1]) % X[j][2])
    print(time[j])
print(0)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int a,b,c;
void solve()
{
    cin>>a>>b>>c;
    if(c<a+b)
    {
        cout<<"No";
        return;
    }
    int VT=4*a*b;
    int VP=(c-a-b)*(c-a-b);
    if(VT<VP)cout<<"Yes";
    else cout<<"No";
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("STRWC.inp","r",stdin);
    //freopen("STRWC.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
s=input()
k=int(input())
i_=-1
for i in range(len(s)):
	if int(s[i])>1:
		i_=i
		break
if i_!=-1:
	if k-1<i_: 
	    print(1)
	else: 
	    print(int(s[i_]))
else:
    print(1)

Measured memory_bytes: 3060
N,K=map(int,input().split())
ans={}
for i in range(N):
    a,b=map(int,input().split())
    if a in ans:ans[a]+=b
    else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
for key,value in ans:
    K-=value
    if K<=0:break
print(key)

Measured memory_bytes: 15076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n]; int dp[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=1;i<n;i++)
    dp[i]=INT_MAX;
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
        if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
    }
  }
  cout<<dp[n-1];
  return 0;
}


Measured memory_bytes: 1024