akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    string a;
    cin >> a;
    string b;
    cin >> b;
    string c;
    cin >> c;
    char next = 'a';
    intl ia = 0;
    intl ib = 0;
    intl ic = 0;
    while(true){
        if(next == 'a'){
            next = a[ia];
            if(ia == a.length()){
                cout << 'A' << endl;
                break;
            }
            ia++;
        }
        else if(next == 'b'){
            next = b[ib];
            if(ib == b.length()){
                cout << 'B' << endl;
                break;
            }
            ib++;
        }
        else if(next == 'c'){
            next = c[ic];
            if(ic == c.length()){
                cout << 'C' << endl;
                break;
            }
            ic++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int n;
  int odd = 0;
  scanf("%d", &n);
  while (n--) {
    int x;
    scanf("%d", &x);
    if (x % 2) odd++;
  }
  if (odd % 2 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int a = fs.nextInt(), b = fs.nextInt(), c = fs.nextInt();
		int d = fs.nextInt(), e = fs.nextInt(), f = fs.nextInt();
		
		if(a>b) {
			int t = a;
			a = b;
			b = t;
		}
		if(c>d) {
			int t = c;
			c = d;
			d = t;
		}
		
		//水の入れ方
		TreeSet<Integer> ws = new TreeSet<>();
		int war[] = new int[3010];
		war[0]=1;
		for(int i=0;i<3005;i++) {
			if(i-100*a>=0) {
				if(war[i-100*a]==1) {
					war[i]=1;
					ws.add(i);
				}
			}
			if(i-100*b>=0) {
				if(war[i-100*b]==1) {
					war[i]=1;
					ws.add(i);
				}
			}
		}
		
		//砂糖の入れ方
		TreeSet<Integer> ss = new TreeSet<>();
		int sar[] = new int[3010];
		sar[0]=1;
		ss.add(0);
		for(int i=0;i<3005;i++) {
			if(i-c>=0) {
				if(sar[i-c]==1) {
					sar[i]=1;
					ss.add(i);
				}
			}
			if(i-d>=0) {
				if(sar[i-d]==1) {
					sar[i]=1;
					ss.add(i);
				}
			}
		}
		
		int total = 0;
		int sugar = 0;
		double con = 0;
		
		for(int water:ws) {
			int slim = water/100*e;
			int rem = f - water;
			if(rem < 0)continue;
			slim = Math.min(slim, rem);
			if(ss.floor(slim)==null)continue;
			int smax = ss.floor(slim); 
			double tcon = (double)100*smax/(water + smax);
			if(tcon >= con) {
				con = tcon;
				total = water + smax;
				sugar = smax;
			}
		}
		System.out.println(total + " " + sugar);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 22848
s = input()
ans = len(s)
for i in range(26):
    c0 = chr(ord('a')+i)
    tmp = 0
    ma = 0
    for c in s:
        if c==c0:
            ma = max(ma, tmp)
            tmp = 0
        else:
            tmp += 1
    ma = max(ma, tmp)
    ans = min(ans, ma)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    static Scanner sc=new Scanner(System.in);
    static Main app=new Main();
    void sub(int ans){    
        System.out.println(ansd(ans)+" "+ansu(ans));    
    }
    public static int ansd(int temp){
        int ans=0;
        for(int i=2;i<temp;i++){
            boolean judge=true;
            for(int j=2;j<i;j++){
                if(i%j==0){
                    judge=false;
                    break;
                }
            }if(judge) ans=i;
        }
        return ans;
    }
    public static int ansu(int temp){
        boolean finish=true;
        temp++;
        while(finish){
            boolean judge=true;
            for(int i=2;i<temp;i++){
                if(temp%i==0){
                    judge=false;
                    break;
                }
            }
            if(judge){
                finish=false;
            }else{
                temp++;
            }
        }
        return temp;
    }
    public static void main(String[] args) {
        while(sc.hasNextInt())app.sub(sc.nextInt());
    }
}

Measured memory_bytes: 19068
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

P = True
B = False
lenP = lambda x: 2*x + 1
lenB = lambda x: 2*x + 2
lenS = lambda x: 2*x + 3

def main():
  n, x = map(int, input().split())
  _next = lambda burger: [B] + burger + [P] + burger + [B]
  burger = [P]
  Pn = {0:1}
  Bn = {0:0}
  Sn = {0:1}
  for i in range(n):
    Pn[i+1] = lenP(Pn[i])
    Bn[i+1] = lenB(Bn[i])
    Sn[i+1] = lenS(Sn[i])
  _sum = 0
  middle = int((Sn[n] + 1)/2)
  for i in list(range(1, n+1))[::-1]:
    if middle == x:
      _sum += int(Pn[i-1])
      break
    elif middle < x:
      _sum += Pn[i-1] + 1
      middle += int((Sn[i-1]+1)/2)
    else:
      middle -= int((Sn[i-1]+1)/2)
      pass
  if middle <= x:
    _sum += 1

  print(_sum)

  pass

if __name__=='__main__':
  main()

Measured memory_bytes: 3064
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]

INF = 1<<20

def perm(n, a, b, c):
    if n == N:
        if all([a, b, c]):
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return INF
    return min(
        perm(n+1,a,b,c),
        perm(n+1,a+l[n],b,c)+10,
        perm(n+1,a,b+l[n],c)+10,
        perm(n+1,a,b,c+l[n])+10
        )

print(perm(0,0,0,0))


Measured memory_bytes: 3064
N, K = gets.chop.split.map(&:to_i)
c = Array.new(N){Array.new(2)}
N.times{|i|
  c[i][0], c[i][1] = gets.chop.split.map(&:to_i)
}

# 多次元配列のソート
c.sort_by!{|x| x[0]}

k = 0
N.times{|i|
  k += c[i][1]
  if k >= K
    puts c[i][0]
    exit
  end
}

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=13;
int c[N][N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,d; cin>>n>>d;
	for(int i=0; i<n; i++) {
		for(int j=0; j<d; j++) {
			cin>>c[i][j];
		}
	}
	int anss=0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			ll ans=0;
			for(int k=0; k<d; k++) {
				ans+=(c[i][k]-c[j][k])*(c[i][k]-c[j][k]);
			}
			if(ans==(ll)sqrt(ans)*(ll)sqrt(ans)) {
				anss++;
			}
		}
	}
	cout<<anss<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,y,i,m=1,p;
   string s;
   cin>>n>>s;
   int l=s.size();
  for(i=0;i<l;i=i+1)
   {
       p=s[i]-'A';
       p=p+n;
       p=p%26;
      s[i]=p+'A';
       cout<<s[i];


   }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
bool v[N];
int n,m,x,y,c[N],q[N],t,X;
vector<int>a[N];
int main()
{
	cin>>n;
	m=n-1;
	while(m--&&cin>>x>>y)
		a[x].push_back(y),a[y].push_back(x),c[x]++,c[y]++;
	for(int i=1;i<=n;i++)
		if(c[i]==1)
			q[++t]=i;
	while(t)
	{
		X=q[t--];
		if(v[X])
			continue;
		for(int i=0;i<a[X].size();i++)
			if(!v[a[X][i]])
			{
				v[X]=v[a[X][i]]=true;
				for(int j=0;j<a[a[X][i]].size();j++)
					if(!v[a[a[X][i]][j]])
					{
						c[a[a[X][i]][j]]--;
						if(c[a[a[X][i]][j]]==1)
							q[++t]=a[a[X][i]][j];
					}
			}
		if(!v[X])
		{
			cout<<"First";
			return 0;
		}
	}
	cout<<"Second";
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#define IMP_NM 3
  
int cmp(const void *a,const void *b){
return *(int *)a - *(int *)b;
}
  
int main(void){
int a[IMP_NM], i;
for(i = 0;i < IMP_NM;i++){
scanf("%d",&a[i]);
}
qsort(a,IMP_NM,sizeof(a[0]),cmp);
for(i = 0;i < IMP_NM;i++){
printf("%d",a[i]);
if(i != IMP_NM - 1){
printf(" ");
}
}
printf("\n");
return 0;
}

Measured memory_bytes: 604
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    use itertools_num::ItertoolsNum as _;
    input! {
       k: u64,
    }

    let mut ans: usize = 0;
    let mut s = 1_u64;
    let mut a = 0_u64;
    for i in 0..40000000 {
        a = a.saturating_add(s.saturating_mul(7) % k) % k;
        s = s.saturating_mul(10) % k;
        //mydbg!(a, s);
        if a == 0 {
            echo!(i + 1);
            return;
        }
    }
    echo!(-1);
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <algorithm>

using namespace std;

struct val{
    int i;
    int val;
};

bool compara(val a, val b){
    return a.val<b.val;
}

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

    val arr[n];

    for(int i=0; i<n; i++){
        arr[i].i=i;
        scanf("%d",&arr[i].val);
    }

    sort(arr,arr+n,compara);

    //for(int i=0; i<n; i++){
    //    int mayor=0;
    //    for(int j=0; j<n; j++){
    //        if(i!=j && mayor<arr[j]){
    //            mayor=arr[j];
    //        }
    //    }
    //    printf("%d\n",mayor);
    //}

    for(int i=0; i<n; i++){
        if(arr[n-1].i!=i){
            printf("%d\n",arr[n-1].val);
        }else{
            printf("%d\n",arr[n-2].val);
        }
    }

    return 0;
}

Measured memory_bytes: 3072
from math import sqrt
N = int(input())
ans = 0
for i in range(7, N+1):
  if i%2==0:
    continue
  c = 0
  for j in range(1, int(sqrt(i))+1):
    if i%j==0:
      if i//j==j:
        c+=1
      else:
        c+=2
  if c==8:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0;i < N;i++) cin >> m.at(i);
  int base = 0;
  for(int i = 0;i < N;i++) base += m.at(i);
  sort(m.begin(), m.end());
  X -= base;
  int answer;
  answer = X/m.at(0) + N;
  cout << answer << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/jsc2019-qual/submissions/7121286
 
#include	<stdio.h>
int main(){
int month=0,day=0,count=0,tmp=0,compare1=0,test=0,compare2=0;
scanf("%d",&month);//tuki
scanf("%d",&day);//hiniti
for(int j=1;j<=month;j++){
for(int i=2;i<10;i++){
	tmp=j/i;
  	test=j%i;
  	compare1=tmp*10+i;
    compare2=i*10+tmp;
  	/*if(compare1<=day && compare1!=compare2&&tmp<10 && 1<tmp && test==0){
    count=count+1;
     
    }*/
    if(compare2<=day && tmp<10 && 1<tmp &&test==0){
    count=count+1;
      
    }
}}
printf("%d",count);
 return 0;
}
 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 
    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ
*/


bool isPrime(ll x) {
    for(ll i=2; i*i<=x; ++i) if (x%i==0) return false;
    return true;
}

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

    int x; cin >> x;
    for(int p=x; p<=10000000; ++p) if (isPrime(p)) {
        cout << p << endl;
        return 0;
    }
    
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N;
    int T[100005], A[100005];

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T[i] >> A[i];
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        int pos = lower_bound(T, T + N, l) - T;
        double perf = 1e9;
        for (int j = pos; j < N && T[j] < r && j < pos + 500; j++) {
            perf *= (10 - A[j]) / 10.0;
        }
        printf("%.12f\n", perf);
    }
    return (0);
}



Measured memory_bytes: 3944
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		int nums[] = new int[2]; 
      	int g[][] = {{1,3,5,7,8,10,12},{4,6,9,11},{2}};
      
      	int x_group = 3;
      	boolean x_found;
      	boolean eg = false;
      	
      	for(int i = 0;i < 2; i++){
        	nums[i] = sc.nextInt();
        }
      
      	for(int i = 0; i < 3 && x_group == 3; i++){
          for(int j = 0;j < g[i].length && x_group == 3;j++){
            if(nums[0] == g[i][j]) x_group = i;
          }
        }
      
      	for(int i = 0; i < g[x_group].length;i++){
          if(g[x_group][i] == nums[1]) eg = true;
        }      	
 		
      	if(eg) System.out.println("Yes");
      	else System.out.println("No");
        
	}
}


Measured memory_bytes: 35556
import sys
from collections import defaultdict

input = sys.stdin.readline

MOD = 1000000007

n, m = map(int, input().split())
f = defaultdict(lambda : 1)
dp = [0] * (n + 1)
for i in range(m):
    a = int(input())
    f[a] = 0
for i in range(n + 1):
    if i == 0:
        dp[i] = 1
    else:
        if f[i]:
            dp[i] = dp[i - 1] + dp[i - 2]
print(dp[-1] % MOD)



Measured memory_bytes: 482680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    long ns,nt;
    ns=s.size();
    nt = t.size();
    vector<vector <long> > alp(26,vector<long>(0));
    for(long i=0;i<ns;i++){
        alp[(int)(s[i]-'a')].emplace_back(i);
    }
    
    for(int i=0;i<26;i++){
        if(alp[i].size()==0) alp[i].emplace_back(-1);
    }
    
    long gap=0;
    int pre;
    int c=0;

    for(long i=0;i<nt;i++){
        if(i==0){
            pre = alp[(int)(t[0])-'a'][0];
            if(alp[(int)( t[i]-'a' )][0] == -1){
                c=1;
                break;
            }
        }
        else{
            if(alp[(int)( t[i]-'a' )][0] == -1){
                c=1;
                break;
            }
            else{
                if(pre >= *--alp[(int)(t[i]-'a')].end()){
                        gap++;
                        pre = *alp[(int)(t[i]-'a')].begin();
                }
                else{
                    pre = *upper_bound(alp[(int)(t[i]-'a')].begin(), alp[(int)(t[i]-'a')].end(), pre);
                }
            }
        }
    }
    if(c==1) cout << -1 << endl;
    else cout << ns*gap+pre+1 <<endl;


    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	double x,y,X,Y,i,j;
	cin>>x>>y>>X>>Y;
	if(x<X)i=X-x;
	else i=x-X;
	if(y<Y)j=Y-y;
	else j=y-Y;
    printf("%f\n", sqrt((i*i)+(j*j)));
	return 0;
	}


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

int main(){
	int a,b;
	cin >> a >> b;

		if( a == b )
		{
		cout << "a == b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			cout << "a < b" << endl;
			}
		}

}


Measured memory_bytes: 3084
from collections import deque, defaultdict
import sys
input=sys.stdin.readline


def solve():
    H, W, K = map(int, input().split())
    y1, x1, y2, x2 = map(int, input().split())
    l = [[1 if s=="@" else 0 for s in input()] for _ in range(H)]
    INF = 10**12

    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1

    ddy = [0, 0, -1, 1]
    ddx = [-1, 1, 0, 0]

    dist = defaultdict(lambda :INF)
    dist[(y1, x1)] = 0
    q = deque([(y1, x1)])

    while q:
        y, x = q.popleft()
        for dy, dx in zip(ddy, ddx):
            for j in range(1, K+1):
                if (not (0<=y+dy*j<H and 0<=x+dx*j<W)) or l[y+dy*j][x+dx*j] or dist[(y+dy*j, x+dx*j)] < dist[(y, x)] + 1:
                    break
                if dist[(y+dy*j, x+dx*j)] > dist[(y, x)] + 1:
                    dist[(y+dy*j, x+dx*j)] = dist[(y, x)] + 1
                    q.append((y+dy*j, x+dx*j))
                else:
                    continue

    ans = dist[(y2, x2)]
    print(ans if ans!=INF else -1)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 200600
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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() {
ll ans = 0;
	int N ; cin >> N;
	vector<pair<ll,ll>> A;
	rep(i,N){ll a; cin >> a;A.PB(MP(a,i+1));}
	sort(ALL(A));

	ll l = A.at(N/2-1).first;
	ll r = A.at(N/2).first;
	ll B[N+2];
	rep(i,N)
	{
		if(i<N/2){B[A.at(i).second] = r;}
		else{B[A.at(i).second] = l;}
	}
	
	rep(i,N-1){
	cout << B[i+1] << "\n";
	}
	cout << B[N] << endl;
}

Measured memory_bytes: 7660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;

  cout << (x/10==9||x%10==9 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll mod=998244353;

int main() {
    ll n,k,i;cin>>n>>k;ll h[n];for(i=0;i<n;i++)cin>>h[i];
    ll dp[n+1];dp[0]=0;dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    for(i=3;i<=n;i++)
    {
        dp[i]=INT_MAX;
        int j=1;
        while(j<=k && i-j>0)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(h[i-1]-h[i-1-j]));j++;
        }

        //dp[i]=min(dp[i-2]+abs(h[i-1]-h[i-3]),dp[i-1]+abs(h[i-1]-h[i-2]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,n,s1,s2;
	char name[16];
	for(i=0;i<9;i++) {
		cin>>name>>s1>>s2;
		cout<<name<<" "<<s1+s2<<" "<<(s1*200)+(s2*300)<<endl;
	}
	return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define endl "\n"
const int mod = 1e9+7;
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
int power(int a,int b){ int res=1; a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
 
ll a[101][100005];
int main()
{	
	sync
	int n;ll w;
	cin >> n >> w;
	ll in[n+1][2];
	for(int i = 1; i <= n ; i++)
		cin >> in[i][0] >> in[i][1];
	for(int i = 0; i <= 100; i++)
		for(int j = 0; j <= 100001; j++)
			a[i][j] = 2000000000;
	for(int i = 0; i <= 100; i++)
		a[i][0] = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= 100000; j++)
		{
			if(j >= in[i][1])
			{
				a[i][j] = min(a[i][j], a[i-1][j-in[i][1]]+in[i][0]);
			}
			a[i][j] = min(a[i][j], a[i-1][j]);
		}
	}
	int ans = -1;
	for(int j = 100000; j >= 1; j--)
	{
		for(int i = 100; i >= 1; i--)
		{	
			if(a[i][j] <= w)
			{
				ans = max(ans, j);
			}
 
		}
	}	
	cout << ans;
	return 0;
}

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

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

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


int main(){
    ll N,a;
    cin >> N;
    ll cnt_odd=0,cnt_even=0, cnt_four=0;
    llrep(i,N){
        cin >> a;
        if (a%2==0){
            if (a%4==0) cnt_four ++;
            else cnt_even ++;
        }else{
            cnt_odd ++;
        }
    }
    if (cnt_even==0){
        if(cnt_odd==0) cout << "Yes" << endl;
        else if (cnt_four==0 && cnt_odd>0) cout << "No" << endl;
        else if(cnt_four - cnt_odd >= -1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if (cnt_odd==0){//奇数がない
            if (cnt_four>0) cout << "Yes" << endl;
            else if (cnt_even>=2) cout << "Yes" << endl;
            else cout << "No" << endl;
        }else{//奇数がある
            if (cnt_four==0 || cnt_four - cnt_odd < -1) cout << "No" << endl;
            else if (cnt_four - cnt_odd >= 0) cout << "Yes" << endl;
            // else if (cnt_even >= 2) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }

    return 0;
}


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

using namespace std;
using namespace std::chrono;

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

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

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q;

vector<vector<ll> > C(100001, vector<ll>());
vector<vector<ll> > CW(100001, vector<ll>());

ll ans = 0;
ll miw = big;

ll middle = -1;

ll totsum = 0;

ll SS[100001] = {0};

ll dfs(ll i, ll par, ll w){
    ll ss = 1;
    for(ll c1 = 0; c1 < sz(C[i]); c1++){
        ll a = C[i][c1];
        if(a != par){
            ll w2 = CW[i][c1];
            miw = min(miw,w2);
            ss += dfs(a,i,w2);
        }
    }

    if(par != -1){
        if(ss == n-ss){
            middle = w;
        }
        ans += (2*min(ss,n-ss)) * w;
    }
    SS[i] = ss;

    return ss;
}

ll centroid(ll i, ll par){
    ll ma = 0;
    ll j = 0;
    for(ll c1 = 0; c1 < sz(C[i]); c1++){
        ll a = C[i][c1];
        if(a != par){
            if(ma < SS[a]){
                j = a;
                ma = SS[a];
            }
        }
    }
    if(ma <= n/2)return i;
    return centroid(j,i);
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e,f;

    cin >> n;
    for(ll c1 = 0; c1 < n-1; c1++){
        cin >> a >> b >> c;
        a--;
        b--;
        C[a].push_back(b);
        C[b].push_back(a);
        CW[a].push_back(c);
        CW[b].push_back(c);
        totsum += c;
    }
    dfs(0,-1,-1);
    if(middle != -1){
        cout << ans-middle << "\n";
    }
    else{

        c = centroid(0,-1);
        ll miw = big;
        for(ll c1 = 0; c1 < sz(C[c]); c1++){
            miw = min(miw,CW[c][c1]);
        }
        cout << ans-miw << "\n";
    }


    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main(){
	int n,k;
	cin >> n >> k;
	ll ans = 0;
	for(int b = 1; b <= n; b++){
		ans += n/b*max(b-k,0)+max(n%b-k+1,0);
	}
	if(k == 0) ans -= n;
	cout << ans << endl;
	return 0;
}

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF=2000000000;
const ll LINF = 1e18+5;

int main() {
    int N;
    cin>>N;
    string s, t;
    cin >> s >> t;
    string ans;
    rep(i,N) {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
    int r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n;
  cin >> n;
  vector<ll> a(n), b(n + 1);
  for(i = 0; i < n;i++){
    cin >> a[i];
  }
  b[0] = 0;
  for(i = 1; i <= n; i++)
    b[i] = b[i - 1] + a[i - 1];
  
  ll result = INF;
  ll suml, sumr;
  ll itrl, itrr;
  ll bufmax, bufmin;
  for(i = 2; i <= n - 2; i++){
    suml = b[i];
    sumr = b[n] - b[i];
    itrl = upper_bound(ALL(b), suml / 2) - b.begin();
    itrr = upper_bound(ALL(b), suml + sumr / 2) - b.begin();
    bufmax = max({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    bufmin = min({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    //cout << b[itrl] spa b[i] spa b[itrr] spa b[n] << endl;
    chmin(result, bufmax -  bufmin);
    
   
    itrl--;
    bufmax = max({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    bufmin = min({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    //cout << b[itrl] spa b[i] spa b[itrr] spa b[n] << endl;
    chmin(result, bufmax -  bufmin);
    itrr--;
    bufmax = max({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    bufmin = min({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    //cout << b[itrl] spa b[i] spa b[itrr] spa b[n] << endl;
    chmin(result, bufmax -  bufmin);
    itrl++; 
    bufmax = max({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    bufmin = min({b[itrl], b[i] - b[itrl], b[itrr] - b[i], b[n] - b[itrr]});
    //cout << b[itrl] spa b[i] spa b[itrr] spa b[n] << endl;
    chmin(result, bufmax -  bufmin);
  }
      
    
  cout << result << endl; 
 
  return 0;
  /**/
  
}




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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#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()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dp[15][106010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int d, g;
  cin >> d >> g;
  g /= 100;
  VI p(d), c(d);
  REP(i, d) cin >> p[i] >> c[i], c[i] /= 100;

  REP(i, 15) REP(j, 106010) dp[i][j] = INF;
  dp[0][0] = 0;

  REP(i, d) REP(j, g+1) {
    if(dp[i][j] == INF) continue;
    chmin(dp[i+1][j], dp[i][j]);
    REP(k, p[i]) {
      int nxt;
      if(k == p[i]-1) nxt = (i+1)*(k+1) + c[i];
      else nxt = (i+1)*(k+1);
      chmin(dp[i+1][min(g, j+nxt)], dp[i][j]+(k+1));
      // if(min(g, j+nxt) == g) cout << i+1 << " " << j+nxt << " " << k << " " << dp[i+1][min(g, j+nxt)] << endl;
      if(j+nxt >= g) break;
    }
  }

  // REP(i, g+1) cout << dp[d][i] << " ";
  // cout << endl;

  cout << dp[d][g] << endl;

  return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <algorithm>
#include <cstring>

#define R register
#define maxn 100010
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
typedef long long ll;
int n, a[maxn];
int main()
{
	scanf("%d", &n);
	for (R int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	R ll ans = ~0ULL >> 1;
	for (R int x = 0; x < 2; ++x)
	{
		R ll pre = 0, tot = 0;
		for (R int i = 1; i <= n; ++i)
			if ((i & 1) == x)
			{
				pre += a[i];
				if (pre >= 0) tot += pre + 1, pre = -1;
			}
			else
			{
				pre += a[i];
				if (pre <= 0) tot += 1 - pre, pre = 1;
			}
		cmin(ans, tot);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,i;
  cin >> a >> b >>c;
  
  i = a;
  a = b;
  b = i;
  
  i = a;
  a = c;
  c = i;
  
  cout <<a<< endl;cout <<b<< endl;cout <<c<< endl;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n-1; i++){
    if (s[i] != s[i+1]) ans++;
  }
  ans++;
  cout << ans << endl;
}


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

using namespace std;

int n;
int a[100100],b[100100],c[100100];
int dp_a[100100],dp_b[100100],dp_c[100100];


int vac(int i,char estado){

    if(i>n) return 0;

    int resp;

    if(i==0){
        resp=max(a[i]+vac(i+1,'a'),b[i]+vac(i+1,'b'));
        return resp=max(resp, c[i]+vac(i+1,'c'));
    }
    else{
        switch(estado){
            case 'a':
                if(dp_a[i]!=-1) return dp_a[i];
                return dp_a[i] =max(b[i]+vac(i+1,'b'),c[i]+vac(i+1,'c')); break;
            case 'b':
                if(dp_b[i]!=-1) return dp_b[i];
                return dp_b[i] =max(a[i]+vac(i+1,'a'),c[i]+vac(i+1,'c')); break;
            case 'c':
                if(dp_c[i]!=-1) return dp_c[i];
                return dp_c[i] =max(a[i]+vac(i+1,'a'),b[i]+vac(i+1,'b')); break;
        }
    }
}

int main(){

    memset(dp_a,-1,sizeof(dp_a));
    memset(dp_b,-1,sizeof(dp_b));
    memset(dp_c,-1,sizeof(dp_c));

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    cout<<vac(0,'d');
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()


int main()
{
	fastio;
	int n, m;
	cin >> n >> m;
	int lc=0, rc=0;
	for(int i=0;i<m;i++)
	{
		int l, r;
		cin >> l >> r;
		if(!i)
		{
			lc = l;
			rc = r;
		}
		else
		{
			lc = max(l, lc);
			rc = min(r, rc);
		}
	}
	int z = rc - lc + 1;
	if(z < 0) cout << "0\n";
	else
		cout << rc - lc + 1 << "\n";
	return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun h w ->
    let s = Array.init h (fun _ -> Scanf.scanf " %s" (fun s -> s)) in
    let rec loop_y y =
        let rec loop_x x =
            if x = w then loop_y (y + 1) else
                if s.(y).[x] = '.' then loop_x (x + 1) else (
                    if x > 0     && s.(y).[x - 1] = '#' ||
                       x < w - 1 && s.(y).[x + 1] = '#' ||
                       y > 0     && s.(y - 1).[x] = '#' ||
                       y < h - 1 && s.(y + 1).[x] = '#' then loop_x (x + 1) else false
                )
        in
        if y = h then true else loop_x 0
    in
    print_endline @@ if loop_y 0 then "Yes" else "No"
)

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
//int n,m,a[N];
int main() {
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<' '<<b<<' '<<c;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
using i64 = long long;

bool ask(i64 n) {
  printf("? %lld\n", n);
  fflush(stdout);
  char res[10];
  scanf("%s", res);
  return res[0] == 'Y';
}

int main() {
  int c = 0, t = 1;

  for (; c <= 9; c++) {
    if (!ask(t)) break;
    t *= 10;
  }

  if (c == 10) {
    i64 t = 10;
    while (!ask(t - 1)) t *= 10;
    printf("! %lld\n", t / 10);
  } else {
    i64 ret = 0;
    for (int i = 1; i < c; i++) {
      int l = 0, r = 10;
      while (r - l > 1) {
        const int mid = (l + r) / 2;
        if (ask(ret * 10 + mid)) l = mid;
        else r = mid;
      }

      ret = ret * 10 + l;
    }

    ret *= 10;

    int l = -1, r = 9;
    while (r - l > 1) {
      const int mid = (l + r) / 2;
      if (ask((ret + mid) * 10)) r = mid;
      else l = mid;
    }

    printf("! %lld\n", ret + r);
  }

  fflush(stdout);

  return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int pwr[200005];
int bigmod(int b, int p, int mod)
{
    if(!p)return 1ll;
    int ret= bigmod(b, p/2, mod);
    ret= (1LL*ret*ret)%mod;
    if(p&1)ret= (1LL*ret*b)%mod;
    return ret;
}
char str[200005];
int f[200005];
int func(int x)
{
    int c= 0;
    for(int i=0; i<20; i++)
    if(x&(1<<(i)))c++;
    return (x%c);
}
int main()
{
    int n, c= 0;
    scanf("%d %s", &n, str);
    reverse(str, str+n);
    for(int i=0; str[i]; i++)
    c+= (str[i]=='1');
    if(c>1)
    {
        pwr[0]= 1%(c-1);
        int sum= 0;
        if(str[0]=='1')sum= pwr[0];
        for(int i=1; str[i]; i++)
        {
            pwr[i]= (pwr[i-1]*2)%(c-1);
            if(str[i]=='1')sum+= pwr[i], sum%= (c-1);
        }
        for(int i=0; str[i]; i++)
        if(str[i]=='1')
        {
            int x= ((sum-pwr[i])%(c-1) + (c-1) )%(c-1);
            f[i]= 1;
            while(x)x= func(x), f[i]++;
        }
    }
    c++;
    pwr[0]= 1%c;
    int sum= 0;
    if(str[0]=='1')sum= pwr[0];
    for(int i=1; str[i]; i++)
    {
        pwr[i]= (pwr[i-1]*2)%c;
        if(str[i]=='1')sum+= pwr[i], sum%= c;
    }
    for(int i=0; str[i]; i++)
    if(str[i]=='0')
    {
        int x= (sum+pwr[i])%c;
        f[i]= 1;
        while(x)x= func(x), f[i]++;
    }
    for(int i=n-1; i>=0; i--)printf("%d\n", f[i]);
    return 0;
}


Measured memory_bytes: 5580
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll a[x];
    ll s=0;
    f(i,x){
        cin>>a[i];
        s+=a[i];
    }
    ll c=0;
    f(i,x){
        if(a[i]*4*y-s>=0){
            c++;
        }
    }
    if(c>=y){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>


int main() {
	int st[26]{};
	int tt[26]{};

	std::string s, t;
	std::cin >> s >> t;

	for (unsigned i{}; i < s.size(); i++) {
		st[s[i] - 'a']++;
		tt[t[i] - 'a']++;
	}


	std::sort(st, st + 26);
	std::sort(tt, tt + 26);

	bool match = true;
	for (unsigned i{}; i < 26;i++) {
		match &= st[i] == tt[i];
	}
	std::cout << (match ? "Yes" : "No") << "\n";
	return 0;
}

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

int id,T[500001];
void maxHeapify(int );

int main()
{
  int i;
  
  scanf("%d",&id);
  
  for(i = 1;i <= id;i++)
    {
      scanf("%d",&T[i]);
    }
  for(i = id/2;i >= 1;i--)
    {
      maxHeapify(i);
    }
  for(i = 1;i <= id;i++)
    {
      printf(" %d",T[i]);
    }
  printf("\n");
  return 0;
}
void maxHeapify(int i)
{
  int a,r,l,largest;
  l = 2*i;
  r = (2*i) + 1;
  if(l <= id && T[l] > T[i])
    {
      largest = l;
    } else
    {
      largest = i;
    }
  if(r <= id && T[r] > T[largest])
    {
      largest = r;
    }
  if(largest != i)
    {
      a = T[i];
      T[i] = T[largest];
      T[largest] = a;
      maxHeapify(largest);
    }
}



Measured memory_bytes: 3676
// https://atcoder.jp/contests/arc087/tasks/arc087_a

#include "bits/stdc++.h"
#define ll long long 
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
using namespace std;
int main() {

    int n; cin >> n;
    vector <int> arr(n);
    for(auto &i : arr) cin >> i;

    unordered_map <int,int> mp;

    for(int i = 0; i < n; i++){
        mp[arr[i]]++;
    }

    int ans = 0;
    
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(i -> first != i -> second){
            if(i -> first > i -> second) ans += i -> second;
            else ans += i->second - i -> first;
        }
    }

    cout << ans;

}

Measured memory_bytes: 7500
# -*- coding: utf-8 -*-
s = input()
k = int(input())

# g = 5000000000000000

ret = ""
for i,x in enumerate(s):
    # print(i,x)
    if x!="1":
        print(x)
        exit()
    elif i+1==k:
        print(1)
        exit()
print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	if(a==b && b==c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int A = scanner.nextInt();
		    int B = scanner.nextInt();
		    int C = scanner.nextInt();
		    int D = scanner.nextInt();
		    if( A + B == C + D ) 
		    {
		    	System.out.println("Balanced");
		    }
		    else if ( A + B > C + D )
		    {
		    	System.out.println("Left");
		    }
		    else 
		    {
		    	System.out.println("Right");
		    }
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
#include<stdio.h>

void same(int*, int*, int*);
void unite(int*, int*, int*, int*);

int main(void) {
    int i, j;
    int n, q, com, x, y;
    scanf("%d%d", &n, &q);
    int map[n];
    
    for(i=0; i<n; i++) map[i] = i;
    
    for(i=0; i<q; i++) {
        scanf("%d%d%d", &com, &x, &y);
        
        if(com == 1) {
            same(map, &x, &y);
        } else {
            unite(&n, map, &x, &y);
        }
    }
    return 0;
}

void same(int *map, int *x, int*y) {
    if(map[*x] == map[*y]) printf("1\n");
    else printf("0\n");
}

void unite(int *n, int *map, int *x, int *y) {
    int i;
    int target = map[*y];
    for(i=0; i<*n; i++) {
        if(map[i]==target) map[i] = map[*x];
    }
}

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

int main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=1;i<=n;++i){
		if(i%3==0)
			a.push_back(i);
		else if(i%10==3)
			a.push_back(i);
		else if(i/10%10==3)
			a.push_back(i);
		else if(i/100%10==3)
			a.push_back(i);
		else if(i/1000%10==3)
			a.push_back(i);


	}
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();++i){
	cout<<" "<<a[i];
	}
	cout<<endl;

	return 0;
}





/*void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;

}

int main()
{
	call(30);
}*/

Measured memory_bytes: 1276
#include <stdio.h>
int main(void){
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
d = a+b;
if(d >=a+c){
	d = a+c;
}
if(d>=c+b){
	d = b+c;
}
printf("%d",d);
}


Measured memory_bytes: 128