akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string ans, b = "";

	int n;
	cin >> n >> ans;


	int now = 0;
	for (int i = 0; i < n; i++) {
		if (ans[i] == '(')
			now++;
		else
			now--;
		if (now < 0) {
			b += '(';
			now++;
		}
	}
	while (now > 0) {
		ans += ')';
		now--;
	}
	b += ans;
	ans = b;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a,b;
    bool B = true;
    bool B2 = true;
    int cnt = 0;
    vector<int> x(n); vector<int> y(n);
    for(int i=0;i<n;i++)cin >> x[i];
    for(int i=0;i<n;i++)cin >> y[i];
    vector<int> v(n);
    for(int i=0;i<n;i++)v[i] = i+1;
   do{
       cnt++;
       for(int i=0;i<n;i++){
           if(!(v[i] == x[i]))B = false;
           if(!(v[i] == y[i]))B2 = false;
       }
       if(B)a = cnt;
       if(B2)b = cnt;
       B = true;
       B2 = true;
   }while(next_permutation(v.begin(),v.end()));
   cout << abs(a-b) << endl;
}

Measured memory_bytes: 3628
n, m = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
#値段が安い順から買うのが効率的なので、安い順に並び替え
a.sort(key=lambda cost: cost[0])

ans = 0
count = 0
for v in a:
  ans += v[0] * v[1]
  count += v[1]
  if count > m:
    while True:
      count -= 1
      ans -= v[0]
      if count == m:
        break
  if count == m:
    break

print(ans)



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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50
#define PI 3.141592653589793238462643383279502884197169

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a/g * b; //prevent overflow
}

/////////////////////////  END OF TEMPLATE ////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    while(n--)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto x: mp)
    {
        int sum = x.second;
        if(mp.count(x.first-1))
        {
            sum += mp[x.first-1];
        }
        if(mp.count(x.first+1))
        {
            sum += mp[x.first+1];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6408
n = int(input())
lis = list(map(int, input().split()))
ans = 1

flag = 1

for i in lis:
    ans *= i
    if ans > 10**18:
        flag = -1
        break

if 0 in lis:
    flag = 2

if flag == 1:
    print(ans)
elif flag == 2:
    print(0)
else:
    print(-1)

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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define trav(a,x) for(auto& a: x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()

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

int main(){
	ll n,maxi=0;cin>>n;
	ll root = sqrt(n);
	rep(i,1,root+1){
		if(n%i==0){
			maxi = max(i,maxi);
		}
	}
	ll n_steps=0;
	n_steps = maxi-1+(n/maxi)-1;
	cout<<n_steps;
}

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

int main(){
  int n;
  cin >> n;
  vector<string>st(n);
  int ans=1;
  
  for(int i=0;i<n;i++){
    cin >> st.at(i);
  }
  sort(st.begin(),st.end());
  for(int i=1;i<n;i++){
    if(st.at(i)!=st.at(i-1)){
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 9600
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = &[
                $((
                    &stringify!($arg).to_string() as &fmt::Debug,
                    &($arg) as &fmt::Debug,
                )),*
            ];
            eprintln!("{:?}", DebugMap(entries));
        }
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let S = rl();

    let mut d = 0;
    let mut k = 0;
    for c in S.chars() {
        if c == 'S' {
            d += 1;
        } else {
            if d <= 0 {
                k += 1;
            } else {
                d -= 1;
            }
        }
    }
    k += d;
    println!("{}", k);
    return;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
 
ll calc(int x,int y,int m){
  ll res=1;
  rep(i,y){
    res=res*x%m;
  }
  return res%m;
}
 
int main(){
  int const mod=1e9+7;
  int n;
  cin>>n;
  ll ten=calc(10,n,mod);
  ll nine=calc(9,n,mod);
  ll eight=calc(8,n,mod);
  ll ans=(ten-nine)%mod;
  ans=(ans-nine)%mod;
  ans=(ans+eight)%mod;
  ans=(ans+mod)%mod;
  cout<<ans<<endl;
  return 0;
}

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

int main(void){
  int n,m;
  int ans[4],zero,flg;
  
  cin >> n >> m;
  for (int i=0; i<4; i++) ans[i] = -1;
  flg=1;
  for (int i=0; i<m; i++){
    int s,c; cin >> s >> c;
    if (ans[s-1]!=-1 && ans[s-1]!=c){ // 矛盾したクエリ
      flg=0;
      break;
    } else {
      ans[s-1]=c;
    }
  }
  if (n!=1 && ans[0]==0) flg=0; // top dig. is 0
  if (!flg){
    cout << -1 << endl;
  } else {
    if (ans[0]==-1 && n!=1) ans[0]=1;
    for (int i=0; i<n; i++){
      cout << (ans[i]==-1?0:ans[i]);
    }
    cout << endl;
  }
  return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;
 
int main (){
  int w,h,n;
  int x1,y1,x2,y2;
  cin >> w >> h >> n;

  x1=y1=0;
  x2=w;
  y2=h;
  
  rep(i,0,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1 && x>x1){
      x1=x;
    }
    else if(a==2 && x<x2){
      x2=x;
    }
    else if(a==3 && y>y1){
      y1=y;
    }
    else if(a==4 && y<y2){
      y2=y;
    }
  }
  if(x2<x1 || y2<y1) printf("0\n");
  else pout((x2-x1)*(y2-y1));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	string S;
	unsigned long long K;
	cin >> S >> K;

	for (auto i = 0; i < S.length(); ++i)
	{
		if (S[i] != '1')
		{
			cout << S[i] << endl;
			break;
		}
		else if(i >= K - 1)
		{
			cout << S[i] << endl;
			break;
		}
	}

	return 0;
}


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

signed main()
{
    long long n;
    long long a,b;
    long long cnt;
    long long rem;

	cin >> n >> a >> b;
    cnt = 0;
    cnt += (n / (a + b)) * a;
    rem = n % (a + b);
    cnt += min(rem, a);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
lis_AC = []
lis_WA = []
for i in range(M):
    p,s = input().split()
    if s == "AC":
        lis_AC.append(p)
    else:
        if p not in lis_AC:
            lis_WA.append(p)
lis_AC = set(lis_AC)
cnt_WA = 0
for i in lis_WA:
    if i in lis_AC:
        cnt_WA += 1

print(len(lis_AC), end = " ")
print(cnt_WA)

Measured memory_bytes: 22304
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vi x(n), y(n);
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    
    int min1 =  - x[0] - y[0], min2 = y[0] - x[0];
    int min3 = x[0] - y[0], min4 = x[0] + y[0]; 
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans = max({ans,  - x[i] - y[i] - min1, - x[i] + y[i] - min2, x[i] - y[i] - min3, x[i] + y[i] - min4});
        min1 = min(min1, - x[i] - y[i]);
        min2 = min(min2, - x[i] + y[i]);
        min3 = min(min3,  x[i] - y[i]);
        min4 = min(min4,  x[i] + y[i]);
    }
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


Measured memory_bytes: 4732
use proconio::input;

fn main(){
    input! {
        n : usize,
        c : i128,
        x : [i128; n]
    };
    let mut s = vec![0; n+1];
    for i in 0..n { s[i+1] = s[i] + x[i]; }
    let mut res = 1 << 120;
    for i in 1..=n {
        let mut cur = (n+i) as i128 * c;
        for j in 0..=n {
            if i*j >= n { break }
            let src = n - j*i;
            let dst = if src >= i { src - i } else { 0 };
            cur += (s[src] - s[dst]) * std::cmp::max(5, 2*j+3) as i128;
        }
        res = std::cmp::min(res, cur);
    }
    println!("{}", res);
}

Measured memory_bytes: 10164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c;
			c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 25760
#include <iostream>
#include <string>
#include <set>

using namespace std;

string str;

bool check(int k){
	int count[256] = {0}, d = 0;
	count['a'] = count['z'+1] = 1;
	for(int i=0; i<str.length(); i++){
		if( !count[ str[i] + ((k&(1<<i))?1:0) ]++ )
			d |= (1<<i);
	}
	return k == d;
}

int main(){
	while(cin >> str, str[0] != '#'){
		set<string> ans;
		set<string>::iterator it;
		for(int k=0; k<(1<<str.length()); k++){
			if( check(k) ){
				string str2 = str;
				for(int l=0; l<str.length(); l++){
					if( k & (1<<l) && str[l] != 'z' ){
						str2[l]++;
					}
				}
				ans.insert( str2 );
			}
		}
		// ??????
		cout << ans.size() << endl;
		if( ans.size() <= 10 ){
			for(it = ans.begin(); it != ans.end(); it++)
				cout << *it << endl;
		}else{
			int count = 0;
			for(it = ans.begin(); count < 5; it++, count++)
				cout << *it << endl;
			for(it = ans.end(); count > 0; it--, count--){}
			for(; count < 5; it++, count++)
				cout << *it << endl;
		}
	}
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int x = 1, c = 0;
  for(int i=0; i<n; i++) {
    c++;
    if(v[x-1] == 2) break;
    x = v[x-1];
  }
  if(c == n) cout << -1 << endl;
  else cout << c << endl;
}

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,a[100005],ans=0; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	forn(i,n)
	{
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<1e5;i++)
		ans=max(ans,a[i]+a[i-1]+a[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
import sys
N, Y = map(int, raw_input().split())
for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        if i * 10000 + j * 5000 + k * 1000 == Y:
            print i, j, k
            sys.exit()
print "-1 -1 -1"


Measured memory_bytes: 2692
function Main(input){
  var inputs = input.split("\n");
  var array = inputs[1].split(" ");
var N = inputs[0]-1;
  var sum = 0;
var i;
  for(i = 0;i <= N;i++){
    sum = sum + new Number(array[i]);
 }
  var plo;
  for(j = 0;j <= N;j++){
    if(plo == undefined){
      plo =new Number(array[j]);
    }
    plo = plo*new Number(array[j]);
  }
  var mom = 0;
  for(k = 0;k <= N;k++){
    mom = mom + plo/new Number(array[k]);
  }
  console.log(plo/mom);
  }
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
#! /usr/bin/python3

import numpy as np

n = int(input())
a = list(map(int, input().split()))
s = np.cumsum(a)

t = 1
ans1 = 0
u = 0

for i in range(n):
    x = s[i] + u
    if t * x <= 0:
        ans1 += abs(x) + 1
        if t == 1:
            u += abs(x) + 1
        else:
            u -= abs(x) + 1
    t *= -1

t = -1
ans2 = 0
u = 0

for i in range(n):
    x = s[i] + u
    if t * x <= 0:
        ans2 += abs(x) + 1
        if t == 1:
            u += abs(x) + 1
        else:
            u -= abs(x) + 1
    t *= -1

print(min(ans1, ans2))

Measured memory_bytes: 25308
def main():
	n = input()
	p = map(int, raw_input().split())
	p.sort()

	lia = []
	lib = []
	if(n % 2 == 0):
		for i in range(0,n,2):
			if(p[i] != p[i+1]):
				print 0
				return
			if(p[i] != i+1):
				print 0
				return
			lia.append(p[i])
			lib.append(p[i+1])
	else:
		for i in range(1, n, 2):
			if(p[i] != p[i+1]):
				print 0
				return
			if(p[i] != i+1):
				print 0
				return
			lia.append(p[i])
			lib.append(p[i+1])

	print 2**(n/2) % (10**9 + 7)

if __name__ == "__main__":
	main()

Measured memory_bytes: 11328
#include <stdio.h>
 
int main () {
	int a[3][3];
	int count = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	int n, m, b[3][3];
	scanf("%d", &n);
	for ( int i = 0; i < n; i++) {
		scanf("%d", &m);
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == m) {
					b[i][j] = 1;
				}
			}
		}
	}
	
	if (b[0][0]+ b[1][1]+ b[2][2] == 3 || b[0][2]+ b[1][1]+ b[2][0] == 3) {
      printf("Yes\n");
      return 0;
    }
	
	for(int i = 0; i < 3; i++) {
      if(b[i][0]+ b[i][1]+ b[i][2] == 3 || b[0][i]+ b[1][i]+ b[2][i] == 3) {
        printf("Yes\n");
        return 0;
       }
    }
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 1604
fn main(){
    proconio::input!{
        n: u64,
        k: u64,
    }
    let mut sunuke = Vec::new();
    for i in 0..k{
        proconio::input!{
            mut d: u64,
        }
        for l in 0..d{
            proconio::input!{
                mut a: u64
            }
            sunuke.push(a);
        }
    }
    sunuke.sort();
    sunuke.dedup();
    println!("{}", n - sunuke.len() as u64);
}

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

using namespace std;

int main()
{
  long long n,a,b,d,r,ans;
  
  cin >> n >> a >> b;
  
  d = n/(a+b);
  r = n%(a+b);
  
  ans = d*a;
  if(r>a)ans+=a;
  else ans+=r;
  
  cout << ans;
  
}

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

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

	int a[n], b[n];
	vector<pair<long long,int>> sum(n);
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		sum[i] = make_pair(a[i]+b[i],i);
	}

	sort(sum.begin(), sum.end());

	long long ans = 0;

	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			ans += a[sum[n-1-i].second];
		}else{
			ans -= b[sum[n-1-i].second];
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	long long ans=0;
	long long maxx=0;
	for(int i=1;i<=n;i++){
		long long x;
		scanf("%lld",&x);
		maxx=max(maxx,x);
		ans+=maxx-x;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3820
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll k; cin >> k;
    if (k%2==0) {
        cout << "-1" << endl;
        return 0;
    }

    ll p = 1;
    ll r = 0;
    int ans = 0;
    rep(i,10010010) {
        ++ans;
        r += (7*p)%k;
        r %= k;
        if (r == 0) {
            cout << ans << endl;
            return 0;
        }
        p = (p*10)%k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int
  var a,b []int
  n = NextInt()
  a = NextIntArray()
  b = make([]int,2)
  for i:=0;i<n;i++ {
    b[a[i]%2]++
  }
  if b[1]%2 == 0 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const LL mod=1000000007;

LL modinv(LL x){
	LL k=mod, u=1, v=0;
	while(k){
		LL t=x/k;
		x-=t*k; swap(x,k);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

int main(){
	LL n, k;
	cin >> n >> k;
	LL dp[200010];
    LL ans[200010];
	rep(i,n) ans[i]=0;
	ans[0]=1; ans[1]=n*(n-1);
	LL Cn[200010];
	LL Cn1[200010];
	Cn[0]=1; Cn[1]=n;
	for(LL i=2; i<200010; i++){
		Cn[i]=Cn[i-1]*(n-i+1);
        Cn[i]%=mod;
        Cn[i]*=modinv(i);
        Cn[i]%=mod;
	}
	Cn1[0]=1; Cn1[1]=n-1;
	for(LL i=2; i<200010; i++){
		Cn1[i]=Cn1[i-1]*(n-i);
        Cn1[i]%=mod;
        Cn1[i]*=modinv(i);
        Cn1[i]%=mod;
	}
	LL sum[200010];
	rep(i,n) sum[i]=0;
    sum[0]=1;
	for(int i=1; i<n; i++){
		sum[i]=sum[i-1]+Cn[i]*Cn1[n-i-1];
		sum[i]%=mod;
	}
	if(k<n) cout << sum[k] << endl;
	else cout << sum[n-1] << endl;

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=505;
int s[N],t[N];
bool visr[N],visc[N];
ull a[N][N],u[N],v[N],b[N],c[N];
int n;
int main()
{
    ull one=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&s[i]);
    for(int i=1;i<=n;i++) scanf("%d",&t[i]);
    for(int i=1;i<=n;i++) scanf("%llu",&u[i]);
    for(int i=1;i<=n;i++) scanf("%llu",&v[i]);
    for(ull k=0;k<64;k++)
    {
        memset(visr,false,sizeof(visr));
        memset(visc,false,sizeof(visc));
        vector<int>r,c;
        for(int i=1;i<=n;i++)
        {
            if(s[i]==0) r.push_back(i);
            if(t[i]==0) c.push_back(i);
        }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
        {
            if(s[i]==0&&(u[i]>>k&1)||t[j]==0&&(v[j]>>k&1)||s[i]==1&&(u[i]>>k&1)&&t[j]==1&&(v[j]>>k&1)&&!(visr[i]&&visc[j]))
                a[i][j]|=one<<k,visr[i]=visc[j]=true;
        }
        bool f1=false,f2=false;
        int p1=0,p2=0;
        for(int i=1;i<=n;i++)
            if((u[i]>>k&1)&&s[i]==1&&!visr[i]&&c.size())
        {
            f1=true;
            a[i][c[p2]]|=one<<k;
            p2++;if(p2==c.size()) p2=0;
        }
        for(int i=1;i<=n;i++)
            if((v[i]>>k&1)&&t[i]==1&&!visc[i]&&r.size())
        {
            f2=true;
            a[r[p1]][i]|=one<<k;
            p1++;if(p1==r.size()) p1=0;
        }
        assert(!(f1&&f2));
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        if(s[i]) b[i]|=a[i][j];
        else b[i]&=a[i][j];
        if(t[j]) c[j]|=a[i][j];
        else c[j]&=a[i][j];
        if(j==1) b[i]=a[i][j];
        if(i==1) c[j]=a[i][j];
    }
    for(int i=1;i<=n;i++)
        if(u[i]!=b[i]||v[i]!=c[i])
    {
        printf("-1\n");return 0;
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        printf(j==n?"%llu\n":"%llu ",a[i][j]);
}


Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
constexpr ll INF = 1LL<<60;

int main() {
    string s;
    cin >> s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> d(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> d.at(i).at(j);
    }
  }
  vector<int> h(H, 0);
  vector<int> w(W, 0);
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (d.at(i).at(j) == '#') {
        h.at(i)=1;
        w.at(j)=1;
      }
    }
  }
  for (int i=0; i<H; i++) 
    if ( h.at(i)==1 ) {
      for (int j=0; j<W; j++) 
        if ( w.at(j)==1 ) cout << d.at(i).at(j);
      cout << endl;
    }
}


Measured memory_bytes: 256
// Written by Kuji on 2020-05-10-18.35.32
#include<bits/stdc++.h>
#define ll long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define forr(i,a,b) for(ll i=a;i>=b;i--)
#define forit(it,x) for (auto it=(x).begin();it!=(x).end(); it++)
#define fi first
#define se second
#define sll set<ll>
#define vll vector<ll>
#define msl map<string,ll>
using namespace std;
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    string s,s1,s2;
    cin>>s>>s1;
    s2=s1.substr(0,s1.length()-1);
    if(s==s2)
        cout<<"Yes\n";
    else
        cout<<"No\n";


}



Measured memory_bytes: 3652
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long x = saori.saorihayami();
		long y = 100;
		int n = 0;
		while(x > y){
			y *= 1.01;
			n++;
		}
		System.out.println(n);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32308
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
using namespace std;


int main(){
    int h1, h2, m1, m2, k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int dh = (h2 - h1)*60; // 起きている時間（分）
    int dm = m2 - m1;
    int d = dh + dm;
	
    if(d - k <= 0){
        cout << 0 << endl;
    } else {
        cout << d-k << endl;
    }
}

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

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

    while(X > 0){
        if(X % 100 >= 5) X -= 105;
        else X -= (100 + X%10);
    }

    if(X == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
typedef long long ll;

int main(void) {
  ll i, n;
  scanf("%lld", &n);
  ll d[n];
  for(i = 0; i < n; ++i) scanf("%lld", &d[i]);
  std::sort(d, d + n);
  printf("%lld", d[n / 2] - d[n / 2 - 1]);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int dp[101][10001];

int main()
{
	int N, W;
	cin >> N >> W;
	int v[101], w[101];
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i <= W; i++) dp[0][i] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}


Measured memory_bytes: 7000
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
 int key;
 Node *right,*left,*parent;
 };
 
 Node *root,*NIL;
 
 Node * find(Node *u,int k){
 while(u!=NIL && k!=u->key){
 if(k<u->key) u=u->left;
 else u= u->right;
 }
 return u;
 }
 
 void insert(int k){
Node *y=NIL;
 Node *x=root;
 Node *z;
 
 z=(Node *)malloc(sizeof(Node));
 z->key=k;
 z->left=NIL;
 z->right=NIL;
 
 while(x!=NIL){
 y=x;
 if(z->key < x->key){
 x=x->left;
 }else{
 x=x->right;
 }
 }
 
 z->parent=y;
 if(y==NIL){
 root=z;
 }else{
 if(z->key < y->key){
 y->left=z;
 }else{
  y->right=z;
 }
 }
 }
 
 void inorder(Node *u){
  if(u==NIL) return;
 inorder(u->left);
 printf(" %d",u->key);
 inorder(u->right);
 }
 void preorder(Node *u){
  if(u==NIL) return;
 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);
}
 
 int main(){
 int n,i,x;
 string com;
 
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
 cin >> com;
 if(com[0]=='f'){
 scanf("%d",&x);
 Node *t=find(root,x);
 if(t!=NIL) printf("yes\n");
 else printf("no\n");
 }else if(com=="insert"){
  scanf("%d",&x);
  insert(x);
  }else if(com=="print"){
  inorder(root);
  printf("\n");
   preorder(root);
  printf("\n");
  }
  }
  
  return 0;
  }
  


Measured memory_bytes: 21924
deck = [[0] * 13 for i in range(4)]
n = input()

for i in range(0, n) :
    suit, num = raw_input().split(" ")
    if (suit == "S") :
        deck[0][int(num)-1] = 1
    if (suit == "H") :
        deck[1][int(num)-1] = 1
    if (suit == "C") :
        deck[2][int(num)-1] = 1
    if (suit == "D") :
        deck[3][int(num)-1] = 1

for i in range(0, 4) :
    for j in range(0, 13) :
        if (deck[i][j] == 0) :
            if (i == 0) :
                print("S %s" % str(j+1))
            if (i == 1) :
                print("H %s" % str(j+1))
            if (i == 2) :
                print("C %s" % str(j+1))
            if (i == 3) :
                print("D %s" % str(j+1))

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(n);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for(int i=0;i<n;i++){
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
	public:
		//'rank' is the hight of union find tree 
		//'p' is the pointer of parent
		vector<int> rank,p;

		//constructor
		DisjointSet(){}
		DisjointSet(int size){
			rank.resize(size,0);
			p.resize(size,0);
			for(int i=0; i<size; i++) makeSet(i);
		}

		//make union find tree
		void makeSet(int x){
			p[x] = x;
			rank[x] = 0;
		}

		//check whether the root of x is the same as that of y
		bool same(int x, int y){
			return findSet(x) == findSet(y);
		}

		//unite two tree
		void unite(int x, int y){
			link(findSet(x),findSet(y));
		}
		void link(int x, int y){
			if(rank[x] > rank[y]){
				p[y] = x;
			} else{
				p[x] = y;
				if ( rank[x] == rank[y] ){
					rank[y]++;
				}
			}
		}

	//travel the parents of tree recursivily to find root 
	int findSet(int x){
		if(x != p[x]){
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
	
};

int main(){
	int n, a, b, q;
	int t;

	cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	for(int i=0; i<q; i++){
		cin >> t >> a >> b;
		if(t==0)ds.unite(a,b);
		else if(t==1){
			if (ds.same(a,b)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  string r = s;
  reverse(ALL(r));
  int n = s.size();
  int K;
  cin>>K;
  vector<vector<vecint>> dp(n+1, vector<vecint>(n+1, vecint(K+1, 0)));
  REP(i,n)REP(j,n)REP(k,K+1) {
    //cerr << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
    if (s[i] == r[j]) {
      dp[i+1][j+1][k] = max(dp[i+1][j+1][k], 1 + dp[i][j][k]);
    }
    if (k<K) {
      dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1], 1 + dp[i][j][k]);
    }
    dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
    dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
    dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k]);
  }
  int mx = 0;
  REP(i,n)REP(j,n) {
    if (i+j > n) break;
    mx = max(mx, dp[i][j][K]*2+(n-(i+j))%2);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 110336
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2


fun main(args: Array<String>) {
    val (SA, SB) = readString().split(' ')
    val A = SA.toBigDecimal()  // [0, 1e15]
    //val B = SB.toDouble()  // [0.00, 9.99]
    val B = SB.toBigDecimal()

    if (A==0.toBigDecimal() || B==0.toBigDecimal()) {
        println(0)
        return
    }

    val ans = A * B

    println(ans.toLong())
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	if(A==1) A+=13;
	if(B==1) B+=13;
	if(A==B) cout<<"Draw"<<endl;
	else if(A>B) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> inline void read(T &x){
	x=0;ll f=1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-f;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=x*10+ch-48;
		ch=getchar();
	}
	x=x*f;
}
int main(){
	int t;
	cin>>t;
	bool ok=true;
	for(int i=1;i<=t;i++)
	{
		if(floor((double)i*1.08)==t)
		{
			ok=false;
			cout<<i;
			break;
		}
	}
	if(ok) cout<<":(";
	return 0;
} 


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

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

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
			cnt++;
			i += 2;
		}
        if (i == N - 3) break;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc080/tasks/abc080_c

n = int(input())

shops = []
for _ in range(n):
    s = [int(i) for i in input().split()]
    shops.append(s)

profits = []
for _ in range(n):
    p = [int(i) for i in input().split()]
    profits.append(p)

ans = -1 * float('inf')
for i in range(1, 2 ** 10):
    revenue = 0
    for j in range(n):
        c = 0
        s = shops[j]
        for k in range(10):
            if s[k] and (i >> k) & 1:
                c += 1
        revenue += profits[j][c]
    ans = max(ans, revenue)
print(ans)

Measured memory_bytes: 73984
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	A := nextInt()
	B := nextInt()
	C := nextInt()
	K := nextInt()
	cnt := 0
	for B <= A && cnt <= K {
		B *= 2
		cnt++
	}
	for C <= B && cnt <= K {
		C *= 2
		cnt++
	}
	log.Println(A, B, C)
	if cnt <= K {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  int q; cin >> q;
  int cnt = 0;
  string s1 = "";
  string s2 = "";
  rep(i, q){
    int t; cin >> t;
    if(t == 1) cnt++;
    else{
      int f;
      char c;
      cin >> f >> c;
      if(f==1 && cnt%2 == 0) s1 = c + s1;
      else if(f==1 && cnt%2 == 1) s2 = s2 + c;
      else if(f==2 && cnt%2 == 0) s2 = s2 + c;
      else if(f==2 && cnt%2 == 1) s1 = c + s1;
    }
  }

  s = s1 + s;
  s = s + s2;
  if(cnt%2 == 1) reverse(all(s));

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 1392
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No";

	cin>>n;
	cin>>m;

	ll maxi=n*4;
	ll mini=n*2;
	if(m%2==1){
		print("No");
		return;
	}
	if(mini<=m&&m<=maxi) sres="Yes";
	print(sres);
	return;
}

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


Measured memory_bytes: 3656
n = int(input())
v = list(map(int, input().split()))

res = v.copy()

for i in range(n):
    if i == 0:
        pass
    else:
        for j in range(i):
            if res[j] > v[i]:
                res.pop(i)
                res.insert(j, v[i])
                break

    print(" ".join([str(x) for x in res]))


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vl a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vl as(n+1), bs(m+1);
  as[0] = 0, bs[0] = 0;
  rep(i,n) as[i+1] = as[i] + a[i];
  rep(i,m) bs[i+1] = bs[i] + b[i];
  int ans = 0;
  if(sz(as) < sz(bs)) swap(as,bs);
  rep(i,max(n,m)+1) {
    if(as[i] > k) continue;
    int l = k - as[i];
    auto it = upper_bound(all(bs),l);
    it--;
    int tmp = i + (it - bs.begin());
    chmax(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int N = in.nextInt();
        	String str = "No";
        	loop: for(int i = 0; i < 100; i++) {
    			if(4 * i == N) {
    				str = "Yes";
    				break loop;
    			}
        		for(int j = 0; j < 100; j++) {
        			if(4 * i + 7 * j == N) {
        				str = "Yes";
        				break loop;
        			}
        		}
        	}
        	out.println(str);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        return static_cast<T>(facts[k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p] * factinv[q-p] % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};


int main() {
    Factorial<int> f(200001, MOD);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    for (int i = 0; i < h-a; ++i) {
        ans = (ans + (ll)f.C(b-1+i, i) * f.C(w+h-b-i-2, w-b-1))% MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3328
# coding: utf-8
def call(n):
    for i in range(1, n+1):
        x = i
        if x % 3 == 0:
            print(" " + str(i),end="")
            continue
        while x != 0:
            if x % 10 ==3:
                print(" " + str(i),end="")
                break
            x = x // 10
    print()
            
num = int(input())
call(num)


Measured memory_bytes: 5884