akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        A: u8,
        B: u8,
        C: u8,
    }
    match A + B + C {
        17 => println!("YES"),
        _ => println!("NO"),
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
//#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
#include <stdio.h>
//小数制度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int dp[1010][1010];
int v[1010];
int w[1010];
int main(){
  int wei,n;
  int cnt = 1;
  while(cin >> wei,wei){
    cin >> n;
    REP(i,1010) REP(j,1010) dp[i][j] = 0;
    for(int i=0;i<n;i++){
      scanf("%d,%d",&v[i],&w[i]);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<=wei;j++){
        if(j-w[i]<0) dp[i+1][j] = dp[i][j];
        else  dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      }
    }
    /*for(int i=0;i<n+1;i++){
      for(int j=0;j<wei+1;j++){
        cout << dp[i][j] << " ";//l<<endl;
      }
      cout << endl;
    }*/
    int maxv=0;
    int ans=-1;
    for(int i=0;i<wei+1;i++){
      if(maxv < dp[n][i]){
        maxv = dp[n][i];
        ans = i;
      }
    }
    cout << "Case " << cnt << ":" <<endl;
    cout << maxv << endl << ans << endl;
    cnt++;
  }
}

Measured memory_bytes: 5236
#include <iostream>
#include <string>
//#include <math.h>
using namespace std;

int main(){
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  if(c == d && e == f){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}


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

# def dfs(bit, depth=0):
#     if depth > 10:
#         return bit * -2**depth
#
#     return min(dfs(0, depth + 1) - n, dfs(1, depth + 1) - n)
# print(dfs(0), dfs(1))

if n < 0:
    n *= -1
    sign = 0
else:
    sign = 1

b = list(map(int, list(bin(n)[2:])))[::-1] + [0] * 30
results = []
for i, v in enumerate(b[:-1]):
    up = b[i] // 2
    b[i] %= 2
    b[i + 1] += up
    if i % 2 == sign:
        if b[i]:
            b[i + 1] += 1
print(int("".join(map(str, b[::-1]))))


Measured memory_bytes: 3064
import java.util.*;
 
public class Main{
 
    int[] v;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
 
    void solve(){
        Scanner sc = new Scanner(System.in);

        calc();
 
        while(sc.hasNext()){
            String pzl = "";
            for(int i=0; i<2; i++)
                for(int j=0; j<4; j++) pzl += sc.next();

            System.out.println(v[Integer.parseInt(pzl)/10]);
        }
    }
 
    void calc(){
        Queue<int[]> q = new LinkedList<int[]>();
        q.add(new int[]{1234567,0,0,0});

        v = new int[7654322];
        Arrays.fill(v,-1);
        v[123456] = 0;
 
        while(q.size()>0){
            int[] pp = q.poll();
            int x = pp[1], y = pp[2], cnt = pp[3];

            String pzzs = String.valueOf(pp[0]);
            if(pzzs.length()==7) pzzs = "0" + pzzs;
            char[] c = pzzs.toCharArray();
 
            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx<0 || nx>=4 || ny<0 || ny>=2) continue;
                c[y*4+x] = c[ny*4+nx];
                c[ny*4+nx] = '0';
                int ns = Integer.parseInt(String.valueOf(c));
                if(v[ns/10]==-1){
                    v[ns/10] = cnt+1;
                    q.add(new int[]{ns,nx,ny,cnt+1});
                }
                c[ny*4+nx] = c[y*4+x];
                c[y*4+x] ='0';
            }
        }
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 42000
//import java.util.*;
//
//public class Main {
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int m = scanner.nextInt();
//        int[] a = new int[n];
//        int[][] bc = new int[2][m];
//        long sum = 0;
//
//        for (int i = 0; i < n; i++) {
//            a[i] = scanner.nextInt();
//        }
//
//        Arrays.sort(a);
//        for (int i = 0; i < m; i++) {
//            bc[0][i] = scanner.nextInt();
//            bc[1][i] = scanner.nextInt();
//        }
//        Comp comp = new Comp();
//        //2次元目のインデックス1番でソート
//        comp.set_index(1);
//        //Arraysクラスのsort()を実行する
//        Arrays.sort(bc, comp);
//        int k = 0;
//        for (int i = m-1; i >= 0; i--) {
//            if(a[k] >= bc[1][i]){
//                break;
//            }
//            for (int j = 0; j < bc[0][i]; j++) {
//                if (a[k] < bc[1][i]) {
//                    a[k++] = bc[1][i];
//                } else {
//                    break;
//                }
//            }
//        }
//        for(int i = 0 ; i < n ; i++){
//            sum+=a[i];
//        }
//        System.out.println(sum);
//    }
//
//}
//
//class Comp implements Comparator {
//
//    int index = 0;
//
//    void set_index(int i) {
//        index = i;
//    }
//
//    @Override
//    public int compare(Object a, Object b) {
//        int[] int_a = (int[]) a;
//        int[] int_b = (int[]) b;
//        return (int_a[index] - int_b[index]);
//    }
//
//}
//

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        ArrayList<Integer> l = new ArrayList<>();
        ArrayList<Integer> r = new ArrayList<>();


        for (int i = 0; i < m; i++) {
            l.add(scanner.nextInt());
            r.add(scanner.nextInt());
        }

        if (Collections.min(r) >= Collections.max(l)) {
            System.out.println(Collections.min(r) - Collections.max(l) + 1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 85608
import sys, math
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    w = ii()
    print(*S[::w], sep='')
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 9488
#include <iostream>

using namespace std;

int main(void) {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    cout << 15 - x1 - x2 - x3 -x4 - x5 << endl;
    return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int s;
    cin >> s;
    set<int> ss;
    ss.insert(s);
    int ans = 2;

    for (;;) {
        if (s % 2 == 0) {
            s = s / 2;
        }
        else {
            s = 3 * s + 1;
        }
        auto ite = ss.insert(s);
        if (!ite.second) {
            break;
        }
        ++ans;
    }
    cout << ans;

    return 0;
}

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

    int x, y, c, tmp;

    void run(){
	while(sc.hasNext()){
	    x = sc.nextInt();
	    y = sc.nextInt();
	    if(x==0 && y==0) break;
	    c = 0;

	    if(x<y){
		tmp = x;
		x = y;
		y = tmp;
	    }

	    while(y!=0){
		tmp = x%y;
		x = y;
		y = tmp;
		c++;
	    }

	    System.out.println(x+" "+c);
	}
    }
}

Measured memory_bytes: 24676
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int h, w;
    for (int i = 0; ; i++)
    {
        cin>>h>>w;
        if (h == 0 && w == 0)
        {
            break;
        }

        for (int j = 0; j < h; j++)
        {
            for (int k = 0; k < w; k++)
            {
                cout<<"#";
            }
            cout<<endl;
        }
       cout<<endl; 
    }
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int n;
    cin >> n;
    rep(i,n)cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3584
k,n=map(int,input().split())
a = list(map(int,input().split()))
a=sorted(a)
d=[]
cnt=1
for i in range(k-1):
  if a[i]==a[i+1]:
    cnt+=1
  else:
    d.append(cnt)
    cnt=1
d.append(cnt)
d=sorted(d)
ans=0
for i in range(len(d)-n):
  ans+=d[i]
print(ans)


Measured memory_bytes: 24748
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    pp = ""
    p = ""

    left = -1
    right = -1

    for i, char in enumerate(s, 1):
        if pp == char:
            left = i - 2
            right = i
            break
        if p == char:
            left = i - 1
            right = i
            break
        pp = p
        p = char

    print(left, right)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69252
n=int(input())
a=[]
b=[]
for _ in range(n):
  s=int(input())
  if s%10:a.append(s)
  else:b.append(s)
a=sorted(a)
if not a:
  print(0)
  exit()
if sum(a)%10:print(sum(a)+sum(b))
else:print(sum(a[1:])+sum(b))

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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

bool in_range(int x, int mn, int mx) { return mn <= x && x < mx; }
bool in_range(int x, int y, int w, int h) { return in_range(x, 0, w) && in_range(y, 0, h); }

struct State { int step, x1, y1, x2, y2; };

int W, H, tx, ty, kx, ky, grid[55][55];
int dst[55][55][55][55];

void solve() {
	memset(dst, -1, sizeof(dst));
	
	queue< State > que;
	que.push(State{0, tx, ty, kx, ky});
	dst[ty][tx][ky][kx] = 0;
	
	while (!que.empty()) {
		State s = que.front(); que.pop();
		
		if (s.step >= 100) break;
				
		if (s.x1 == s.x2 && s.y1 == s.y2) {
			cout << s.step << endl;
			return;
		}
		
		for_(d,0,4) {
			int nx1 = s.x1 + dx[d], ny1 = s.y1 + dy[d];
			int nx2 = s.x2 + dx[(d + 2) % 4], ny2 = s.y2 + dy[(d + 2) % 4];
			
			if (!in_range(nx1, ny1, W, H)) { nx1 = s.x1; ny1 = s.y1; }
			if (grid[ny1][nx1] == 1) { nx1 = s.x1; ny1 = s.y1; }
			
			if (!in_range(nx2, ny2, W, H)) { nx2 = s.x2; ny2 = s.y2; }
			if (grid[ny2][nx2] == 1) { nx2 = s.x2; ny2 = s.y2; }
			
			if (dst[ny1][nx1][ny2][nx2] == -1) {
				dst[ny1][nx1][ny2][nx2] = s.step + 1;
				que.push(State{s.step + 1, nx1, ny1, nx2, ny2});
			}
		}
	}
	
	cout << "NA" << endl;
}

int main() {
	while (cin >> W >> H, W) {
		cin >> tx >> ty;
		--tx; --ty;
		cin >> kx >> ky;
		--kx; --ky;
		for_(i,0,H) for_(j,0,W) cin >> grid[i][j];
		solve();
	}
}

Measured memory_bytes: 37280
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long [] A = new long [5];
		long min = (long) Math.pow(10, 15);
		for (int i=0;i<5;i++) {
			A[i] = sc.nextLong();
			min = Math.min(A[i], min);
		}
		long result;
		if (N % min == 0)
			result = N/min + 4;
		else 
			result = N/min + 5;
		System.out.println(result);
	}
}	


Measured memory_bytes: 22740
import java.io.*;
import java.util.Scanner;

public class Main {

    static int i = 1;

    public static void main(String[] args) {


        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        for (int u = 0; u < t; u++) {
            System.out.print("ACL");
        }

    }
}

Measured memory_bytes: 35732
import math

a,b,h,m = map(float,input().split())

mini = m+(h*60.0)

a_ang = 0.5*mini
b_ang = 6.0*m
ang = 0.0
flag = 0

if a_ang > b_ang:
    if a_ang-b_ang > 180:
        ang = 360.0 - (a_ang-b_ang)
    elif a_ang-b_ang < 180:
        ang = a_ang - b_ang
    else:
        print(a+b)
        flag = 1
elif a_ang < b_ang:
    if b_ang-a_ang > 180:
        ang = 360.0 - (b_ang-a_ang)
    elif b_ang-a_ang < 180:
        ang = b_ang - a_ang
    else:
        print(a+b)
        flag = 1
else:
    if a>b:
        print(a-b)
    else:
        print(b-a)
    flag = 1

if flag == 0:
    rad = math.radians(ang)
    print(math.sqrt((a**2)+(b**2)-(2*a*b*(math.cos(rad)))))


Measured memory_bytes: 9496
#!/usr/bin/env python3

import array


def sieve_of_eratosthenes(end, typecode="L"):
    assert end > 1
    is_prime = array.array("B", (True for i in range(end)))
    is_prime[0] = False
    is_prime[1] = False
    primes = array.array(typecode)
    for i in range(2, end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes


def solve(x):
    primes = sieve_of_eratosthenes(x * 5)
    for p in primes:
        if x <= p:
            return p


def main():
    x = int(input())
    p = solve(x)
    print(p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3992
def main():
    end = list(input())
    n = int(input())
    start = []


    for i in range(n):
        query = input().split()
        q = int(query[0])
        if q == 1:
            start,end = end,start
        else:
            f = int(query[1])
            if f == 1:
                start.append(query[-1])
            else:
                end.append(query[-1])
    print(''.join(start[::-1] + end))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 77160
import math

def isPrime(x):
    if x == 2:
        return 1
    elif x < 2 or x % 2 == 0:
        return 0
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return 0
        i += 2
    return 1

arr = []
cnt = 0
            
n = int(input())
for i in range(n):
    x = int(input())
    arr.append(x)

for i in arr:
    cnt += isPrime(i)
    
print(cnt)
     


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



int main(){
  int N = 3;
  cin >> N;
  int M;
  cin >> M;
  
  
  if(abs(M-N) % 2 == 1) 
  {
    cout << "IMPOSSIBLE" << endl;
  }
  else
  {
    int ans = min(M, N) + abs(M-N)/2;
  	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int S, A, B;

int main(void){
	//IO("test.in", "test.out");
	S = 1;
	scanf("%d%d", &A, &B);
	for(int i = 2; i <= 999; i++){
		if(S - A == S + i - B){
			printf("%d\n", S - A);
			break;
		}else{
			S += i;
		}
	}
}

Measured memory_bytes: 256
N=int(input())
A = list(map(int,input().split()))
B=[0]
total=0
count=0
flag=0
for i in range(N):
  total+=A[i]
  B.append(total)
total=0

B.sort()
B.append(1000000000)
for i in range(N+1):
  count+=1
  if B[i]!=B[i+1]:
    if count>=2:
        total+=count*(count-1)//2
    count=0
#print(B)
print(total)


Measured memory_bytes: 26136
d,n=map(int,input().split())
a=[100**d*i for i in range(n+1)]
if d==0 and n==100:
    print(101)
elif d==1 and n==100:
    print(10100)
elif d==2 and n==100:
    print(1010000)
else:
    print(a[-1])

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

int n;
long long a[110];
long long x;

int main()
{
	//freopen("in.txt", "r", stdin);
	scanf("%d%lld",&n, &x);
	for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1);
	long long sum = 0;
	int ans = 0, j = -1;
	for(int i = 1; i <= n; i ++)
	{
		if(sum + a[i] <= x) ans ++, sum += a[i], j = i;
		else break;
	}
	if(j == n && sum < x) ans --;
	printf("%d\n", ans);
	return 0;
}

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

int main() {  
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if(w>=v or (long double)abs(a-b)/abs(v-w)>t)
    cout << "NO" << "\n";
  else cout << "YES" << "\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
  ////  #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
    cin>>a>>b>>n;
    if(a<b)
    	swap(a,b);
    for(int i=1;;i++){
    	++cn1;
    	if(i*a>=n)
    	{
    		break;
    	}
    }
    cout<<cn1<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

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

	string S;
	cin >> S;

	int result = 0;

	for( int i = 0; i < N-1; ) {
		if( S.at( i ) == 'O' && S.at( i+1 ) == 'X' ) {
			result += 1;
			i += 2;
		}
		else if( S.at( i ) == 'X' && S.at( i+1 ) == 'O' ) {
			result += 1;
			i += 2;
		}
		else {
			i += 1;
		}
	}

	cout << result << endl;
}



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

int main() {
  using pii = pair<int, int>;
  // これ以降 pii という型名はpair<int, int> と同じ意味で使える
  using vi = vector<int>; // intの1次元の型に vi という別名をつける
  using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
//
//  pii p;
//  p = make_pair(1, 2);
//  int N = 10, M = 20;
//  vvi data(N, vi(M));  // N * M の2次元配列
//
  int n,a,b,N_103,N_102,N_101;
  cin >> n >> a >> b;
  int sum = 0;
  int ans = 0;
  for(int i = 0;i < n;i++){
    sum = (i+1)/10000;
    N_103 = (i+1)%10000;
    sum += N_103/1000;
    N_102 = (i+1)%1000;
    sum += N_102/100;
    N_101 = (i+1)%100;
    sum += N_101/10;
    sum += (i+1)%10;
    if(sum >= a && sum <= b){
      ans += i + 1;
//      cout << i+1 <<endl;
    }
    sum = 0;
  }
  cout << ans << endl;
  return (0);
}

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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; }

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









int main(){
  int H, W, K;
  cin >> H >> W >> K;
  char c[H][W];
  int res[H][W];
  int pos = -1;
  REP(y, H){
    REP(x, W){
      cin >> c[y][x];
      if(c[y][x] == '#' && pos == -1) pos = y;
    }
  }

  int cnt = 1;
  for(int y = pos; y < H; y++){
      bool flag = true;
      REP(x, W){
        if(c[y][x] == '#'){
          flag = false;
          break;
        }
      }
      if(flag){
        REP(x, W){
          res[y][x] =res[y - 1][x];
        }
      }else{
        vector<int>id;
        REP(x, W){
          if(c[y][x] == '#') id.push_back(x);
        }
      queue<int> cp;
      for(int x = 1; x < id.size(); x++) cp.push(id[x] - 1);
      cp.push(W - 1);
      REP(x, W){
        res[y][x] = cnt;
        if(cp.front() == x){
          cp.pop();
          cnt++;
        }
      }
    }
  }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << res[max(i, pos)][j] << " ";
        }
        cout << '\n';
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,n,m,i,j,r,sum[5010],q[5010],le[202][5010],re[202][5010],aa[5010],a[5010][202],b[5010][5010];
int main(){
	scanf("%lld%lld",&n,&m);
	for(i=1;i<n;i++)scanf("%lld",&aa[i]);
	for(i=1;i<n;i++)sum[i]=sum[i-1]+aa[i];
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)scanf("%lld",&a[i][j]);
	for(j=1;j<=m;j++){
		r=0;
		for(i=1;i<=n;i++){
			while(r&&a[i][j]>=a[q[r]][j])r--;
			le[j][i]=q[r]+1;
			q[++r]=i;
		}
		r=0;
		for(i=n;i;i--){
			while(r&&a[i][j]>a[q[r]][j])r--;
			if(!r)re[j][i]=n;
			 else re[j][i]=q[r]-1;
			q[++r]=i;
		}
		for(i=1;i<=n;i++){
			//printf("%lld %lld %lld %lld\n",j,i,le[j][i],re[j][i]);
		b[le[j][i]][i]+=a[i][j];
		b[le[j][i]][re[j][i]+1]-=a[i][j];
		b[i+1][i]-=a[i][j];
		b[i+1][re[j][i]+1]+=a[i][j];
	  }
	}
	for(i=1;i<=n;i++)
	 for(j=1;j<=n;j++){
	 	//printf("-1 %lld %lld %lld ",i,j,b[i][j]);
	  b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	  //printf("%lld\n",b[i][j]);
	  if(i<=j)ans=max(ans,b[i][j]-(sum[j-1]-sum[i-1]));
}
	printf("%lld",ans);
}
/*
每个人的每张餐券可用范围是一个(l~i)(i~r)的二维矩形 
每个人的矩形不想交 
*/

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

tmp = {}

tmp[s] = 1
i = 1
while True:
    i += 1
    if s % 2 == 0:
        s = int(s/2)
    else:
        s = int(3*s+1)
    if s in tmp:
        print(i)
        exit()
    tmp[s] = 1


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
    int A,B,C;
    int S1;
  
    scanf("%d%d%d",&A,&B,&C);
    S1=A-B;
    if(S1<=C) printf("%d\n",C-S1);
    else printf("0\n");
  
    return 0;
}
  
    


Measured memory_bytes: 1736
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
from functools import reduce

n,x,y = list(map(int, input().split()))

count = {}
for k in range(1,n):
    count[k] = 0

for i in range(1,n+1):
    for j in range(i+1,n+1):
        k = min([j-i, abs(x-i) + abs(y-j) + 1])
        count[k] += 1

for k in range(1,n):
    print(count[k])





Measured memory_bytes: 9684
#include<stdio.h>

void swap(long long int* a,long long int* b){
    long long int c=*a;
    *a=*b;
    *b=c;
}

long long int gcd(long long int a, long long int b){
    if(a<b){
        swap(&a,&b);
    }while(a%b!=0){
        long long int c=a%b;
        a=b;
        b=c;
    }
    return b;
}

int main(){
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld", a*b / gcd(a, b));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x,k,d;
    cin>>x>>k>>d;

    if(x<0) x=abs(x);
    ll ans,n=k;
    k-=(x+d-1)/d;
    if(k<0){
        x-=n*d;
        cout<<abs(x)<<endl;
        return 0;
    }else x-=(x+d-1)/d*d;

    if(k%2==1) ans=min(abs(x-d),abs(x+d));
    else ans=abs(x);


    cout<<abs(ans)<<endl;

    return 0;
}

Measured memory_bytes: 3592
// ITP1_7_C:   Spreadsheet
// 2017.7.27
 
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int e[101][101];
    int R, C, r, c;
    int s, total;
 
    scanf("%d%d", &R, &C);
    for (r = 1; r <= R; r++) {
        for (c= 1; c <= C; c++) scanf("%d", &e[r][c]);
    }
     
    for (r = 1; r <= R; r++) {
        s = 0;
        for (c = 1; c <= C; c++) s += e[r][c];
        e[r][0] = s;
    }
    total = 0;
    for (c = 1; c <= C; c++) {
        s = 0;
        for (r = 1; r <= R; r++) s += e[r][c];
        e[0][c] = s;
        total += s;
    }
    for (r = 1; r <= R; r++) {
        for (c = 1; c <= C; c++) printf("%d ", e[r][c]);
        printf("%d\n", e[r][0]);
    }
    for (c = 1; c <= C; c++) printf("%d ", e[0][c]);
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

long long gcd (long long a, long long b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    long long a, b;
    cin >> a >> b;
    long long g = gcd(a, b);
    vector<long long> v;
    for (long long i = 1; i <= sqrt(g); ++i) {
        if (g % i == 0) {
            v.push_back(i);
            if (i * i != g) {
                v.push_back(g / i);
            }
        }
    }
    sort(v.begin(), v.end());
    vector<long long> answer;
    for (long long n : v) {
        bool ok = true;
        for (long long m : answer) {
            if (m != 1 && n % m == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            answer.push_back(n);
        }
    }
    cout << answer.size() << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int n = s.size();
  int c = 0;
  for (int i = 0; i < n/2; i++){
    if(s[i] != s[n - i - 1]){
      c++;
    }
  }
  cout << c;
  return 0;
}


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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int res = max(0,min(b,d)-max(a,c));
    cout<<res<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,j,fm,sm,vmax=0,umax=0,ans;
  cin >> n;
  vector<int> f(n/2+3,0),s(n/2+3,0),fn,fb,sn,sb;
  for (i=0;i<n;i++){
    if (i%2) cin >> s.at(i/2);
    else cin >> f.at(i/2);
  }
  fn.push_back(f.at(0));
  sn.push_back(s.at(0));
  fb.push_back(1);
  sb.push_back(1);
  for (i=1;i<n/2;i++){
    for (j=0;j<fn.size();j++) if (f.at(i)==fn.at(j)) break;
    if (j!=fn.size()) fb.at(j)++;
    else{
      fn.push_back(f.at(i));
      fb.push_back(1);
    }
  }
  for (i=0;i<fn.size();i++) if (vmax<fb.at(i)){
    vmax=fb.at(i);
    fm=fn.at(i);
  }
  
  for (i=0;i<n/2;i++){
    for (j=1;j<sn.size();j++) if (s.at(i)==sn.at(j)) break;
    if (j!=sn.size()) sb.at(j)++;
    else{
      sn.push_back(s.at(i));
      sb.push_back(1);
    }
  }
  for (i=0;i<sn.size();i++) if (umax<sb.at(i)){
    umax=sb.at(i);
    sm=sn.at(i);
  }
  if (fm==sm){
    int fmax=0,smax=0;
    for (i=0;i<fn.size();i++) if (fn.at(i)!=fm && fmax<fb.at(i)) fmax=fb.at(i);
    for (i=0;i<sn.size();i++) if (sn.at(i)!=sm && smax<sb.at(i)) smax=sb.at(i);
    ans=n-max(vmax+smax,umax+fmax);
  }else ans=n-vmax-umax;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1700
def run(s, t):
    len_t = len(t)
    for i in range(len_t):
        t = t[-1] + t[0:(len_t-1)]
        if s == t:
            return 'Yes'
    return 'No'


def read_line():
    s = input()
    t = input()
    return (s, t)


def main():
    s, t = read_line()
    ret = run(s, t)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#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 (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;

  FOR(i, 1, 3501) {
    FOR(j, 1, 3501) {
      ll b = 4 * i * j - n * i - n * j, a = n * i * j;
      if (b > 0 && a % b == 0) {
        cout << i << ' ' << j << ' ' << a / b << '\n';
        return 0;
      }
    }
  }
  

  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;

        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }

        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }

        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }

        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }

        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
};

using std::__gcd;
using std::abs;
using namespace MySpace;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;


ll n, k;
ll a[5000];

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    ll s = 0, ans = 1e18, ge = 0;
    for (int i = 0; i < n; i++)
    {
        a[i] = i + k;
        s += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        ll t = s - a[i];
        ans = min(ans, abs(t - s));
        if (ans == abs(t - s))
            ge = t;
    }
    cout << ge;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = n;
    ll sum = 1;
    ll cnt = 0;
    for(ll i = 3;; i *= 3){
        if(sum*2+i-1 > n)   break;
        cnt++;
        ll tmp = cnt*2-1;
        ll res = n-sum-sum+1;
        ll cp = i;
        while(res){
            tmp += res/cp;
            res -= res/cp*cp;
            cp /= 3;
        }
        ans = min(ans, tmp);
        sum += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iterator>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N, cnt = 0;
    cin >> N;
    vector<string> S;
    string str;
    rep(i, N){
        cin >> str;
        S.insert(S.end(), str);
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 11668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>=a-b&&a+b>=a*b)
        cout<<a+b;
    else if(a-b>=a+b&&a-b>=a*b)
        cout<<a-b;
    else if(a*b>=a-b&&a*b>=a+b)
        cout<<a*b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){
    int x,n;
    cin>>x>>n;
    vector<int> p(n);
    int buf;
    int min=101;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>buf;
        p[i]=buf;
    }
    for(int i=-100;i<=103;i++){
        if(find(p.begin(),p.end(),i)==p.end()&&abs(x-i)<min){
            min=abs(x-i);
            ans=i;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int B[20];
int A[20][20];

int main()
{
	int N, M, C;
	int sum, ans = 0;

	cin >> N >> M >> C;
	rep(i, M) cin >> B[i];
	rep(i, N) {
		rep(j, M) cin >> A[i][j];
	}

	rep(i, N) {
		sum = 0;
		rep(j, M) {
			sum += A[i][j] * B[j];
		}
		if (sum + C > 0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n, p;
    string s;
    cin >> n >> p >> s;
    if(p==2||p==5){
        ll ans = 0;
        rep(i,0,n){
            if((s[i]-'0')%p==0)ans+=i+1;
        }
        cout << ans;
        return 0;
    }

    vi d(n+1);//累積和
    d[0] = 0;
    ll ten = 1;
    for(int i = 0 ; i < n ; i++){
        d[i+1] = (d[i]+(s[n-1-i]-'0') * ten) % p;
        ten *= 10;
        ten %= p;
    }  //d[i]にi桁まで合計した累積和をpで割った余りが入っている
    vector<ll> r(p);
    ll ans = 0;
    for(int i = 0 ; i <= n ; i++){
        r[d[i]]++;
    }
    for(int i = 0 ; i < p ; i++){
        ans += r[i]*(r[i]-1)/2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,k;
  cin >> n >> k;
  cout << (k == 1? 0 : n - k) << endl;
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> st;
  for(int i=0;i<n;i++){
    if (s[i] == '('){
      st.push('(');
    }else{
      if (!st.empty()){
        if (st.top() == '('){
          st.pop();
        }else{
          st.push(')');
        }
      }else{
        st.push(')');
      }
    }
  }
  while(!st.empty()){
    if (st.top() == '('){
      s += ")";
      st.pop();
    }else if (st.top() == ')'){
      s = "(" + s;
      st.pop();
    }else{
      break;
    }
  }
  cout << s << endl;
  return 0;
}

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

int main() {
        int a, b;
        cin >> a >> b;
        if (a <= b) {
                cout << "Impossible" << endl;
                return 0;
        }
        int n = a + b;
        vector<int> graph;
        graph.push_back(0);
        int enough = b + 1;
        for (int i = 1; i < n; i ++) {
                cout << "? " << graph.back() << ' ' << i << endl;
                char res;
                cin >> res;
                if (res == 'Y') {
                        graph.push_back(i);
                        if (enough <= graph.size()) break;
                } else {
                        if (graph.size() == 1) {
                                graph.pop_back();
                                graph.push_back(i + 1);
                                i ++;
                        } else {
                                graph.pop_back();
                        }
                }
        }
        int honest = graph.back();
//cerr << honest << endl;
        string ans = "";
        for (int i = 0; i < n; i ++) {
                cout << "? " << honest << ' ' << i << endl;
                char res;
                cin >> res;
                if (res == 'Y') ans += '1';
                else ans += '0';
        }
        cout << "! " << ans << endl;
        return 0;
}



Measured memory_bytes: 724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextLong();
		long[] sum = new long[n];
		sum[0] = a[0];
		for(int i = 0 ; i < n - 1 ; i++) {
			sum[i + 1] = sum[i] + a[i + 1];
		}
		long ans = Long.MAX_VALUE;
		for(int i = 0 ; i < n - 1 ; i++) {
			long x = sum[i];
			long y = sum[n - 1] - sum[i];
			ans = Math.min(ans, Math.abs(x - y));
		}
		System.out.println(ans);
	}
}


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

void Print(vector<string>& svec, string& str, int i, int j)
{
    svec.push_back(string(str.begin()+i, str.begin()+j+1));
}

void Replace(string& str, string target, int i, int j)
{
    str.replace(str.begin()+i, str.begin()+j+1, target);
}

void Reverse(string& str, int i, int j)
{
    reverse(str.begin()+i, str.begin()+j+1);
}

int main(int argc, char* argv[])
{
    string origin;
    int lines;
    vector<string> strvec;
    cin >> origin >> lines;
    for (int i = 0; i < lines; i++)
    {
        string operation;
        cin >> operation;
        if(operation=="replace")
        {
            int i,j;
            string tmpstr;
            cin >> i >> j >> tmpstr;
            Replace(origin, tmpstr, i, j);
        }else if(operation=="reverse")
        {
            int i,j;
            cin >> i >> j;
            Reverse(origin, i, j);
        }else if(operation=="print")
        {
            int i,j;
            cin >> i >> j;
            Print(strvec, origin, i, j);
        }
    }
    for (auto var : strvec)
    {
        cout << var << endl;
    }
    return 0;
}



Measured memory_bytes: 3196
#include <iostream>

using namespace std;
int a[6],k,flag;
int main()
{
    for(int i=1;i<=5;i++)
        cin>>a[i];
     cin>>k;
    flag=0;
    for(int i=1;i<=4;i++)
        for(int j=i+1;j<=5;j++)
       {
        int d=a[j]-a[i];
        if (d>k) flag=1;
       }
    if (flag==0) cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    ll dp[H+1][W+1] = {};
    //rep(i,0,H+1)dp[i][0] = 0;
    //rep(j,0,W+1)dp[0][j] = 0;
    dp[0][0] = 1;
    vector<string> V(H);
    rep(i,0,H)cin >> V[i];
    rep(i,0,H)rep(j,0,W){
        dp[i][j] %= MOD;
        if(V[i][j] != '#'){
            dp[i+1][j] += dp[i][j];
            dp[i][j+1] += dp[i][j];
        }
    }
    cout << dp[H-1][W-1] % MOD << endl;
}

Measured memory_bytes: 9088
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

 int main(){ 
   ll n,a[5]; ll ma=0;
   cin >>n;
   for(int i=0;i<5;i++){
     cin >> a[i];
     ma=max(ma,(n-1)/a[i]);
   }
   
   cout << 5+ma <<endl;
 }

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

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }

    vector<int> b;
    if(N%2 == 1){
        for (int i = N-1; i >= 0; i-=2){
            b.push_back(a[i]);
        }
        for (int i = 1; i < N; i+=2){
            b.push_back(a[i]);
        }
    } else {
        for (int i = N-1; i >= 0; i-=2){
            b.push_back(a[i]);
        }
        for (int i = 0; i < N; i+=2){
            b.push_back(a[i]);
        }
    }

    int x = b.size();
    rep(i, x){
        cout << b[i];
        if(i != x-1){
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
}

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  
  int answer = 0;
  
  if(op == '+')
    answer = a + b;
  if(op == '-')
    answer = a - b;
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
} 

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==5 && B==5 && C==7){
    cout << "YES" << endl;
  }
  else if(A==5 && B==7 && C==5){
    cout << "YES" << endl;
  }
  else if(A==7 && B==5 && C==5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]


def main():
    a, b, n = map(int, input().split())
    x = min(b-1, n)
    print(floor(a*x/b) - a*floor(x/b))

if __name__ == '__main__':
    main()



Measured memory_bytes: 9476