akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import sys

H, W = map(int, input().split())
I = np.array(sys.stdin.read().split(), np.int64).reshape(H,-1)
grid = np.zeros([H,W])
grid[np.where(I%2==1)] = 1

h_move = np.zeros([H,W-1])
s = np.zeros(H)
for i in range(H):
	cond = 0
	for j in range(W):
		if cond == 0:
			if grid[i,j] == 0:
				continue
			else:
				if j == W-1:
					s[i] = 1
				else:
					h_move[i,j] = 1
					cond = 1
		else:
			if grid[i,j] == 0:
				if j == W-1:
					s[i] = 1
				else:
					h_move[i,j] = 1
			else:
				cond = 0
	
v_move = np.zeros(H)
cond = 0
for i in range(H-1):
	if cond == 0:
		if s[i] == 0:
			continue
		else:
			v_move[i] = 1
			cond = 1
	else:
		if s[i] == 0:
			v_move[i] = 1
		else:
			cond = 0

n = h_move.sum() + v_move.sum()

print(int(n))
for i in range(H):
	for j in range(W-1):
		if h_move[i,j] == 1:
			print(i+1,j+1,i+1,j+2)
for i in range(H-1):
	if v_move[i] == 1:
		print(i+1,W,i+2,W)


Measured memory_bytes: 22384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	vector<int> ab(n);
	vector<int> bc(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	for (int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	for (int i = 0; i < n; i++){
		if (b[i] <= a[0]) ab[i] = 0;
		else if (b[i] > a[n-1]) ab[i] = n;
		ab[i] = lower_bound(a.begin(), a.end(), b[i]) - a.begin();

		if (b[i] >= c[n-1]) bc[i] = 0;
		else if (b[i] < c[0]) bc[i] = n;
		bc[i] = c.end() - upper_bound(c.begin(), c.end(), b[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++){
		ans += (ll)ab[i]*bc[i];
	}
	cout << ans << endl;
	return 0;
 }



Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#define MAX 1000000000

int R[MAX];

int main() {
    int n;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        int tmp = 0;
        std::cin >> tmp;
        R[i] = tmp;
    }
    
    int minv = R[0];
    int maxv = R[1] - R[0];
    for (int j = 1; j < n; j++) {
        if ( maxv < R[j] - minv ) maxv = R[j] - minv;
        if ( minv > R[j] ) minv = R[j];
    }
    printf("%d\n", maxv);
    
    return 0;
}

Measured memory_bytes: 3964
n = int(input())
s = map(int,input().split())
cnt = 0
t = sorted(s)
 
for i in range(n):
    a = t[i]
    for j in range(i+1, n):
        b = t[j]
        for k in range(j+1, n):
            c = a + b
            if t[k] < (a+b) and a < (b+t[k]) and b < (a+t[k]) and a != b and b != t[k] and a != t[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9112
n = int(input())
a = list(map(int, input().split()))

print(" ".join(map(str, a)))
for i in range(1, n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(" ".join(map(str, a)))


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

int main()
{
	int x;
	int i = 1;
	while (cin >> x)
	{
		if (x == 0)
		{
			break;
		}
		cout << "Case " << i++ << ": " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			String name[]=new String[n];
			int time[][]=new int[n][];
			int length[]=new int[n];
			int point[]=new int[n];
			for(int i=0; i<n; i++){
				name[i]=sc.next();
				point[i]=0;
				length[i]=sc.nextInt();
				time[i]=new int[length[i]];
				for(int j=0; j<length[i]; j++){
					time[i][j]=sc.nextInt();
				}
			}//テ」ツ?禿」ツ?禿」ツ?セテ」ツ?ァinput
			
			for(int i=0; i<n; i++){
				Arrays.sort(time[i]);
			}
			//kテヲツ卍づ・ツ按サテ」ツ?ォテ・ツ?凖」ツ?」テ」ツ?ヲテ」ツつ凝、ツコツコテ」ツ?ョテ」ツδ敕」ツつ、テ」ツδウテ」ツδ暗」ツつ津ヲツアツづ」ツつ?」ツつ?
			for(int k=0; k<30; k++){
				int count=0;
				//テヲツ卍づ・ツ按サkテ」ツ?ォテ、ツスツ陛、ツコツコテヲツ伉?」ツ?」テ」ツ?ヲテ」ツつ凝」ツ??
				for(int i=0; i<n; i++){
					for(int j=0; j<length[i]; j++){
						if(time[i][j]==k){
							count++;
							break;
						}
						else if(k < time[i][j]) break;
					}
				}
				//テヲツ卍づ・ツ按サkテ」ツ?ォテ・ツ?凖」ツ?」テ」ツ?ヲテ」ツつ凝、ツコツコテ」ツ?ォテ」ツδ敕」ツつ、テ」ツδウテ」ツδ暗」ツつ津ィツカツウテ」ツ??
				for(int i=0; i<n; i++){
					for(int j=0; j<length[i]; j++){
						if(time[i][j]==k){
							point[i]+=(n-(count-1));
							break;
						}
						else if(k < time[i][j]) break;
					}
				}
			}
			//テヲツ慊?・ツーツ湘」ツ?ョテ」ツδ敕」ツつ、テ」ツδウテ」ツδ暗」ツ?ョテ・ツ・ツエテ」ツつ津ヲツ篠「テ」ツ??
			int min=2<<15;
			int index=-1;
			for(int i=0; i<n; i++){
				if(point[i] < min){
					min=point[i];
					index=i;
				}
				else if(point[i]==min){
					if(name[i].compareTo(name[index]) < 0){
						min=point[i];
						index=i;
					}
				}
			}
//			for(int i=0; i<n; i++){
//				System.out.println(point[i]+" "+name[i]);
//			}
			System.out.println(point[index]+" "+name[index]);
		}

	}
}

Measured memory_bytes: 35080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
        string n;
        cin >> n;
        if(n == "ARC")
        cout << "ABC";
        else
        cout << "ARC";
}









Measured memory_bytes: 3636
// AOJ 1064: Yanagi's Comic
// 2018.1.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int id, x1, y1, x2, y2; char used; } T;
T tbl[10];
int ans[10];
int order;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { if (a->x1 - b->x1) return a->x1 - b->x1; return a->y1 - b->y1; }

void calc(T *t, int n)
{
	int i, j, x, y, xx, yy;
	T tmp[10];

	qsort(t, n, sizeof(T), cmp);
	ans[t[0].id] = ++order, t[0].used = 1;

	y = t[0].y2, x = 501;
	for (i = 0; i < n; i++) {
		if (t[i].used) continue;
		if (t[i].y1 < y && y < t[i].y2) { x = t[i].x1; break; }
	}

	xx = yy = 501, j = 0;
	for (i = 0; i < n; i++) {
		if (t[i].used) continue;
		if (t[i].y2 <= y && t[i].x2 <= x) tmp[j++] = t[i], t[i].used = 1;
	}
	if (j > 0) calc(tmp, j);

	for (i = 0; i < n; i++) if (t[i].used == 0) calc(t+i, n-i);
}

int main()
{
	int n, x1, y1, x2, y2;
	int cno, i;

	cno = 0; while (n = in()) {
		for (i = 0; i < n; i++) {
			x1 = in(), y1 = in(), x2 = in(), y2 = in();
			tbl[i].id = i, tbl[i].used = 0;
			if (x1 <= x2) tbl[i].x1 = x1, tbl[i].x2 = x2;
			else          tbl[i].x1 = x2, tbl[i].x2 = x1;
			if (y1 <= y2) tbl[i].y1 = y1, tbl[i].y2 = y2;
			else          tbl[i].y1 = y2, tbl[i].y2 = y1;
		}

		order = 0;
		calc(tbl, n);

		if (!cno) cno = 1;
		else putchar('\n');
		for (i = 0; i < n; i++) printf("%d\n", ans[i]);
	}
	return 0;
}


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

int main() {
  string a,b;
  cin>>a>>b;
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem2399 : Save Your Privacy! **/
int main()
{
	int N;
	while (cin>>N, N) {
		vector<vector<int> > list(N, vector<int>());
		rep(i, N) {
			int m; cin>>m;
			rep(j, m) {
				int a; cin>>a;
				list[i].push_back(a-1);
			}
		}
		int K; cin>>K;
		vector<int> t(K);
		rep(i, K) {
			cin>>t[i];
			t[i]--;
		}
		
		int cnt=0; int ans=-1;
		rep(i, N) {
			bool ok=true;
			rep(j, K) {
				if (find(list[i].begin(), list[i].end(), t[j]) == list[i].end())
					ok = false;
			}
			
			if (ok) {
				cnt++;
				ans = i+1;
			}
		}
		
		cout << (cnt==1?ans:-1) << endl;
	}
}

Measured memory_bytes: 1268
import math
N,M= map(int, input().split())
a = list(map(int, input().split()))
A=[0]*N
#２で何回割れるか
for i in range(N):
    num=0
    while a[i]%2==0:
        num+=1
        a[i]=int(a[i]/2)
    A[i]=num

for i in range(N):
    if A[0]==A[i]:
        s=True
    else:
        s=False
        break
if s:
    M=M/(2**(A[i]-1))
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    def lcm(a, b):
        return a * b // gcd (a, b)
    ak=a[0]
    for i in range(N):
        ak=lcm(ak,a[i])
    #print(ak)
    if ak>M:
        print(0)
    else:
        print(math.ceil(int(M/ak)/2))
else:
    print(0)

Measured memory_bytes: 86664
#include <bits/stdc++.h>
#define maxn 200010
#define INF 0x3f3f3f3f 
using namespace std;
struct Edge{
	int to,next,val;
	Edge(int a=0,int b=0,int c=0){
		to=a,next=b,val=c;
	}
}l[maxn<<1][2];
int head[maxn][2],cnt[2],n,m;
long long dis[maxn][2],res[maxn];
void SPFA(int s,int k){
	queue<int>q;int vis[maxn];
	memset(vis,0,sizeof(vis));
	memset(dis,INF,sizeof(dis));
	q.push(s),dis[s][k]=0;
	while(!q.empty()){
		int hq=q.front();q.pop();vis[hq]=0;
		for (int i=head[hq][k];i;i=l[i][k].next){
			int v=l[i][k].to;
			if (dis[v][k]>dis[hq][k]+l[i][k].val){
				dis[v][k]=dis[hq][k]+l[i][k].val;
				if (!vis[v]) vis[v]=1,q.push(v);
			}
		}
	}
	for (int i=1;i<=n;i++) res[i]+=dis[i][k];
}
void add(int a,int b,int c,int k){
	l[++cnt[k]][k]=Edge(b,head[a][k],c);
	head[a][k]=cnt[k];
}
int main(){
	ios::sync_with_stdio(false);
	int s,t; cin>>n>>m>>s>>t;
	for (int i=1;i<=m;i++){
		int x,y,a,b;
		cin>>x>>y>>a>>b;
		add(x,y,a,0),add(y,x,b,1);
		add(y,x,a,0),add(x,y,b,1);
	}
	SPFA(s,0),SPFA(t,1);
	for (int i=n-1;i>=1;i--) res[i]=min(res[i+1],res[i]);
	for (int i=1;i<=n;i++) cout<<1000000000000000-res[i]<<endl;
}

Measured memory_bytes: 17536
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut t: usize = 0;
    let mut a: usize = 1;
    while a <= n {
        let mut b: usize = 1;
        while b <= n / a {
            if a*b < n {
                t = t + 1;
            }
            b = b + 1;
        }
        a = a + 1;
    }
    println!("{}", t);
}


Measured memory_bytes: 2180
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = 0

def syori(k):
    return k*(k-1) // 2


a_count = Counter(a)
a_value = a_count.values()
for j in a_value:
    cnt += syori(j)

for i in a:
    jud = a_count[i]
    print(cnt - (jud-1))

Measured memory_bytes: 26780
N, M, K = map(int, input().split())
mod = 10**9+7

# comb init
nmax = 2 * 10 ** 5 + 1  # change here
fac = [0] * (nmax + 1)
finv = [0] * (nmax + 1)
inv = [0] * (nmax + 1)
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2, nmax):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def comb(n, r):
    if n < r:
        return 0
    else:
        return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod


def s(k):
    return ((k * (k+1) * (2 * k + 1))%mod * inv[6] + (k * (k+1) * inv[2])%mod)%mod


C = comb(N*M-2, K-2)
print(((C * ((N ** 2 * s(M-1))%mod + (M ** 2 * s(N-1))%mod)%mod)%mod) * inv[2]%mod)


Measured memory_bytes: 44144
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,b,r;
	cin>>n>>b>>r;
cout<<n/(b+r)*b+min(n%(b+r),b)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n, p = map(int, readline().split())
s = readline().rstrip().decode()
cnt = 0
if p == 2 or p == 5:
    for i, ss in enumerate(s):
        if int(ss) % p == 0:
            cnt += (i + 1)
else:
    memo = [0]
    m = 0
    d = 1
    for ss in s[::-1]:
        m += int(ss) * d
        m %= p
        d *= 10
        d %= p
        memo.append(m)
    counter = Counter(memo)
    for i in range(p + 1):
        cnt += counter[i] * (counter[i] - 1) // 2
print(cnt)


Measured memory_bytes: 11952
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
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 read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:i32,T:i32,CT:[(i32,i32);N]);
    let CT:Vec<(i32,i32)> = CT;
    println!("{}",match CT.into_iter().filter(|&(_,t)| t <=T).min(){
        Some(ans) => (ans.0).to_string(),
        None => String::from("TLE")
    });
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

ll N;

int main() {
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        for (ll j = i; j <= N; j+=i) ans += j;
    }
    PRINT(ans);
    return 0;
}

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

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  
  if(A>=K){
    cout << A - K << " " << B << endl;;
    return 0;
  }
  
  K = K -A;
  
  if(B>=K){
    cout << "0 " << B-K << endl;
    return 0;
  }
  
  cout << "0 0" << endl;
}

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

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

    long A[n+1];
    long B[n];

    for (int i = 0; i < n + 1;i++){
        cin >> A[i];
    }
    for (int i = 0; i < n;i++){
        cin >> B[i];
    }
    long sum = 0;

    for (int i = 0; i < n;i++){
        for (int j = 0; j < 2;j++){
            if(B[i] >= A[j+i]){
                B[i] -= A[j+i];
                sum += A[j+i];
                A[j+i] = 0;
            }else{
                sum += B[i];
                A[j+i] -= B[i];
                B[i] = 0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int mo=1e9+7;
int n,m,G[15],E[15],f[1<<15],bt[1<<15],S;
int main()
{
	int i,j,k,x,y;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d",&x,&y);
		x--,y--,G[y]|=(1<<x);
		E[x]|=(1<<y);
	  }
	for(i=1;i<(1<<n);i++)
		bt[i]=bt[i-(i&(-i))]+1;
	f[0]=1,S=(1<<n)-1;
	for(i=1;i<(1<<n);i++)
		for(j=i;j;j=(j-1)&i){
			if((j&1)^((j>>1)&1)) continue;
			x=1;
			for(k=0;k<n;k++){
				if((j>>k)&1)
					x=(1LL*x*(1<<bt[G[k]&(i^j)]))%mo;
				if((~i>>k)&1)
					x=(1LL*x*((1<<bt[E[k]&j])-1))%mo;
			  }
			f[i]=(f[i]+1LL*f[i^j]*x)%mo;
		  }
	int ans=1;
	for(i=1;i<=m;i++) ans=(ans+ans)%mo;
	cout<<(ans+mo-f[(1<<n)-1])%mo;
	return 0;
}


Measured memory_bytes: 512
from collections import deque
k = int(input())
lunlun = deque([])
ans = 0

# 一桁のルンルン数
for i in range(1, 10):
    lunlun.append(str(i))
if k < 10:
    ans = lunlun[k - 1]

# 二桁以上のルンルン数
cnt = 9
while cnt < k + 1:
    # 1番小さなルンルン数を抜き出す
    l = lunlun.popleft()
    l_last = int(l[-1])
    if l_last != 0:
        lunlun.append('{}{}'.format(l, l_last - 1))
        cnt += 1
        if cnt == k:
            ans = lunlun[-1]
            break
    lunlun.append('{}{}'.format(l, l_last))
    cnt += 1
    if cnt == k:
        ans = lunlun[-1]
        break
    if l_last != 9:
        lunlun.append('{}{}'.format(l, l_last + 1))
        cnt += 1
        if cnt == k:
            ans = lunlun[-1]
            break

print(ans)

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

int main()
{
    int h , w;
    string s;
    //vector<long> v;
    //long sum = 0;
    cin >> h >> w ;
    for(int i = 0 ; i < h ; i++){
        cin >> s;
        cout << s << endl;
        cout << s << 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 REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    itn x,n;
    cin >> x >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int cnt = 1;
    int rei = 0;
    int up = 101;
    bool flag = true;
    if(n == 0){
        println(x);
        return 0;
        
    }
    REP(i,n){
        if(a[i] == x){
            flag = false;
            break;
        }
    }
    if(flag) {
        println(x);
        return 0;
    }
    REP(i,n){
        if(cnt >= x)
            break;
        if(a[i] == cnt)
            cnt ++;
        else{
             rei = cnt;
             cnt++;
             i--;
        }
    } 
    cnt =100;
    REPR(i,n){
        if(cnt <= x)
            break;
        if(a[i] == cnt)
            cnt --;
        else{
            up = cnt;
            cnt--;
            i++;
        }
    }
    int diff = 0;
    if(abs(0 - x) <= abs(101 - x))
        diff = 0;
    else diff = 101;
    if(abs(rei - x) <= abs(up - x)){
        if(abs(rei - x) < abs(diff - x)){
            println(rei);
            return 0;
        }else if(abs(rei - x) > abs(up - x)){
            println(diff);
            return 0;
        }else{
            println(min(rei,diff));
        }
        
    }else{
        if(abs(up - x) < abs(diff - x)){
            println(up);
            return 0;
        }else if(abs(up - x) > abs(diff - x)){
            println(diff);
            return 0;
        }else{
            println(min(up,diff));
        }
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N){
	ll a;
	cin>>a;
	ans+=a-1;
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 256
h,w,k= map(int, input().split())
c= [list(input()) for i in range(h)]

# 縦横の黒の数
y=[0]*w
x=[0]*h
for i in range(h):
    x[i]=c[i].count('#')

for i in range(w):
    for j in range(h):
        if c[j][i]=='#':
            y[i]+=1
qq=sum(x)

ans=0
for i in range(2**h):
    p=[]
    for i2 in range(h):
        if (i>>i2)&1:
            p.append(i2)
    for j in range(2 ** w):
        cnt = qq
        q = []
        for j2 in range(w):
            if (j >> j2) & 1:
                q.append(j2)
        for v in p:
            cnt -= x[v]
        for v2 in q:
            cnt -= y[v2]
        for v3 in p:
            for v4 in q:
                if c[v3][v4] == '#':
                    cnt += 1

        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 74044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define m 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif
	ll a, b, n;
	cin >> a >> b >> n;
	ll c = n % b;
	if (n - c - 1 > 0)
		n = n - c - 1;
	ll a1 = a * n;
	a1 = a1 / b;
	ll a2 = n / b;
	cout << a1 - a*a2;
	return 0;
}

Measured memory_bytes: 3632
import sys

def solve():
    while True:
        n = input()
        if n > 0:
            mat = [[0 for i in xrange(n + 1)] for j in xrange(n + 1)]
            for i in range(n):
                line = sys.stdin.readline().split()
                for j in range(n):
                    mat[i][j] = int(line[j])
            for i in xrange(n):
                mat[i][n] = sum(mat[i][j] for j in range(n))
                mat[n][i] = sum(mat[j][i] for j in range(n))
            mat[n][n] = sum(mat[n][i] for i in range(n))
            for lst in mat:
                print "".join(map(lambda n: "%5d" % n, lst))
        else:
            sys.exit()

if __name__ == "__main__":
    solve()

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

struct node {
    int x,y,num,cnt;
} Node[100005];

bool cmp1(node a,node b){
    if(a.x != b.x)
        return a.x < b.x;
    else return a.y < b.y;
}

bool cmp2(node a,node b){
    return a.num < b.num;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&Node[i].x,&Node[i].y);
        Node[i].num = i;
    }
    sort(Node+1,Node+1+m,cmp1);

    Node[0].cnt = 1;
    int Cnt = 1;
    for(int i=1;i<=m;i++){
        if(Node[i].x != Node[i-1].x){
            Cnt = 1;
            Node[i].cnt = Cnt;
        }
        else Node[i].cnt = ++Cnt;
    }

    sort(Node+1,Node+1+m,cmp2);
    for(int i=1;i<=m;i++){
        printf("%06d%06d\n",Node[i].x,Node[i].cnt);
    }

    return 0;
}


Measured memory_bytes: 3072
N, K = map(int, input().split())
mod = 10 ** 9 + 7
G = [1] * (K + 1)  #そのindexを最大公約数にもつ数列の数
ans = 0
for k in range(K, 0, -1):
    x = K // k
    t = int(pow(x, N, mod))
    for j in range(x - 1):
        t -= G[(j + 2) * k]
    G[k] = t
    ans += t * k
    ans %= mod

print(ans)





Measured memory_bytes: 74504
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
  int A, B, X; cin >> A >> B >> X;
  int V = A * A * B;
  long double res;
  if (2 * X >= V) {
    res = atan2l((long double) (2 * (V - X)), (long double) (A * A * A));
  } else {
    res = atan2l((long double) (B * A * B), (long double) (2 * X));
  }
  res *= 360 / (2 * acosl((long double) -1));
  cout << setprecision(10) << res << endl;
}

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

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

using namespace std;

/////////////////////////////////////////////////////

ll N, M;

ll i, j, k;
int main(){
    scanf("%lld%lld", &N, &M);
    printf("%lld", (N * (N - 1)) / 2 + (M * (M - 1)) / 2);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <list>
#include <stack>
#define lar(a, b) ((a>b) ? (a):(b))
#define sml(a, b) ((a<b) ? (a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> p;

int main(void) {
    ll n, m;
    cin >> n >> m;
    ll i, a, b;
    int ship1[200010]={0};
    int shipn[200010]={0};
    for(i=0; i<m; i++) {
        cin >> a >> b;
        if(a==1)
            ship1[b]=1;
        else if(b==n)
            shipn[a]=1;
    }
    
    for(i=2; i<n; i++) {
        if(ship1[i]==1 && shipn[i]==1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    
}


Measured memory_bytes: 1792
S = input()
#print(S)
SA = S.split("/")
#print(SA)
if int(SA[0]) > 2019:
   out ='TBD'
elif int(SA[0]) == 2019:
   if int(SA[1]) > 4:
      out ='TBD'
   elif int(SA[1]) ==  4:
      if int(SA[2]) <= 30:
         out ='Heisei'
      else:
         out ='TBD'
   else:
         out ='Heisei'
else:
   out ='Heisei'
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, A, B;
        cin >> N >> A >> B;
        vll X(N+1);
        rep(i, 1, N+1) {
                cin >> X[i];
        }

        vll dp(N+1);

        rep(i, 2, N+1) {
                dp[i] += dp[i-1] + min(A * (X[i]-X[i-1]), B);
        }
        cout << dp.back() << endl;
}

Measured memory_bytes: 4844
s = gets.chomp
q = gets.to_i
isReverse = false
l, r = "", ""
q.times do
  t = gets.split
  if t[0].to_i == 1
    isReverse = !isReverse
  else
    f = t[1].to_i
    c = t[2]
    isBack = (f == 1 && isReverse) || (f == 2 && !isReverse)
    if isBack
      r << c
    else
      l << c
    end
  end
end
ans = l.reverse + s + r
ans.reverse! if isReverse
puts ans

Measured memory_bytes: 3196
/*
ID: Motyaspr
LANG: C++11
TASK: dualpal
*/

#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <cassert>
#include <cstdlib>
#include <bitset>
#include <algorithm>
#include <string>
#include <list>
#include <fstream>
#include <cstring>
#include <climits>
#include <stack>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define forn(i, n) for(int i = 0; i < n; i++)
#define pk push_back
#define mk make_pair
#define all(v) v.begin(), v.end()
#define X first
#define Y second
#define TASK "party"

const double EPS = 1e-9;
const double pi = acos(-1.0);

const int MAXN = (int)2e5 + 7;
const ll INF = (ll)1e9 + 7;
const ll LINF = (ll)1e9 + 7;
const ll MOD = (ll)1e9 + 7;;
const ll P = 31;
const ll SZ = (ll)1e5;

int n, m;

pair<int, int> up[MAXN];

pair<int, int> low[MAXN];

vector<pair<int, double>> loww, upp;

bool usedl[MAXN], usedu[MAXN];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	if ('A' <= s2[0] && s2[0] <= 'Z')
		cout << "A" << s2[0] << "C";
	else
		cout << "A" << char(int(s2[0]) - 32) << "C";
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.buffer.readline

N=int(readline())
s=[readline().rstrip().decode("utf-8") for _ in range(N)]
#print(s)

A,B,AB,BA=0,0,0,0
for ss in s:
  for i in range(len(ss)-1):
    if ss[i]=="A" and ss[i+1]=="B":
      AB+=1
  if ss[-1]=="A": A+=1
  if ss[0]=="B": B+=1
  if ss[-1]=="A" and ss[0]=="B": BA+=1
A-=BA
B-=BA
#print("AB,BA,A,B:",AB,BA,A,B)

if BA>1:
  AB+=BA-1
  BA=1
#print("AB,BA,A,B:",AB,BA,A,B)

if BA==1:
  if A>0 or B>0:
    if A>0:
      AB+=1
      A-=1
    if B>0:
      AB+=1
      B-=1
    BA-=1
#print("AB,BA,A,B:",AB,BA,A,B)

AB+=min(A,B)
print(AB)

Measured memory_bytes: 42480
#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)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	int ans=0;
	for(int i=1;i<=n;++i){
		int x;
		cin >> x;
		ans+=min(x,abs(k-x))*2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=62;
int ask(string s)
{
	cout<<"? "<<s<<endl;
	int x;
	cin>>x;
	return x;
}
int n,a[N];
string c="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY0123456789";
string f(int l,int r)
{
	if(l==r)
		return string(a[l],c[l]);
	string x=f(l,(l+r)/2),y=f((l+r)/2+1,r);
	for(int i=0,j=0;i<=x.size();i++)
		for(;j<y.size()&&ask(x.substr(0,i)+y[j]+x.substr(i))==n-(int)x.size()-1;i++,j++)
			x.insert(x.begin()+i,y[j]);
	return x;
}
int main()
{
	ios::sync_with_stdio(false);
	for(int i=0;i<62;i++)
	{
		a[i]=128-ask(string(128,c[i]));
		n+=a[i];
	}
	string zh=f(0,61);
	cout<<"! "<<zh<<endl;
	return 0;
}

Measured memory_bytes: 3768
import sys

def tax(p,x):
    return int(p*(100+x)/100)


while True:
    x,y,s=[int(i) for i in  input().split(" ")]

    if x==0 and y==0 and s==0:
        sys.exit()

    maximum=0
    p=int(100*s/(100+x))
    for i in range(1,s):
        for j in range(p-i-3,p-i+3):
            if tax(i,x)+tax(j,x)==s and j>0:
                maximum=max(tax(i,y)+tax(j,y),maximum)

    print(maximum)

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

int main() {

	int a, b, c;
	int n = 0;

	cin >> a;
	cin >> b;
	cin >> c;

	for (int i = a; i <= b; i++)
	{
		if (c%i == 0)
			n++;
	}

	cout << n << endl;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    
    map<int, int> mp;
    loop(i, 3){
        int a; cin >> a;
        mp[a]++;
    }

    cout << mp.size() << 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,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>v(n);
  rep(i,n)cin >> v[i];
  ll x = 0;
  for(ll i = 50; i >= 0; i--){
    ll ok = k - x;
    if(ok >= pow(2,i)){
      int cnt = 0;
      rep(j,n)if(!((v[j] >> i) & 1))cnt++;
      if(cnt >= (n + 1) / 2){
        x += pow(2,i);
      }
    }
  }
  ll ans = 0;
  rep(i,n)ans += (v[i] ^ x);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4500
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,k,a[200]={0},b[200];
	cin>>n>>k;
	int t;
	int c;
	while(k>0)
	{
	 cin>>t;
	 for(int i=1;i<=t;i++)
	 {
	 	cin>>c;
	 	a[c]=1;
	 }
	 k--;
	}
	int r=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0)
		r++;
	}
	cout<<r<<endl;
	 
	 
}

Measured memory_bytes: 3192
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,A,B;
	int[] t;
	public void solve() {
		N = nextInt();
		A = nextInt();
		B = nextInt();

		t = new int[N];
		for(int i = 0;i < N;i++){
			t[i] = nextInt();
		}
		int cnt = 0;
		for(int i = 0;i < N;i++){
			if(A <= t[i] && t[i] < B){
				cnt++;
			}
		}
		out.println(N - cnt);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 8276
#include<iostream>
using namespace std;
#include<cmath>
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n;
	while (cin >> n, n) {
		if (isprime(n))cout << "0\n";
		else {
			int r, l;
			for (r = n - 1; !isprime(r); r--);
			for (l = n + 1; !isprime(l); l++);
			cout << l - r << endl;
		}
	}
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int N;
    ll A[100001] ={}, sum = 0;
    cin >> N; 
    REP(i, N){
      cin >> A[i];
      sum = sum ^ A[i];
    } 
    //cout << bitset<6>(~sum) << endl;
    REP(i, N){
        A[i] = A[i] & (~sum);
        //cout << bitset<6>(A[i]) << endl;
    }
    int rank = 0;
    ll now;
    bool flag;
    for(int i = 59; i >=0; i-- ){
      ll ch = (ll) 1 << (ll)i;
      //cout << bitset<60>(ch) << endl;
      flag = false;
      for(int j=rank; j<N; j++){
        if(ch & A[j]){
          now = A[j];
          swap(A[j], A[rank]);
          flag = true;
          break;
        }
      }
      if(flag){
        REP(j, N){
          if(j != rank && (A[j] & ch)){
            A[j] = A[j] ^ now;
          }
        }
        rank++;
      }
    }
    REP(i, N){
      //cout << bitset<6>(A[i]) << endl;
      ans = ans ^ A[i];
    }
    ans = ans * 2 + sum;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ms = 1e5+9;

ll vet[ms],n;

ll resp(ll soma, ll ans, int f){
	ll val;
	for(ll i = 1;i<n;i++){
		val = vet[i];
		soma += val;
		if(f){		
			if(soma == 0){
				ans+=1;
				soma++;
			}else if(soma < 0){
			
				ans +=((-soma)+1);
				soma = 1;
			}
		}else{
		
			if(soma == 0){
				ans++;
				soma--;
			}else if(soma > 0){
				
				ans += (soma +1);
				soma = -1;
			}
		}
		f = 1-f;
}
	return ans;

}

int main(){
	ll f = 0;
	cin >> n;
	for(ll i= 0;i<n;i++) cin >> vet[i];
	int soma = vet[0];
	ll ans = 0x3f3f3f3f3f3f3f3f;
	if(soma < 0){
		ans = min(ans,resp(soma,0,1));
		ans = min(ans,resp(1,0-soma+1,0));	
	}else if(soma > 0){
		ans = min(ans, resp(soma,0,0));
		//cout<<ans<<"\n";
		ans = min(ans, resp(-1,0+soma+1,1));
		//cout<<ans<<"\n";
		
	}else if(soma == 0){
		ans = min(resp(-1,1,1),ans);
		ans = min(resp(1,1,0),ans);
	}
		
	cout<<ans<<"\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, k;
    string s;
    cin >> n >> s >> k;
    char w = s[k - 1];
    for (int i = 0; i < n; ++i) {
        if (s[i] != w) {
            s[i] = '*';
        }   
    }   
    cout << s << endl;
}

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

int main() {
	ll n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll a;
		cin>>a;
		sum+=a;
	}
	if(n-sum>=0)cout<<n-sum<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<complex>
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
template<class T> T at(vector<T> v, int i) {return v[i % v.size()];}


#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

// 比較関数
int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}

// 平方根
D sr(D a) {return sqrt(max(a, (D)0));}

// 内積
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// 外積
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// 線分のベクトル
P vec(L a) {return a.b - a.a;}

// 有向角度
D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

// 射影
P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}

// 距離
D dLP(L l, P p) {return abs(det(vec(l), p - l.a) / vec(l));}
D dSP(L s, P p) {
  if (dot(vec(s), p - s.a) < 0) return abs(p - s.a);
  if (dot(vec(s), p - s.b) > 0) return abs(p - s.b);
  return dLP(s, p);
}

// 円
struct C{P c; D r;};

// 交差判定
bool iCS(C c, L s) {return sig(c.r, dSP(s, c.c)) >= 0;}

// 交点
pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

// 円と円の中心,p1,p2からなる三角形の共通部分面積
D aCT(C c, P p1, P p2) {
  if (!sig(c.r)) return 0;
  p1 -= c.c; p2 -= c.c; c.c = 0;
  if (near(0, p1) || near(0, p2) || near(p1, p2)) return 0;
  if (!iCS(c, (L){p1, p2})) return c.r * c.r * arg(0, p1, p2) / 2;
  bool b1 = sig(abs(p1), c.r) > 0, b2 = sig(abs(p2), c.r) > 0;
  pair<P, P> pp = pCL(c, (L){p1, p2});
  if (b1 && b2) return (c.r * c.r * (arg(0, p1, pp.first) + arg(0, pp.second, p2)) + det(pp.first, pp.second)) / 2;
  if (b1) return (c.r * c.r * arg(0, p1, pp.first) + det(pp.first, p2)) / 2;
  if (b2) return (c.r * c.r * arg(0, pp.second, p2) + det(p1, pp.second)) / 2;
  return det(p1, p2) / 2;
}

// 円と多角形の共通部分面積
D aCPol(C c, Pol pol) {D res = 0; rep (i, pol.size()) res += aCT(c, pol[i], at(pol, i + 1)); return res;}

int main() {
  int n, r;
  cin >> n >> r;
  Pol pol(n);
  rep (i, n) cin >> pol[i].X >> pol[i].Y;
  D res = 0;
  for (int i = 1; i < r; i += 2) res += (2 * i + 1) * PI - (aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol));
  for (int i = 0; i < r; i += 2) res += aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol);
  printf("%.12Lf\n", res);
  return 0;
}

Measured memory_bytes: 1292
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
vector<vector<int>> gh(1e5+1);
int vis[100001];
int cnt = 0;
bool ff = 0;
int n;
vector<int> bfs2(int st){
	queue<int>q;
	vector<int>len(100001, 10000000);
	q.push(st);
	len[st] = 0;
	int dep = 0;
	while (!q.empty()){
		dep++;
		int sz = q.size();
		while (sz--){
			int node = q.front();
			q.pop();
			for (int i = 0; i < gh[node].size(); i++){
				int nxtnode = gh[node][i];
				if (len[nxtnode] == 10000000){
					len[nxtnode] = dep;
					q.push(nxtnode);
				}
			}
		}
	}
	return len;
}
int main()
{
	fast();
	cin >> n;
	for (int i = 0; i < n-1; i++){
		int u, v;
		cin >> u >> v;
		gh[u].push_back(v);
		gh[v].push_back(u);
	}
	vector<int>v1, v2;
	v1 = bfs2(1);
	v2 = bfs2(n);
	int c1=0, c2 = 0;
	for (int i = 2; i < n; i++){
		if (v1[i] <= v2[i])
			c1++;
		else c2++;
	}
	if (c1>c2)
		cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 6656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int main()
{
    int n, x; cin>>n>>x;
    if(x==2){
        cout<<n+1<<endl; return 0;
    }
    if(x==1){
        ll ans=1;
        for(int i=0; i<n; i++){
            ans=ans*2%MOD;
        }
        cout<<ans<<endl;
        return 0;
    }
    ll dp[3001][6001]={};
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=2*i; j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=MOD;
            dp[i+1][j+1]+=dp[i][j];
            dp[i+1][j+1]%=MOD;
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+2]%=MOD;
        }
    }
    ll ans=0;
    for(int i=0; i<x; i++) ans=(ans+dp[n][i])%MOD;
    ll comb[3001][3001];
    comb[0][0]=1;
    for(int i=1; i<=n; i++){
        comb[i][0]=comb[i][i]=1;
        for(int j=1; j<i; j++){
            comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
        }
    }
    for(int i=0; i<=n-2; i++){
        for(int j=(x+1)%2; j<=x-3; j+=2){
            if(n-1-i>=x-2-j){
                ans+=dp[i][j]*comb[n-1-i][x-2-j];
                ans%=MOD;
            }
        }
    }
    if(x&1){
        for(int i=x; i<=n; i++){
            ans+=comb[n][i];
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 210944
#include <iostream>
using namespace std;
int main() {
  int W;
  cin >> W >> W;
  auto a = [&]() { cout << string(W + 2, '#') << endl; };
  a();
  string S;
  while (cin >> S) cout << '#' << S << "#\n";
  a();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int n,m,u,v,w;
int dis[1507][1507],vis[1507],ans[1507],ret=0,mx=0;
vector < pair<int,int> > edge[1507];
vector < int > ed[1507];
const int inf=1e9;
queue <int> q;
void dijkstra(int st){
	priority_queue < pair<int,int> , vector < pair<int,int> > , greater < pair<int,int> > > pr;
	pr.push(mp(0,st));
	while(!pr.empty()){
		int u=pr.top().se;
		int val=pr.top().fi;
		pr.pop();
		if(dis[st][u]!=val) continue;
		for(int i=0;i<(int)edge[u].size();i++){
			int v=edge[u][i].fi;
			int w=edge[u][i].se;
			if(val+w<dis[st][v]){
				dis[st][v]=val+w;
				pr.push(mp(dis[st][v],v));
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v>>w;
		edge[u].pb(mp(v,w));
		edge[v].pb(mp(u,w));
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j) dis[i][j]=0;
			else dis[i][j]=inf;
		}
	}
	for(int i=1;i<=n;i++){
		dijkstra(i);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			mx=max(mx,dis[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) ed[j].clear(), vis[j]=0;
		for(int j=1;j<=n;j++){
			for(int k=0;k<(int)edge[j].size();k++){
				int v=edge[j][k].fi;
				int w=edge[j][k].se;
				if(dis[i][j]+w==dis[i][v]){
					ed[v].pb(j);
				}
			}
			if(dis[i][j]==mx){
				q.push(j);
				vis[j]=1;
			}
		}
		while(!q.empty()){
			int u=q.front();
			q.pop();
			ans[u]=1;
			for(int v:ed[u]){
				if(vis[v]) continue;
				vis[v]=1;
				q.push(v);
			}
		}
	}
	for(int i=1;i<=n;i++) ret+=(ans[i]==0) ? 1:0;
	cout<<ret<<"\n";
	for(int i=1;i<=n;i++){
		if(ans[i]==0) cout<<i<<"\n";
	}
}



Measured memory_bytes: 12256
def print(str,ar)
  puts str[ar[0].to_i..ar[1].to_i]
end
def reverse(str,ar)
  str[ar[0].to_i..ar[1].to_i] = str[ar[0].to_i..ar[1].to_i].reverse
  return str
end
def replace(str,ar)
  str[ar[0].to_i..ar[1].to_i]=ar[2]
  return str
end


def code_run
  str=$stdin.gets.chomp
  ($stdin.gets.to_i).times do
    command,*ar=$stdin.gets.split
    eval(command +"(str,#{ar})" )
  end
end

code_run


Measured memory_bytes: 7152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		String s = sc.next();
		int countJpP = 0, countOvP = 0;
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'c')
				System.out.println("No ");
			else if (s.charAt(i) == 'a') {
				if (countJpP + countOvP < a + b) {
					countJpP++;
					System.out.println("Yes ");
				} else {
					System.out.println("No ");
				}
			} else {
				if (countOvP + 1 <= b && countOvP + countJpP < a + b) {
					System.out.println("Yes ");
					countOvP++;
				} else
					System.out.println("No");
			}

		}
		sc.close();
	}
}


Measured memory_bytes: 52152
<?php

$number = explode(" ", trim(fgets(STDIN)));

$popular = explode(" ", trim(fgets(STDIN)));
rsort($popular);

$count = 0;

foreach($popular as $value){
	if($value >= array_sum($popular)/(4*$number[1])){
		$count++;
	}
	if($count == $number[1]){
		echo "Yes";
		return;
	}
}
echo "No";


Measured memory_bytes: 3576