akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }

 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
const int INF = 1 << 30;

typedef long long int64;

int main(){
  int D, N;
  cin >> D >> N;
  vector< int > T(D);
  cin >> T;
  vector< int > A(N), B(N), C(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  // dp[i][j]: i - 1日目にjの服を着た時の派手さの差の絶対値の最大値
  vector< vector< int > > dp( D, vector< int >( N, -1));
  for(int i = 0; i < N; i++){ // 1日目に着る服
    if(A[i] <= T[0] && T[0] <= B[i]) dp[0][i] = 0;
  }
  for(int i = 1; i < D; i++){ // 日数
    for(int j = 0; j < N; j++){ // 前日に着た服
      if(dp[i - 1][j] == -1) continue;
      for(int k = 0; k < N; k++){ // 今日着る服
        if(A[k] <= T[i] && T[i] <= B[k] ) dp[i][k] = max( dp[i][k], dp[i - 1][j] + abs(C[j] - C[k]));
      }
    }
  }
  int ret = 0;
  for(int i = 0; i < N; i++){
    ret = max( ret, dp[D - 1][i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1348
import itertools
N,K=map(int,input().split())
XY=[list(map(int,input().split())) for i in range(N)]
ans=float("inf")

for xv in itertools.combinations( [xy[0] for xy in XY] ,2):
  for yv in itertools.combinations( [xy[1] for xy in XY] ,2):
    xmax=max(xv[0],xv[1])
    xmin=min(xv[0],xv[1])
    ymax=max(yv[0],yv[1])
    ymin=min(yv[0],yv[1])

    k=0
    for xy in XY:
      x,y=xy[0],xy[1]
      if xmin<=x and x<=xmax:
        if ymin<=y and y<=ymax:
          k+=1    
    if k>=K:
      ans=min(ans,(xmax-xmin)*(ymax-ymin))
print(ans)

Measured memory_bytes: 50908
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;
using ll = long long;

const ll INF = 1LL << 50;
const int MAX_V = 200000;

ll minw[110][MAX_V + 1];

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

    fill(minw[0], minw[1], INF);
    minw[0][0] = 0;

    for (int i = 1; i <= N; ++i) {
        memcpy(minw[i], minw[i - 1], sizeof(minw[i]));

        ll w;
        int v;
        cin >> w >> v;
        for (int sv = 0; sv + v <= MAX_V; ++sv) {
            minw[i][v + sv] = min(minw[i][v + sv], minw[i - 1][sv] + w);
        }
    }

    for (int v = MAX_V; v >= 0; --v) {
        if (minw[N][v] <= W) {
            cout << v << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 160000
/*
─────────▄▄▄▄▄▄▄▄▄▄▄▄─────────
─────▄▄▀▀░░░░░░░░░░░░▀▀▄▄─────
───▄▀░░░░░░░░░░░░░░░░░░░░▀▄───
──█░░░░░▄▄▄▄▄░░░░▄▄▄▄▄░░░░░█──
─█░░░░░██░█░██▄▄██░█░██░░░░░█─
█░░░░░░░▀▀▀▀▀░░░░▀▀▀▀▀░░░░░░░█
█░░░░▄▄▄░░░░░░░░░░░░░░▄▄▄░░░░█
█░░░░██▀█▄▄▄▄▄▄▄▄▄▄▄▄██▀█░░░░█
─█░░░▀██▄████████▄▄▄▄██▄▀░░░█─
──█░░░░▀██▀▀▀▀████████▀░░░░█──
───▀▄░░░░▀▄▄▄▄██████▀░░░░▄▀───
─────▀▀▄▄░░░░░░░░░░░░▄▄▀▀─────
─────────▀▀▀▀▀▀▀▀▀▀▀▀─────────
*/
#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9 + 7;

int mul(int a, int b) {
	return int(1ll * a * b % mod);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(2 * n);
	for (int i = 0; i < 2 * n; ++i) {
		a[i] = (s[i] == 'B');
	}
	int ans = 1, cnt = 0;
	for (int i = 0; i < 2 * n; ++i) {
		if ((cnt & 1) != a[i]) {
			++cnt;
		}
		else {
			ans = mul(ans, cnt--);

		}
	}
	if (cnt != 0) {
		ans = 0;
	}
	for (int i = 1; i <= n; ++i) {
		ans = mul(ans, i);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	ll l,r;
	ll count[N];
	count[0] = 0;
	reps(i,n-1){
		count[i] = count[i-1];
		if(s[i-1] == 'A' && s[i] == 'C'){
			count[i]++;
		}
	}
	rep(i,q){
		cin>>l>>r;l--;r--;
		cout<<count[r] - count[l]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1792
class Node():
    def __init__(self, parent=-1, child=[]):
        self.parent = parent
        self.child = child


def node_depth(u, id):
    if u[id].parent == -1:
        return 0
    else:
        return node_depth(u, u[id].parent) + 1


def node_type(u, id):
    if u[id].parent == -1:
        return "root"
    elif u[id].child == []:
        return "leaf"
    else:
        return "internal node"


def main():
    n = int(input())
    u = [Node() for _ in range(n)]

    for _ in range(n):
        id, _, *child = (int(x) for x in input().split())
        u[id].child = child
        for c in child:
            u[c].parent = id

    for id in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}".
              format(id, u[id].parent,
                     node_depth(u, id), node_type(u, id),
                     u[id].child))


main()



Measured memory_bytes: 38212
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct UnionFind {
    n: usize,
    root: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> Self {
        let root = (0..n).collect();
        let rank = vec![0; n];
        let size = vec![1; n];
        Self {
            n,
            root,
            rank,
            size,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        if self.root[x] == x {
            x
        } else {
            let root = self.find(self.root[x]);
            self.root[x] = root;
            root
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) {
        if x >= self.n || y >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root == y_root {
            return;
        }
        if self.rank[x_root] < self.rank[y_root] {
            self.root[x_root] = y_root;
            self.size[y_root] += self.size[x_root];
        } else {
            self.root[y_root] = x_root;
            self.size[x_root] += self.size[y_root];
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[x_root] += 1;
            }
        }
    }

    pub fn size(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        self.size[x_root]
    }

    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        if x >= self.n || y >= self.n {
            panic!();
        }
        self.find(x) == self.find(y)
    }
}

fn solve() {
    input! {
        n: usize, m: usize, k: usize,
        abv: [(Usize1, Usize1); m],
        cdv: [(Usize1, Usize1); k]
    };

    let mut friend_relations = UnionFind::new(n);
    let mut friends = vec![0; n];
    for (a, b) in abv {
        friend_relations.unite(a, b);
        friends[a] += 1;
        friends[b] += 1;
    }
    let mut blocks = vec![Vec::new(); n];
    for (c, d) in cdv {
        blocks[c].push(d);
        blocks[d].push(c);
    }
    let res = (0..n)
        .map(|u| {
            let all = friend_relations.size(u) - 1;
            let mut res = all - friends[u];
            for &b in &blocks[u] {
                if friend_relations.is_same(u, b) {
                    res -= 1;
                }
            }
            res
        })
        .join(" ");
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 13688
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(a)
ans = 0
for i in range(n):
    x = 0
    y = 0
    for j in range(i):
        if a[i] > a[j]:
            x += 1
    for j in range(n):
        if a[i] > b[j]:
            y += 1
    ans += y*((1+k)*k//2) - x*k
    ans %= (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 9304
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
#define mp make_pair
typedef long long ll;
using namespace std;

vector<pair<int, int> > graph[301];
ll dist[301][301][2];

void dijkstra(int start, int l){
	priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >, greater<pair<pair<int, int>, int> > > que;
	que.push(mp(mp(0, 0), start));
	dist[start][start][0] = 0;
	dist[start][start][1] = 0;

	while(!que.empty()){
		int q_num = que.top().first.first, q_used = que.top().first.second, q_to = que.top().second;
		que.pop();
		if (dist[start][q_to][0] < q_num || (dist[start][q_to][0] == q_num && dist[start][q_to][1] < q_used)) continue;

		for (auto x : graph[q_to]){
			if (l - q_used < x.second){
				if (dist[start][x.first][0] > dist[start][q_to][0] + 1 || (dist[start][x.first][0] == dist[start][q_to][0] + 1 && dist[start][x.first][1] > x.second)){
					dist[start][x.first][0] = dist[start][q_to][0] + 1;
					dist[start][x.first][1] = x.second;
					que.push(mp(mp(dist[start][q_to][0] + 1, x.second), x.first));
				}
			}else{
				if (dist[start][x.first][0] > dist[start][q_to][0] || (dist[start][x.first][0] == dist[start][q_to][0] && dist[start][x.first][1] > q_used + x.second)){
					dist[start][x.first][0] = dist[start][q_to][0];
					dist[start][x.first][1] = q_used + x.second;
					que.push(mp(mp(dist[start][q_to][0], q_used + x.second), x.first));
				}
			}
		}
	}
	return;	
}

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		if (l < c) continue;
		graph[a].push_back(mp(b, c));
		graph[b].push_back(mp(a, c));
	}
	for (int i = 0; i <= 300; i++){
		for (int j = 0; j <= 300; j++){
			dist[i][j][0] = 1000000000000000000;
		}
	}
	for (int i = 1; i <= n; i++) dijkstra(i, l);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++){
		int s, t;
		cin >> s >> t;

		if (dist[s][t][0] == 1000000000000000000){
			cout << -1 << endl;
			continue;
		}
		cout << dist[s][t][0] << endl;
	}
	return 0;
}


Measured memory_bytes: 6600
N, A, B, C, D = map(int, input().split())
S = input()

S = S[min(A, B)-1:max(C, D)]
if "##" in S:
    print("No")
else:
    if "..." in S:
        S_b = S[B-2:min(D+1, N)]
        if "..." in S_b:
            print("Yes")
        else:
            print("No")
    else:
        if C < D:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 3572
#include <stdio.h>

char s[10001], a[100], x;

int main()
{	 
	int n, i;
		
	scanf("%d", &n);
	x = 65 + (n < 26 ? n : 0);
	for(i = 65; i < 91; i++, x++){
		if(x == 91) x = 65;
		a[i] = x;
	}
	scanf("%s", s);
	for(i = 0; s[i]; i++) putchar(a[s[i]]);
	puts("");
		
	return 0;
}

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

int main()
{
	int n,m;
	while(cin >> n >> m){
		if(n==0 && m==0)
			break;
		int taro[100],hana[100],t=0,h=0;
		for(int i=0;i<n;i++){
			cin >> taro[i];
			t+= taro[i];
		}
		for(int j=0;j<m;j++){
			cin >> hana[j];
			h+= hana[j];
		}
		sort(taro,taro+n);
		sort(hana,hana+m);
		bool flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(t-taro[i]+hana[j] == h-hana[j]+taro[i] && flag){
					cout << taro[i] << " " << hana[j] << endl;
					flag = false;
				}
			}
			if(flag==false)
				break;
		}
		if(flag)
			cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

a, b = LI()
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 9032
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Ans = 0
for i in range(N):
    Ans += min(A[i]+A[i+1], B[i])
    A[i+1] = max(0, A[i+1] + min(A[i]-B[i], 0))

print(Ans)


Measured memory_bytes: 18476
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int a,b;
  cin >> a >> b;
  string s[100];
  for(int i=0; i<100; i++){
    for(int j=0; j<100; j++){
      if(i<50) s[i].push_back('.');
      else s[i].push_back('#');
    }
  }
  int cnt = 0;
  for(int i=0; i<50; i+=2){
    if(cnt == b-1) break;
    for(int j=0; j<100; j+=2){
      if(cnt == b-1) break;
      s[i][j] = '#';
      cnt++;
    }
  }
  cnt = 0;
  for(int i=51; i<100; i+=2){
    if(cnt == a-1) break;
    for(int j=0; j<100; j+=2){
      if(cnt == a-1) break;
      s[i][j] = '.';
      cnt++;
    }
  }
  cout << 100 << " " << 100 << endl;
  for(int i=0; i<100; i++){
    cout << s[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := 0
	for i:= 0; i < 2; i++ {
		if a > b {
			ans += a
			a -= 1
		} else {
			ans += b
			b -= 1
		}
	}
	fmt.Println(ans)
}

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

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

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

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

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

vll row,column;
vector< vector<char> > a;
ll ans=0,h,w,k;

vll decToBinary(int n)
{
    vll binaryNum(6);
  
    // counter for binary array 
    int i = 0;
    while (n > 0) { 
  
        // storing remainder in binary array 
        binaryNum[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
    return binaryNum;
}

int main(int argc, char const *argv[])
{
	//ios_base::sync_with_stdio(false);cin.tie(NULL);
    
	ll te=1,test,i,j,n,m,flag,p,temp,kb;
	//cin>>te;
	for(test=1;test<=te;test++)
	{
		cin>>h>>w>>k;
		a=vector<vector<char>> (h, vector<char> (w));
		fore(i,h)
		{
			fore(j,w)
			cin>>a[i][j];
		}
		
		kb=(1<<h);p=(1<<w);
		ll bla,ans=0;
		fore(i,kb)
		{
			fore(j,p)
			{
				vll bini=decToBinary(i);
				vll binj=decToBinary(j);
				//pvec(flag,bini);
				//pvec(flag,binj);
				bla=0;
				for(n=(h-1);n>=0;n--)
				{
					for(m=(w-1);m>=0;m--)
					{
						if(bini[n]==1 && binj[m]==1 && a[n][m]=='#')
						{
							bla++;
						}
					}
				}

				if(bla==k)
					ans++;
			}
		}

		cout<<ans<<"\n";
		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>

int main(void)
{
	int n, i;
	
	while (scanf("%d", &n) != EOF){
		for (i = 1; i <= 512; i *= 2){
			if (n % (i * 2) != 0){
				printf("%d", i);
				n -= i;
				if (n != 0){
					printf(" ");
				}
			}
			
		}
		printf("\n");
	}
	
	return (0);
}

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

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

	ostringstream oss;
	oss << str[0] << str.size() - 2 << str[str.size() - 1];
	cout << oss.str() << endl;
	return 0;
}

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

int main(){
    int N;
    scanf("%d",&N);
    int* arr=(int*)malloc(sizeof(int)*N);
    for(int i=0;i<N;i++){
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<N;i++){
        int tmp=arr[i];
        int j=i-1;
        while(j>=0 && arr[j]>tmp){
            arr[j+1]=arr[j];
            j--;
        }
        arr[j+1]=tmp;
        for(int k=0;k<N;k++){
            if(k==N-1){
                printf("%d\n",arr[k]);
            }
            else{
                printf("%d ",arr[k]);
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
void solver() {
  int n, k;
  cin >> n >> k;

  vector<double> pk(n);
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    pk[i] = (double)((1.0 + p) / 2.0);
  }

  for (int i = 1; i < n; i++) {
    pk[i] = pk[i - 1] + pk[i];
  }

  double ans = pk[k - 1];
  for (int i = 1; i < n - k + 1; i++) {
    ans = max(ans, pk[i + k - 1] - pk[i-1]);
  }

  std::cout << std::fixed;
  cout << setprecision(20) << ans << "\n";
}

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


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

int main() {
   long long N,X,M;
   cin >> N >> X >> M;
   set<int> S;
   vector<long long> A;
   int size=0,cycle;
   A.push_back(X);
   size++;
   while (!S.count(A[size-1])) {
       S.insert(A[size-1]);
       long long B=(A[size-1]*A[size-1])%M;
       //cout << B << endl;
       A.push_back(B);
       size++;
   }
   vector<long long> B;
   long long count=0;
   for (int i=0; i<size; i++) {
       if (A[i]==A[size-1]) {
           cycle=size-1-i;
           for (int j=i+1; j<size; j++) {
               B.push_back(A[j]);
           }
           break;
       }
   }
   long long C=0;
   for (int i=0; i<cycle; i++) C+=B[i];
   for (int i=0; i<size; i++) {
       count+=A[i];
       //cout << A[i] << endl;
       N--;
       if (N==0) break;
   }
   count+=(N/cycle)*C;
   for (int i=0; i<N%cycle; i++) count+=B[i];
   cout << count << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), m = in();
    vstr a = in(n), b = in(m);

    rep(i, n - m + 1) rep(j, n - m + 1)
    {
        bool ok = true;
        rep(k, m)
        {
            rep(l, m)
            {
                if (a[k + i][l + j] != b[k][l])
                {
                    ok = false;
                    break;
                }
            }
            if (!ok)
                break;
        }
        if (ok)
        {
            Yes;
            return;
        }
    }
    No;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
 
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
 
ll dp[101][4][4];
 
int main() {
  int n, m;
  cin >> n >> m;
  int y[100] = {};
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    y[a - 1] = b;
  }
 
  rep(i, 1, 4) rep(j, 1, 4) {
    int a = y[0] ? y[0] : i, b = y[1] ? y[1] : j;
    dp[1][b][a] = 1;
  }
 
  rep(i, 2, n) rep(j, 1, 4) rep(k, 1, 4){
    if(y[i]) {
      if(!(y[i] == j && j == k)) dp[i][y[i]][j] += dp[i - 1][j][k];
      dp[i][y[i]][j] %= 10000;
      continue;
    }
    rep(l, 1, 4) if(!(j == k && k == l)) dp[i][j][k] += dp[i - 1][k][l];
    dp[i][j][k] %= 10000;
  }
 
  ll ans = 0;
  rep(i, 1, 4) rep(j, 1, 4) ans += dp[n - 1][i][j];
  cout << ans % 10000 << endl;
}

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

int main() {
  string S;
  cin >> S;
  int res = 0;
  int i = 0, j = S.size() - 1;
  while (i < j) {
    if (S[i] != S[j]) {
      res++;
    }
    i++;
    j--;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
      string[] h_w = Console.ReadLine().Split(' ');
      int h = int.Parse(h_w[0]);int w =int.Parse( h_w[1]);
      string result = "";
      string[] masu = new string[h];
      for(int i = 0; i < h; i++)
      {
        masu[i] = Console.ReadLine();
      }
      for(int ih = 0; ih < h; ih++)
      {
        result = "";
        for(int iw = 0; iw < w; iw++)
        {
          int k = 0;
          for(int ih_searcharea = ih - 1; ih_searcharea <= ih + 1; ih_searcharea++)
          {
            for(int iw_searcharea = iw - 1; iw_searcharea <= iw + 1; iw_searcharea++)
            {
              if (ih_searcharea >= 0 && iw_searcharea >= 0 && ih_searcharea < h && iw_searcharea < w)
              {
                if (masu[ih_searcharea][iw_searcharea] == '#') k++;
              }
            }
          }
          if (masu[ih][iw] == '.') result += k;
          else result += '#';
        }
        Console.WriteLine(result);
      }		
	}
}

Measured memory_bytes: 13140
while true
    w, h = gets.chomp.split.map(&:to_i)
    break if [w, h] == [0, 0]
    start = gets.chomp.split.map{|x| x.to_i - 1}
    goal = gets.chomp.split.map{|x| x.to_i - 1}
    map = Array.new(h){"." * w}
    n = gets.to_i
    n.times{
        c, d, x, y = gets.chomp.split.map(&:to_i)
        addx, addy = 4, 2
        if d == 1
            addx, addy = 2, 4
        end
        for tempy in 0...addy
            map[tempy + y - 1][x - 1, addx] = c.to_s * addx
        end
    }

    result = "NG"
    color = map[start[1]][start[0]]
    if color != "."
        list = [start]
        until list.empty?
            px, py = list.pop
            map[py][px] = "0"
            if [px, py] == goal
                result = "OK"
                break
            end
            list << [px + 1, py] if px < w - 1 && map[py][px + 1] == color
            list << [px - 1, py] if px >     0 && map[py][px - 1] == color
            list << [px, py + 1] if py < h - 1 && map[py + 1][px] == color
            list << [px, py - 1] if py >     0 && map[py - 1][px] == color
        end
    end
    puts result
end


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

int main(){
	long long x;
	cin >> x;
	long long n = 100;
	long long cnt =0;
	while(n < x){
		n = (long long)(1.01 * n);
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int b[n+1];//记录第i中的个数
	bool flag[n+1];//记录第i中是否有红球 
	for(int i = 1; i <=n; i++)
	{
		b[i]=1;
		flag[i]=false;
	 } 
	 flag[1]=true;
	int count = 1;
	for(int i = 0; i < m; i++)
	{
		int x,y;
		cin>>x>>y;
		b[x]--;
		b[y]++; 
		if(flag[x])//x中有红球 
		{
			if(b[x])//拿出去之后还有 
			{
				if(flag[y]==false)
				{
					count++;
					flag[y]=true;
				}
			}
			else//没有时 
			{
				count--; 
				if(flag[y]==false) 
				{
					count++;
					flag[y]=true; 
				} 
				flag[x]=false;
			}
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define MAX 1e9
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
#define MOD 1000000007

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  rep(i,N){cin>>A[i];}
  sort(A.begin(),A.end());
  int ans=0;
  rep(i,K){ans+=A[i];}
  cout<<ans;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    sort(l.begin(),l.end());
    rep(b,n){
        int r = b+1;
        rep(a,b){
            int ab = l[a]+l[b];
            while(r < n && l[r] < ab)r++;
            int l = b+1;
            ans += max(0,r-l);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
ll a,b,k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>k;
	set<int> s;
	FOR(i,a,a+k){
		s.insert(i);
		if(i>b)break;
		pri(i);
	}
	FOR(i,b-k+1,b+1){
		if(i<a)continue;
		if(s.count(i)!=1)pri(i);
	}
	return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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





ll n;


int F(ll a, ll b){
    int digita = 0;
    int digitb = 0;
    
    while(a>0){
        digita++;
        a /= 10;
    }
    
    while(b>0){
        digitb++;
        b /= 10;
    }
    
    return max(digita,digitb);
    
}

void input(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> n;
    
    
     
}





void solve(){
    
    
    ll sqrtn = sqrt(n) + 1;
    
    int ans = 1000;
    
    for (int i = 1; i < sqrtn; i++) {
        if(n%i==0) ans = min(F(i,n/i),ans);
    }
    
    cout << ans << endl;
    
    
    
    
    
    
}





signed main() {
    
    input();
    solve();
    return 0;
}



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

int main() {
    int n,a[200010] = {0},hoge;
    bool flag = true;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1])flag = false;
    }
    if(flag) cout << "YES"<<endl;
    else cout << "NO"<<endl;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename Tp>
Tp CeilDiv(Tp _dividend, long long _divider) {
    return static_cast<Tp>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<int> arr(n);
    loop(n) {
        cin >> arr[i];
    }
    vector<int> buy;
    vector<int> sale;
    for (int i = 0; i < n;) {
        if (sz(buy) == sz(sale)) {
            for (int j = i + 1; j < n; ++j) {
                if (arr[j] > arr[j - 1]) {
                    buy.push_back(arr[j - 1]);
                    i = j;
                    break;
                }
            }
            if (sz(buy) == sz(sale)) {
                break;
            }
        } else {
            for (int j = i + 1; j < n; ++j) {
                if (arr[j] < arr[j - 1]) {
                    sale.push_back(arr[j - 1]);
                    i = j;
                    break;
                }
            }
            if (sz(sale) < sz(buy)) {
                sale.push_back(arr.back());
                break;
            }
        }
    }
    ll sum = 1000;
    loop(sz(sale)) {
        if (buy[i] <= sale[i]) {
            ll d = sum / buy[i];
            sum %= buy[i];
            sum += sale[i] * d;
        } else {
            break;
        }
    }
    cout << sum << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b && b==c) cout << "No" << endl;
  else if (a==b || b==c || c==a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 5e2+5;
int S[N][N], A[N][N], B[N][N], n, m;
char c[N];
int main(){
    scanf("%d %d", &n, &m);
    for(int i=0;i<n;i++){
        scanf("%s", c);
        for(int j=0;j<m;j++){
            if(c[j]=='#') S[i][j] = 1;
        }
    }
    for(int i=0;i<n;i++) A[i][0] = B[i][m-1] = 1;
    for(int i=0;i<n;i+=2) for(int j=0;j<m-1;j++) A[i][j] = 1;
    for(int i=1;i<n;i+=2) for(int j=m-1;j;j--) B[i][j] = 1;
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(S[i][j]){
        if(i&1) A[i][j] = 1;
        else B[i][j] = 1;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(A[i][j]) printf("#");
            else printf(".");
        }
        puts("");
    }
    puts("");
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(B[i][j]) printf("#");
            else printf(".");
        }
        puts("");
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
long long int n,k,ans=0;
int l[100];
int main()
{
	cin>>k>>n;
	for(int i=1;i<=k;i++)
	{
		cin>>l[i];
	}
	sort(l+1,l+1+k);
	for(int i=k;i>=k-n+1;i--)
	{
		ans=ans+l[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    char s[100];
    int k;

    scanf("%d", &k);
    scanf("%s", &s);

    if (k >= strlen(s)){
        printf("%s", s);
    }else if (k<strlen(s)){
    s[k]='\0';
    printf("%s...", s);
    }

}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi=acos(-1);
#define x  first
#define y  second
#define read(n,a) for(int i=0;i<n;i++)cin>>a[i];
#define rep(i,z,n)for(int i=z;i<n;i++)

ll a[200002]={};
//int b[1000002]={};
ll n,m;

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<!n;
    }
    return 0;
}


Measured memory_bytes: 3632
n,k=map(int,input().split())

d={}
for i in range(n):
  a,b=map(int,input().split())
  if a in d:
    d[a]+=b
  else:
    d[a]=b

d_keys=sorted(d.keys())
cnt=0
for i in d_keys:
  cnt+=d[i]
  if cnt>=k:
    print(i)
    exit()

Measured memory_bytes: 10592
#include<iostream>

using namespace std;

int main()
{
	int n,m,k,i,j;
	int map[20][20];
	
	for(;;)
	{
		cin >> n >> m ;
		if(n==0 && m==0)
			break;
		
		cin >> k ;
		
		for(i=0;i<20;i++)
			for(j=0;j<20;j++)
				map[i][j]=1;
		
		for(i=0;i<k;i++)
		{
			int x,y;
			cin >> x >> y ;
			x--;
			y--;
			map[x][y]=-1;
		}
		
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				if(map[i][j]==-1)
				{
					map[i][j]=0;
				}
				else if(i==0 && j!=0)
				{
					if(map[i][j-1]==0)
						map[i][j]=0;
				}
				else if(i!=0 && j==0)
				{
					if(map[i-1][j]==0)
						map[i][j]=0;
				}
				else if(i!=0 && j!=0)
				{
					map[i][j]=map[i-1][j]+map[i][j-1];
				}
			}
		}
		cout << map[n-1][m-1] << endl;
	}
}

Measured memory_bytes: 0
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	char str[N];
	
	void main()
	{
		string A,B;cin>>A>>B;int a=qread(),b=qread();
		string now;cin>>now;if(A==now)a--;else b--;write1(a),write2(b);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
string s;
string s1 = " ',.!?',.!?',.!?";
string s2 = " abcABCabcABCabcABC";
string s3 = " defDEFdefDEFdefDEF";
string s4 = " ghiGHIghiGHIghiGHI";
string s5 = " jklJKLjklJKLjklJKL";
string s6 = " mnoMNOmnoMNOmnoMNO";
string s7 = " pqrsPQRSpqrsPQRSpqrtPQRS";
string s8 = " tuvTUVtuvTUVtuvTUV";
string s9 = " wxyzWXYZwxyzWXYZwxyzWZYZ";
 
int main(void){
 
  while( cin >> s ){
 
    int cnt = 0;
 
    for( int i = 0 ; i < s.size() ; i++ ){
      if( s[i] == '1' ){
    for( int j = i ; s[j] == '1' ; j++ , i++ ) cnt++;
    cout << s1[cnt];
    i--;
      }
      else if( s[i] == '2' ){
    for( int j = i ; s[j] == '2' ; j++ , i++ ) cnt++;
    cout << s2[cnt];
    i--;
      }
      else if( s[i] == '3' ){
    for( int j = i ; s[j] == '3' ; j++ , i++ ) cnt++;
    cout << s3[cnt];
    i--;
      }
      else if( s[i] == '4' ){
    for( int j = i ; s[j] == '4' ; j++ , i++ ) cnt++;
    cout << s4[cnt];
    i--;
      }
      else if( s[i] == '5' ){
    for( int j = i ; s[j] == '5'; j++ , i++ ) cnt++;
    cout << s5[cnt];
    i--;
      }
      else if( s[i] == '6' ){
    for( int j = i ; s[j] == '6'; j++ , i++ ) cnt++;
    cout << s6[cnt];
    i--;
      }
      else if( s[i] == '7' ){
    for( int j = i ; s[j] == '7' ; j++ , i++ ) cnt++;
    cout << s7[cnt];
    i--;
      }
      else if( s[i] == '8' ){
    for( int j = i ; s[j] == '8' ; j++ , i++ ) cnt++;
    cout << s8[cnt];
    i--;
      }
      else if( s[i] == '9' ){
    for( int j = i ; s[j] == '9' ; j++ , i++ ) cnt++;
    cout << s9[cnt];
    i--;
      }
      else if( s[i] == '0' && s[i + 1] == '0' && s[i + 2] == '0' ){
    cout << "  ";
    i += 2;
      }
      else if( s[i] == '0' && s[i + 1] == '0' ){
    cout << " ";
    i++;
      }
      cnt = 0;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  if (A + B > C + D) {
    printf("Left");
  } else if (A + B == C + D) {
    printf("Balanced");
  } else {
    printf("Right");
  }
}


Measured memory_bytes: 256
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
for i in range(N):
    dt = t[i + 1] - t[i]
    dst = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if (dt < dst) or (dt % 2 != dst % 2):
        print("No")
        break
else:
    print("Yes")

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;

int main() {
	int N, M; cin >> N >> M;
	vector<int> S(N), T(M);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> T[i];
	}

	vector<vector<ll>> acm(N + 1, vector<ll>(M + 1));

	ll ans = 1;

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			acm[i+1][j+1] = (acm[i][j+1] + acm[i+1][j] - acm[i][j]) % MOD;
			if (acm[i+1][j+1] < 0) acm[i+1][j+1] += MOD;

			if (S[i] == T[j]) {
				ll val = acm[i][j] + 1;
				if (val >= MOD) val -= MOD;
				acm[i+1][j+1] = (acm[i+1][j+1] + val) % MOD;
				ans = (ans + val) % MOD;
			}
		}
	}

	cout << ans << endl;


	return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  ll n; cin >> n;
  ll flag = 0;
  rep(i, n) 
  {
    ll a;
    cin >> a;
    if(a % 2 == 1) flag++;
  }
  if(flag % 2 == 1) fin("NO");
  fin("YES");
}
//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
s = int(input())


nums = set([s])
n = 2
prev = s
while True:
    ai = None
    if prev % 2 == 0:
        ai = int(prev / 2)
    else:
        ai = 3 * prev + 1
    if ai in nums:
        break
    else:
        nums.add(ai)
        prev = ai
        n += 1

print(n)


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

int N, H;
int a[100000];
int b[100000];

int main(int argc, char *args[]) {
	int counter = 0;
	cin >> N >> H;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + N);
	sort(b, b + N);
	int a_max = a[N - 1];
	for (int i = N - 1; i >= 0; i--) {
		if (a_max >= b[i])
			break;
		counter = counter + 1;
		H = H - b[i];
		if (H <= 0)
			break;
	}

	if (H > 0) {
		counter += (H + a_max - 1) / a_max;
	}

	cout << counter << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int n;
   cin >> n;
   if(n == 1){
      cout << "Hello World" << endl;
   }
   else{
      int a, b;
      cin >> a >> b;
      cout << a + b << endl;
   }

   return 0;
}

Measured memory_bytes: 256