akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();
    if n % 3 == 0 {
        let mut dict = BTreeMap::new();
        for i in 0..n {
            *dict.entry(v[i]).or_insert(0) += 1;
        }
        if dict.len() >= 4 {
            println!("No");
            return;
        }
        if dict.len() == 1 && v[0] ^ v[0] == v[0] {
            println!("Yes");
            return;
        }
        let v = dict.keys().cloned().collect::<Vec<_>>();
        let counts = dict.values().cloned().collect::<Vec<_>>();
        if dict.len() == 3 {
            //debug!(v);
            //debug!(counts);
            if v[0] == v[1] ^ v[2] && counts[0] == counts[1] && counts[0] == counts[2] {
                println!("Yes");
                return;
            } else {
                println!("No");
                return;
            }
        }
        if dict.len() == 2 {
            if 2 * counts[0] == counts[1] && v[0] == 0 {
                println!("Yes");
                return;
            } else {
                println!("No");
                return;
            }
        }
        println!("No");
    } else {
        if v.iter().all(|&x| x == 0) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <iostream>
using namespace std;
int main() {
    int A,B;
    cin>>A>>B;
    if(A>=6&&A<=12){
        cout<<B/2<<endl;
    }
    else if(A<6){
        cout<<0<<endl;
    }
    else if(A>12){
        cout<<B<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 111;
int N, a[MAX];

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> a[i];
    }
    sort(a, a + N);
    cout << a[N - 1] - a[0] << endl;
}


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

using namespace std;

void func_a() {
    int x, y, z;
    cin >> x;
    cin >> y;
    cin >> z;

    cout << z << " " << x << " " << y << "\n";

}

void func_b() {
    double n, m;
    cin >> n;
    cin >> m;

    double sum = 0;
    vector<double> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= sum / (4 * m) ) {
            ++count;
            if (count == m) break;
        }
    }

    //cout << "sum:" << sum << "\n";
    //cout << "border:" << sum / (4*m) << "\n";
    //cout << "count:" << count << "\n";
    if (count >= m) cout << "Yes";
    else cout << "No";


}

void func_c() {
    long long  n, k;
    cin >> n;
    cin >> k;

    // cout << n << " " << k << "\n";
    n = n % k;
    long long temp = (n - k > 0) ? n - k : k - n;
    if (n > temp) n = temp;

    cout << n;
}

void func_d1()
{
    int k;
    cin >> k;

    unsigned long long n = 0;
    int count = 0;
    while (true) {
        if (k == count) break;

        ++n;
        if (n < 13) {
            ++count;
            continue;
        }

        int judge = 0;
        unsigned long long temp1;
        temp1 = n;
        while (temp1 > 0) {
            int temp2;
            int temp3;
            temp2 = temp1 % 10;
            temp1 /= 10;
            temp3 = temp1 % 10;

            int temp4;
            temp4 = (temp2 - temp3 > 0) ? temp2 - temp3 : temp3 - temp2;
            if (temp4 > 1) {

                break;
            }
            if (temp1 < 10) judge = 1;
        }

        if (judge == 1) ++count;
    }

    cout << n;


}

void func_d2()
{
    int k;
    cin >> k;

    vector<int> vec1 = { 1 };
    vector<int> vec2 = { 2 };
    vector<int> vec3 = { 3 };
    vector<int> vec4 = { 4 };
    vector<int> vec5 = { 5 };
    vector<int> vec6 = { 6 };
    vector<int> vec7 = { 7 };
    vector<int> vec8 = { 8 };
    vector<int> vec9 = { 9 };

    if (k < 10) {
        cout << k;
        return;
    }

    int count = 10;


}

void func_dans() {
    int k;
    cin >> k;

    queue<long long> que;
    for (int i = 1; i < 10; ++i) que.push(i);

    long long n;
    int count = 0;
    while (true) {
        n = que.front();
        que.pop();
        ++count; 

        if (count == k) break;
        if (n % 10 != 0) que.push(n * 10 + (n % 10) - 1);
        que.push(n * 10 + (n % 10));
        if (n % 10 != 9) que.push(n * 10 + (n % 10) + 1);

    }

    cout << n;
 

}

int main()
{
    //func_a();
    //func_b();
    //func_c();
    //func_d1();
    //func_d2();
    func_dans();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    long long n, ans = 1e18;
    cin >> n;
    for(long long i=1;i*i<=n;i++){
        if(n%i == 0){
            long long j = n/i;
            ans = min(ans, i+j-2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

J = [i for i in range(1, N+1)]
JJ = list(itertools.permutations(J))
for i in range(len(JJ)):
    if P == JJ[i]:
        pp = i
    if Q == JJ[i]:
        qq = i
print(abs(pp - qq))

Measured memory_bytes: 8052
import math

def main():
    ABCDE = [int(input()) for _ in range(5)]
    d = [(k, 10 - (k % 10) if k % 10 != 0 else 0,) for k in ABCDE]
    d.sort(key=lambda x:x[1])
    abced = [k[0] for k in d]
    result = 0
    for i in abced[:-1]:
        if i % 10 == 0:
            result += i
        else:
            result += 10 * math.ceil(i / 10)
    result += abced[-1]
    print(result)

if __name__ == "__main__":
    main()

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

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

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

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

	if(b.size()==1){
		cout<<b[0]<<endl;
	}else if(b.size()==2){
		cout<<b[0]+b[1]<<endl;
	}else{
		int m=b[0]+b[1]+b[2];
		for(int i=0; i<b.size()-2; ++i){
			if(m < b[i]+b[i+1]+b[i+2]){
				m=b[i]+b[i+1]+b[i+2];
			}
		}
		cout<<m<<endl;
	}

	return 0;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(i, M) {
        int a;
        cin >> a;
        sum += a;
    }

    cout << (N>=sum ? N-sum : -1) << endl;


    return 0;
}

Measured memory_bytes: 3632
char s[13];
int L;
main(){
  gets(s);
  L=strlen(s);
  for(int l=L;l>=0;l--)for(int i=0;i<=L-l;i++)
  {
    int f=1;
    for(int j=0;j<l;j++)f&=s[i+j]=='A'||s[i+j]=='T'||s[i+j]=='G'||s[i+j]=='C';
    if(f){
      printf("%d",l);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>


int main(void){
	
	int x,k=0;
	char data[10];
	int stack[100];
	
	 while( scanf("%s", data) != EOF ){
  		  if ( data[0] == '+' ){
  		  	k--;
  		  		stack[k-1]=stack[k-1]+stack[k];
		}
		else if(data[0]=='-'){
			k--;
			stack[k-1]=stack[k-1]-stack[k];
		}
		else if(data[0]=='*'){
			k--;
			stack[k-1]=stack[k-1]*stack[k];
		}
		else{
			stack[k]=atoi(data);
			k++;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}

	



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 10);

int n, m;
string t[MAXN];

void read()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> t[i];
}

bool ok[MAXN][MAXN];

void solve()
{
	int pos_x = 0, pos_y = 0;
	while(pos_x != n - 1 || pos_y != m - 1)
	{
		if(t[pos_x][pos_y] != '#') 
		{
			cout << "Impossible" << endl;
			return;
		}

		ok[pos_x][pos_y] = 1;
		if(pos_x != n - 1 && t[pos_x + 1][pos_y] == '#')
		{
			pos_x++;
			continue;
		}

		if(pos_y != m - 1 && t[pos_x][pos_y + 1] == '#')
		{
			pos_y++;
			continue;
		}

		cout << "Impossible" << endl;
		return;
	}

	if(t[n - 1][m - 1] != '#') 
	{
		cout << "Impossible" << endl;
		return;

	}
	else ok[n - 1][m - 1] = 1;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(!ok[i][j] && t[i][j] == '#')
			{
				cout << "Impossible" << endl;
				return;
			}

	cout << "Possible" << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n-1) cin >> a[i];
    
    int ans = a[0];    
    for(int i = 1; i < n-1; i++) {
        ans += min(a[i-1], a[i]);
    }

    ans = ans + a[n-2];

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	vector<ll> v;
	
	for(ll i = 1;i <= 1000;i++){
		ll kake = 1;
		ll kyuu = 0;
		while(i * kake + kyuu < 10000000000000000){
			v.PB(i * kake + kyuu);
			kake *= 10;
			kyuu *= 10;
			kyuu += 9;
		}
	}
	
	sort(ALL(v));
	v.erase(unique(ALL(v)),v.end());
	
	vector<double> cost;
	
	REP(i,v.size()){
		ll tmp = v[i];
		ll cou = 0;
		while(tmp){
			cou += tmp % 10;
			tmp /= 10;
		}
		cost.PB((double)v[i]/(double)cou);
	}
	
	int k;cin >> k;
	
	int cou = 0;
	REP(i,v.size()){
		bool flag = true;
		for(ll j = i + 1;j < min(i+1000,(ll)v.size());j++){
			if(cost[i] > cost[j]){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << v[i] << endl;
			cou++;
		}
		if(cou == k)break;
	}
	
	return 0;
}


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

using ll=long long; 

void solve(){
	string s;
	cin>>s;
	for(char c='a'; c<='z'; c=char(c+1)){
		if(s.find(c)<0 || s.find(c)>=s.size()){
			//cout<<s.find(c)<<endl;
			cout<<c<<endl;
			return;
		}
	}
	cout<<"None"<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 512
import itertools
 
N = int(input())
L = list(map(int,(input().split())))
 
Combination = list(itertools.permutations(L, 3))
count = 0
for i in Combination:
    # a+b>c かつ b+c>a かつ c+a>b
    a = int(i[0])
    b = int(i[1])
    c = int(i[2])
    if((a+b)> c and (b+c) >a and (c+a) >b and a!=b and b!= c and a!= c and a<b and b<c):
        count+=1
 
print(count)

Measured memory_bytes: 78296
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R, K, X, A, B, C;
ll ans;
string S;
ll a[100000000];
bool channel[31][200001];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	cin >> N >> C;
	rep(i, 0, N) {
		ll s, t, c;
		cin >> s >> t >> c;
		rep(i, s * 2 - 1, t * 2) {
			channel[c][i] = true;
		}
	}
	rep(i, 0, 200001) {
		ll tmp = 0;
		rep(j, 1, C + 1) {
			tmp += channel[j][i];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    scan.close();

    long n = 1;
    while(H>>n > 0) {
      n++;
    }

    System.out.println(((long)1<<n) - 1);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll x, y, s;
vector<P> vp;

ll calc(ll r, ll x){
	return r*(100 + x) / 100;
}

int main(){
	while (cin >> x >> y >> s&&x + y + s){
		vp.clear();
		ll num, ans = -1;
		FOR(i, 1, s + 1){
			FOR(j, 1, i){
				//cout << i << endl;
				//cout << calc(i, x) << calc(s - i, x) << endl;
				if (i - j < j)break;
				if (calc(j, x) + calc(i - j, x) == s){
					vp.push_back({ j, i - j });
				}
			}
		}
		REP(i, vp.size()){
			ans = max(ans, calc(vp[i].first, y) + calc(vp[i].second, y));
			//if (ans == 105)cout << vp[i].first << " " << vp[i].second << endl;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3036
N, M = map(int, input().split())
K = [list(map(int,input().split())) for _ in range(N)]


result = {i : 0 for i in range(1, M+1)}

for i in range(1, M+1):
  dislike =False
  for j in range(N):
    if not i in K[j][1:]:
      dislike = True
  if not dislike:
    #print(i)
    result[i] = 1
    
print(sum(result.values()))
    

Measured memory_bytes: 3060
n=int(input())
t=list(map(int,input().split()))
u=list(map(int,input().split()))
speed=[0]
for i in range(n):
  speed+=[u[i]]*t[i]*2
speed.append(0)
m=len(speed)
for i in range(1,m):
  speed[i-1]=min(speed[i-1],speed[i])
del speed[-1]
m-=1
for i in range(1,m):
  speed[i]=min(speed[i],speed[i-1]+0.5)
for i in range(m-2,-1,-1):
  speed[i]=min(speed[i],speed[i+1]+0.5)
ans=0
for i in range(1,m):
  ans+=abs(speed[i-1]+speed[i])*0.25
print(ans)

Measured memory_bytes: 3504
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    for (i in 0..(n / 4)) {
        for (j in 0..(n /7)) {
            if ((4 * i + 7 * j) == n) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

Measured memory_bytes: 31776
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n;
int a[200005], b[200005];
vector<int> A;
vector<int> B;
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d%d",&a[i],&b[i]);
        A.push_back(a[i]);
        B.push_back(b[i]);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if (n % 2 == 0){
        int LO = A[n/2-1] + A[n/2];
        int HI = B[n/2-1] + B[n/2];
        printf("%d ",HI-LO+1);
    }
    else{
        int LO = A[n/2];
        int HI = B[n/2];
        printf("%d ",HI-LO+1);
    }

}


Measured memory_bytes: 6644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int n, x, res;
set<int> s;

int main ()
{
  R1(n);
  s.insert(n + 14);
  res = 0;
  FOR(i, 0, n)
  {
    R1(x);
    if (x < *s.begin()) ++res;
    s.insert(x);
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
 
#define all(x)                      (x).begin(),(x).end()
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;
#define alog(a, n)                  for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
 
const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

//int divs[1000001];
int n;

inline int getdivs(int n){
    int num = 0;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0)
            num += 2;
        if(i * i == n)
            num--;
    }
    return num;
}



int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    /*for(int i = 1; i <= n; i++){
        divs[i] = getdivs(i);
    }*/
    ll ans = 0;
    for(int i = 1; i < n; i++){
        ans += getdivs(n - i);
    }
    
    cout << ans << endl;

	return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x) cerr << #x << " = " << x << "\n" ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n ;
vector < int > a ;

int main(){
 cin >> n ;
 a.resize( n ) ;
 vector < int > idx ;
 forn( int , i , 0 , n ){
   cin >> a[ i ] ;
 }

 forn( int , i , 1 , n + 1 ){
    if( a[ i - 1 ] != i ) idx.pb( i - 1 ) ;
 }


 if( sz( idx ) >= 3 ) return cout << "NO\n" , 0 ;

 if( sz( idx ) )
 swap( a[ idx.front() ] , a[ idx.back() ] ) ;

 forn( int , i , 1 , n + 1 ){
    if( a[ i - 1 ] != i ){
        return cout << "NO\n" , 0 ;
    }
 }

 cout << "YES\n" ;


 return 0 ;
}


Measured memory_bytes: 256
def dfs(cur, use):
    if cur > N:
        return
    if use == 0b111:
        cnt[0] += 1
    dfs(cur*10 + 3, use | 0b001)
    dfs(cur*10 + 5, use | 0b010)
    dfs(cur*10 + 7, use | 0b100)
    return

N = int(input())
cnt = [0]
dfs(0, 0)
print(cnt[0])

Measured memory_bytes: 3060
import math

K = int(input())
sum_num = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        tmp = math.gcd(i, j)
        for k in range(1, K + 1):
            sum_num += math.gcd(tmp, k)
print(sum_num)


Measured memory_bytes: 9140
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int n, k;

int take[15], ex[15];
int hasil;
void solve(int ix, int sisa, int nt, int cnt)
{
	if(ix > n)
	{
		if(sisa <=0)
		{
			hasil=min(hasil, cnt);
		}
		else if(nt==-1) return;
		else
		{
			int mult=(sisa+(nt*100-1))/(nt*100);
			if(mult>=take[nt]) return;
			hasil=min(hasil, cnt+mult);
		}
		return;
	}
	solve(ix+1, sisa, ix, cnt);
	solve(ix+1, sisa-take[ix]*ix*100-ex[ix], nt, cnt+take[ix]);
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int a=1;a<=n;a++)
	{
		scanf("%d%d", &take[a], &ex[a]);
	}
	hasil=1000000;
	solve(1, k, -1, 0);
	printf("%d\n", hasil);
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 5e5 + 10;
int D;
int val[maxN];
int d[maxN];
int len[maxN];
bool check(int x) {
    if (val[x - 1] == 0) return true;
    int D = val[x - 1];
    for (int i = x + 1; i <= n; i++) {
        if (D >= d[i]) D = max(D - d[i], d[i] / 2);
        else D = min(D, d[i] / 2);
    }
    return D == 0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> D;
    val[0] = D;
    for (int i = 1; i <= n; i++) {
        cin >> d[i];
        val[i] = min(val[i - 1], abs(val[i - 1] - d[i]));
    }
    len[n + 1] = 0;
    for (int i = n; i >= 1; i--) {
        if (d[i] / 2 > len[i + 1]) len[i] = len[i + 1];
        else if (d[i] / 2 == len[i + 1]) len[i] = d[i] / 2 + d[i];
        else len[i] = len[i + 1] + d[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int x;
        cin >> x;
        if (val[x - 1] <= len[x + 1]) cout << "NO\n";
        else cout << "YES\n";
    }
    return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> a;
    for(ll i = 0; i < n; i++){
        ll b; cin >> b;
        a.push_back(b);
    }
    sort(a.begin(), a.end());
    vector<ll> check;
    ll count = 1;
    check.push_back(a[0]);
    for(ll i = 1; i < n; i++)
        check.push_back(check[i-1]+a[i]);
    for(ll i = n-1; i >= 0; i--){
      if(i==0) break;
        //cout << check[i-1] << " " << a[i] << endl;
        if(check[i-1]*2 >= a[i]){
            count++;
        }
        else break;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 2548
import sys
input = sys.stdin.readline

def inp():
    return(int(input()))

def inpf():
    return(float(input()))


def inps():
    return str(input())



n = inp()
arr= []
cac = 0
cwa = 0
ctle = 0
cra = 0
for i in range(n):
    s = inps().rsplit()[0]
    if s=="AC": cac+=1
    elif s=="WA": cwa+=1
    elif s=="TLE": ctle+=1
    else: cra+=1
c = [cac, cwa, ctle, cra]
s = ["AC x ", "WA x ", "TLE x ", "RE x "]
for i in range(len(s)):
    print(s[i]+str(c[i]))

Measured memory_bytes: 9208
n = int(input())
S = []
for _ in range(n):
    S.append(input())

S.sort()
a = S[0]
c = 0
moji = []

for i in S:
    if a != i:
        moji.append([c,a])
        a = i
        c = 0
    c += 1
if c > 0:
    moji.append([c,a])

moji.sort(reverse=True)
maxc = moji[0][0]
x = []
for j in moji:
    if j[0] < maxc: break
    x.append(j[1])
x.sort()
for j in x:
    print(j)


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

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

	int num;
	if (m % 2 != 0) {		// どこで半分にするか？
		if (n % 2 != 0) {
			num = n / 2;
		} else {
			num = n / 2 - 1;
		}
	} else {
		if (n % 2 != 0) {
			num = n / 2 - 1;
		} else {
			num = n / 2 - 1;
		}
	}

	int cnt = 0;
	int start = 0;
	int end = num;
	while (cnt < m) {
		cout << start + 1 << " " << end + 1 << endl;
		start++;
		end--;
		if (start >= end) {		// 前半グループが終わったら後半グループへ
			start = num + 1;
			if (n % 2 != 0) {
				end = n - 1;
			} else {
				end = n - 2;
			}
		}
		cnt++;
	}

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) ((int)(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 111
int n;
int main(){
    int a,b;
    in>>a>>b;
    out<<MAX(0,a-2*b);
}

Measured memory_bytes: 256
/**********

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*********/

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

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

long long primechk[10000];

void preprocess(long long N){
    long long i,j;
    for(i=2;i<=N;i++){
        primechk[i]=1;
    }
    for(i=2;i<=N;i++){
        if(primechk[i]==1){
            for(j=2;i*j<=N;j++){primechk[i*j]=0;}
        }
    }
}

long long Binexpo(long long a,long long b){
    if(b==0)
        return 1;
    long long res=Binexpo(a,b/2);
    if(b%2){return res*res*a;}
    else{return res*res;}
}
long long Pwr(long long a,long long b,long long m){
    a%=m;
    long long res=1;
    while(b>0){
        if(b%2){res=res*a%m;}
        a=a*a%m;
        b>>=1;
    }
    return res;
}
int main()
{   long long a,b,c,d,e,f,g,h,i,j,k,x,y,z,sum,cnt=0,n,m;
    cin>>n;
    long long arr[n];
    for(i=0;i<n;i++){cin>>arr[i];cnt+=arr[i];}
    sum=cnt;
    cin>>m;
    for(i=0;i<m;i++){
        cnt=sum;
        cin>>j>>x;
        cnt=cnt-arr[j-1]+x;
        cout<<cnt<<"\n";
    }

    return 0;
}

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

int main(){
		
	int n,r,p,c ;
	int x,y;
	int a[51]={},b[51]={},card[51]={};
	
	while(1){
		cin >> n >> r ;
		if( n==0 && r==0 ) break;
		
		for( int i=1 ; i<=n ; i++ ) card[i] = n-i+1 ;
		
		for( int i=0 ; i<r ; i++ ){
			cin >> p >> c ;
			
			for( x=1 ; x<p ; x++ ) a[x] = card[x] ;
			for( y=1 ; y<=c ; y++ ) b[y] = card[x+y-1] ;
			
			swap(a,b);
			
			for( x=1 ; x<=c ; x++ ) card[x] = a[x] ;
			for( y=1 ; y<p ; y++ ) card[x+y-1] = b[y] ;
		}
		
		cout << card[1] << endl ;
	}
	
return 0;
}

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

vector<pair<int,int> > g[100005];
bool u[100005];
int d[100005];
int n;

void dfs(int x){
    u[x]=true;
    for(int i=0;i<g[x].size();i++){
        int y=g[x][i].first,z=g[x][i].second;
        if(!u[y]){
            d[y]=d[x]+z;
            dfs(y);
        }
    }
}

int main(){

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

    cin>>n;
    for(int i=1;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }
    dfs(1);
    for(int i=1;i<=n;i++){
        if(d[i]%2==0){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 8832
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(D);
    READV(A);
    map<ll,ll> Z;
    set<ll> pos;
    FORI(i,0,N)
    {
        READV(X);
        READV(H);
        Z[X]=max(Z[X],H);
    }
    for(auto p:Z)
    {
        pos.insert(p.fi);
    }
    ll ans=0;
    map<ll,ll> V;
    ll sum=0;
    while(sz(pos)>0)
    {
        ll p=*pos.begin();
        sum+=V[p];
        ll H=Z[p]-sum;
        pos.erase(pos.begin());
        if (H>0)
        {
            ans+=(H+A-1)/A;
            V[p+2*D+1]-=((H+A-1)/A)*A;
            pos.insert(p+2*D+1);
            sum+=((H+A-1)/A)*A;
        }
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 50304
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	cin >> a;
	string b = "";
	b += a[0];
	for (int i = 1; i < a.size(); i++) {
		int k = b.size();
		if (a[i] == b[k-1]) {
		} else {
			b += a[i];
		}
	}
	int kk = a.size();
	if (a[0] == a[kk-1] && a[0] == 'x') {
		cout << 'x' << endl;
	} else {
		cout << 'o' << endl;
	}
	return 0;
}

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n, a, b = map(int, input().split())
    mi = a * (n - 1) + b
    ma = a + b * (n - 1)
    res = ma - mi + 1
    res = max(0, res)
    print(res)

main()


Measured memory_bytes: 3444
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    int p = count(ALL(S), '+');
    cout << p - (4-p) <<  endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,l;
	int i,j;
	cin>>n>>l;
	array<string,101>arr;
	for(i=0;i<n;i++)	cin>>arr[i];
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(arr[i]>arr[j])	swap(arr[i],arr[j]);
		}
	}
	for(i=0;i<n;i++)	cout<<arr[i];
	cout<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[110][110];
int a, c;

signed main(){
	vi tmp;
	vvi d;
	while (1) {
		int b = scanf("%d%c", &a, &c);
		if (b == EOF) break;
		tmp.pb(a);
		if (c == '\n') {
			d.pb(tmp);
			tmp.clear();
		}
	}
	int n = d.size() / 2 + 1;
	rep(i, 0, 2 * n - 1) {
		rep(j, 0, n) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = d[0][0];
	rep(i, 0, n - 1) {
		rep(j, 0, i + 1) {
			dp[i + 1][j] = max(dp[i + 1][j], d[i + 1][j] + dp[i][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], d[i + 1][j + 1] + dp[i][j]);
		}
	}
	rep(i, n, 2 * n - 1) {
		rep(j, 0, 2 * n - 1 - j) {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + 1]) + d[i][j];
		}
	}
	/*rep(i, 0, 2 * n - 1) {
		rep(j, 0, n) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[2 * n - 2][0] << endl;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (ll)(n); ++i)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N, M; cin >> N >> M;
	set<int> pre;
	vector<int> next;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		if (a == 1 || b == 1)pre.insert(a + b - 1);
		if (a == N || b == N)next.push_back(a + b - N);
	}

	bool impossible = true;
	rep(i, 0, next.size()) {
		if (pre.find(next[i]) != pre.end()) {
			cout << "POSSIBLE" << endl;
			impossible = false;
			break;
		}
	}
	if(impossible)cout << "IMPOSSIBLE" << endl;


	return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define pi pair<ll,ll>
#define ss second
#define ll long long
#define MAXN 100005
using namespace std;
using namespace __gnu_pbds;  

ll k;

void solve()
{
	cin>>k;
	ll cnt=0;
	for(ll i=1;i<=k;i++)
	{
		for(ll j=1;j<=k;j++)
		{
			for(ll p=1;p<=k;p++)
			{
				ll res=__gcd(i,__gcd(j,p));
				cnt+=res;
			}
		}
	}
	cout<<cnt<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	solve();
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125];

int main(){
  scanf("%d", &n);
  REP(i,n)scanf("%d" ,a+i);
  int ans = 0;
  REP(i,n-1){
    if(a[i]==a[i+1]){
      i++;
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

int main() {
	int N;
	cin >> N;
	vector<ll> x(N);
	REP(i, N) scanf("%lld", &x[i]);
	
	ll ans = 0, sum = 0;
	
	REP(i, N - 1) {
		sum = (sum + mod_pow(i + 1, MOD - 2)) % MOD;
		ans = (ans + sum * (x[i + 1] - x[i]) % MOD) % MOD;
	}
	
	FOR(i, 1, N) ans = ans * i % MOD;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
n,k,s = map(int, raw_input().split())
r = [s] * k 

if s == 10 ** 9:
	for i in range(n - k):  r.append((10 ** 9) - 2)
else:
	for i in range(n - k):  r.append(s + 1)
for a in r: print a,


Measured memory_bytes: 98916
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
const long long MOD = 1000000007;
int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int current_open = 0;
    long long N_fact = 1;
    for(int i = 1; i <= N; i++){
        N_fact = (N_fact * i) % MOD;
    }
    
    long long ans = 1;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'B'){
            if(current_open % 2 == 0){
                current_open ++;
            } else {
                ans = (ans * current_open) % MOD;
                current_open --;
            }
        } else {
            if(current_open % 2 == 0){
                if(current_open <= 0){
                    ans = 0;
                    break;
                } else {
                    ans = (ans * current_open) % MOD;
                    current_open --;
                }
            } else {
                current_open ++;
            }
        }
    }
    
    ans = (ans * N_fact) % MOD;

    if(current_open != 0){
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
#include<stdio.h>
int D[107][7],i,j,N;
int G[55][6]=
{
    {1,2,3},{1,3,5},{1,5,4},{1,4,2},
    {2,1,4},{2,4,6},{2,6,3},{2,3,1},
    {3,1,2},{3,2,6},{3,6,5},{3,5,1},
    {4,1,5},{4,2,1},{4,6,2},{4,5,6},
    {5,1,3},{5,3,6},{5,4,1},{5,6,4},
    {6,2,4},{6,4,5},{6,5,3},{6,3,2}
}
;
int ch(int a,int b)
{
    int i;
    for(i=0;
i<24;
i++)
    {
 if(D[a][1]==D[b][G[i][0]]&&
  D[a][2]==D[b][G[i][1]]&&
  D[a][3]==D[b][G[i][2]]&&
  D[a][6]==D[b][7-G[i][0]]&&
  D[a][5]==D[b][7-G[i][1]]&&
  D[a][4]==D[b][7-G[i][2]])
 return 1;
    }
    return 0;
}
int main()
{
    scanf("%d",&N);
    for(i=0;
i<N;
i++)
 for(j=1;
j<=6;
j++)
 scanf("%d",&D[i][j]);
    for(i=0;
i<N;
i++)
 for(j=i+1;
j<N;
j++)
 {
 if(ch(i,j))
 {
 puts("No");
 return 0;
 }
 }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 2104
N = int(input())
S = []
ABcnt = 0
topABcnt = 0
topBbtmA = 0
topBbtmNO = 0
topNObtmA = 0
for _ in range(N):
  s = input()
  nowABcnt = s.count('AB')
  ABcnt += nowABcnt
  if s[0:2]=='AB':
    topABcnt += 1
  if s[0]=='B':
    if s[-1]=='A': topBbtmA += 1
    else: topBbtmNO += 1
  elif s[-1]=='A':
    topNObtmA += 1
  if nowABcnt!=0 or s[0]=='B' or s[-1]=='A': S.append(s)

ans = 0


ans += min(topBbtmNO, topNObtmA)
firstSurvivorCnt = max(topBbtmNO, topNObtmA) - ans

nikaisenGet = min(firstSurvivorCnt, topBbtmA)
ans += nikaisenGet

topBbtmA -= nikaisenGet
if ans == 0: ans += max(0, topBbtmA-1)
else: ans += topBbtmA #topBbtmAが生き残ってたら足す
#最後のtopBbtmAはペアを作れない

print(ans+ABcnt)

Measured memory_bytes: 46056
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll k;
	cin>>k;
	ll ans=0;
	for(i=1;i<=k;i++)
	for(j=1;j<=k;j++)
	for(ll z=1;z<=k;z++)
	{
		ans+=__gcd(__gcd(i,j),z);
	}
	cout<<ans;
cout<<"\n"; 
 } 
}


Measured memory_bytes: 3696
#[allow(unused)]
use std::io::{stdin, stdout, Write};    
#[allow(unused)]
macro_rules! read {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty), *) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            read!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (n, d) = read![i64, i64];
    let d2 = d * d;
    let xy = read![i64, i64; n];
    let mut count = 0;
    for item in xy {
        if item.0 * item.0 + item.1 * item.1 <= d2 {
            count += 1;
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 5184
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int[] box=new int[10];
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<10;i++){
			box[i]=sc.nextInt();
		}
		Arrays.sort(box);
		for(int i=0;i<3;i++)
			System.out.println(box[9-i]);
	}

}

Measured memory_bytes: 12000