akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Palace
	var N int
	fmt.Scanf("%d", &N)
	var T, A int
	fmt.Scanf("%d %d", &T, &A)

	var H int
	var flag float64 = 100000.0
	var answer int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H)
		point := math.Abs(float64(A) - (float64(T) - float64(H)*0.006))
		if flag > point {
			flag = point
			answer = i + 1
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 1892
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 2; i < n; ++ i) {
        sum ^= a[i];
    }
    int wa = a[0] + a[1];
    if(wa < sum) {
        cout << -1 << endl;
        return;
    }
    int ad = (wa - sum);
    if(ad % 2 == 1) {
        cout << -1 << endl;
        return;
    }
    ad >>= 1;
    //cerr << sum << " " << ad << endl;
    int ans = 0;
    vector<int> cand;
    for(int bit = 63; bit >= 0; -- bit) {
        int mask = (1LL<<bit);
        if(!(ad & mask) && !(sum & mask)) {
            //
        } else if(ad & mask && sum & mask) {
            cout << -1 << endl;
            return;
        } else if(ad & mask && !(sum & mask)) {
            ans += mask;
            if(ans > a[0]) {
                cout << -1 << endl;
                return;
            }
        } else {
            cand.push_back(bit);
        }
    }
    for(int bit: cand) {
        int mask = (1LL<<bit);
        if(ans + mask <= a[0]) {
            ans += mask;
        }
    }
    if(ans == 0) {
        cout << -1 << endl;
        return;
    }
    cout << a[0] - ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3664
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) {
		int[][] dir = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }, { 1, 1 },
				{ -1, -1 } };
		while (true) {
			int t = nextInt();
			if (t == 0) {
				break;
			}

			int n = nextInt();
			int[][] xy = new int[n][2];
			for (int i = 0; i < n; i++) {
				xy[i][0] = nextInt();
				xy[i][1] = nextInt();
			}
			int sx = nextInt();
			int sy = nextInt();

			int[][] map = new int[121][121];
			for (int i = 0; i < n; i++) {
				int x = xy[i][0];
				int y = xy[i][1];
				map[x + 60][y + 60] = -1;// 障害物は負の数にしておく
			}

			Deque<Integer[]> deque = new ArrayDeque<Integer[]>();
			int sum = 1;
			Integer[] start = { sx + 60, sy + 60 };
			deque.add(start);
			map[sx + 60][sy + 60] = 1;
			while (deque.size() > 0) {
				Integer[] poll = deque.poll();
				if (map[poll[0]][poll[1]] > t) {
					continue;
				}
				for (int i = 0; i < dir.length; i++) {
					if (poll[0] + dir[i][0] >= 0
							&& poll[1] + dir[i][1] >= 0
							&& map[poll[0] + dir[i][0]][poll[1] + dir[i][1]] == 0) {
						map[poll[0] + dir[i][0]][poll[1] + dir[i][1]] = map[poll[0]][poll[1]] + 1;
						Integer[] add = { poll[0] + dir[i][0],
								poll[1] + dir[i][1] };
						deque.add(add);
						sum++;
					}
				}
			}
			System.out.println(sum);

		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 45540
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
 

using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

int C[51][51];

void comb_table(int N) {
    rep(i, N+1) {
        for (int j = 0; j <= i; j++){
            if(j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    comb_table(N);
    int v[55];
    rep(i, N) cin >> v[i];
    sort(v, v+N, greater<int>());
    double ans = 0;
    rep(i, A) {
        ans += v[i];
    }
    ans /= A;

    int cnt = 0;
    int X = 0, Y = 0;
    rep(i, N) {
        if (v[i] == v[A-1]) {
            X++;
            if(i < A) Y++;
        } 
    }

    if (Y == A) {
        for (int i = A; i <= min(B,X); i++) cnt += C[X][i];
    } else {
        cnt += C[X][Y];
    }

    cout.precision(20);
    cout << fixed << ans << endl;
    cout << cnt << endl;

    return 0;
}




Measured memory_bytes: 384
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  // read problem
  long long int H, W, K;
  scanf("%lld%lld%lld", &H, &W, &K);

  std::string str_tmp;
  std::vector<std::string> S;
  for(long long int i = 0; i < H; i++){
    std::cin >> str_tmp;
    S.push_back(str_tmp);
  }

  // solve problem
  std::vector<long long int> count_strawberry(H);
  for(long long int i = 0; i < H; i++){
    for(long long int j = 0; j < W; j++){
      if(S[i][j] == '#'){
        count_strawberry[i]++;
      }
    }
  }

  std::vector<std::vector<long long int> > field(H, std::vector<long long int>(W));
  long long int start_flag = -1;

  long long int tmp_group = 0;
  long long int tmp_count;

  for(long long int i = 0; i < H; i++){
    // if no strawberries has been found
    if(count_strawberry[i] > 0 && start_flag == -1){
      start_flag = i;
    }
    if(start_flag == -1){
      continue;
    }

    // if there are strawberries in the line
    if(count_strawberry[i] > 0){
      tmp_group++;
      tmp_count = 0;
      for(long long int j = 0; j < W; j++){
        field[i][j] = tmp_group;
        if(S[i][j] == '#'){
          tmp_count++;
          if(tmp_count < count_strawberry[i]){
            tmp_group++;
          }
        }
      }
    }
    // if no strawberries in the line
    else{
      for(long long int j = 0; j < W; j++){
        field[i][j] = field[i-1][j];
      }
    }
  }
  
  // print answer
  std::cerr << "Answer: " << std::endl;
  for(long long int i = 0; i < H; i++){
    for(long long int j = 0; j < W; j++){
      if(i < start_flag){
        std::cout << field[start_flag][j] << " ";
      }
      else{
        std::cout << field[i][j] << " ";
      }
    }std::cout << std::endl;
  }

  return 0;
}


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

int main(void) {
    string str;
    string cpy;
    int m, h;
    
    while(cin >> str) {
        if(str[0] == '-' && str.length() == 1)   break;
        cin >> m;
        
        for(int i = 0; i < m; ++i) {
            cin >> h;
            cpy = str.substr(0, h);
            str.erase(0, h);
            str.insert(str.length(), cpy);
        }
        
        cout << str << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
#include <iomanip>
using namespace std;
#define ll long long int


int main () {
  double a, b, c, d;
  cin >> a >> b >> c >> d;
  int taka = ceil(c / b);
  int aoki = ceil(a / d);
  if(taka<=aoki) cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3260
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;
int n;
int a[MAXN][MAXN];

int get_node(int x, int y){
	if(x > y) swap(x, y);
	return x * n + y;
}

vector<int> graph[MAXN * MAXN];
int tin[MAXN * MAXN], tout[MAXN * MAXN], t;
vector<int> res;
bool dfs(int node) {
	tin[node] = t++;
	for(auto to : graph[node]) {
		if(tout[to]) continue;
		if(tin[to]) return false;
		else {
			bool tmp = dfs(to);
			if(!tmp) return false;
		}
	}
	tout[node] = t++;
	res.push_back(node);
	return true;
}
bool tp_sort() {
	memset(tin, 0, sizeof(tin));
	memset(tout, 0, sizeof(tout));
	t = 1;
	for(int i = 0; i < n; i++) {
		int node = get_node(i, a[i][0]);
		if(!tin[node]) {
			bool tmp = dfs(node);
			if(!tmp) return false;
		}
	}
	reverse(res.begin(), res.end());
	return true;
}

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

    cin >> n;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n - 1; j++) {
    		cin >> a[i][j];
    		a[i][j]--;
    		if(j)
    			graph[get_node(i, a[i][j - 1])].push_back(get_node(i, a[i][j]));
    	}
    }
    int valid = tp_sort();
    if(!valid) {
    	cout << -1 << endl;
    	return 0;
    }

    vector<int> cur(n, 1);
    for(int i : res) {
    	int x = i / n, y = i % n;
    	int d = max(cur[x], cur[y]);
    	cur[x] = d + 1;
    	cur[y] = d + 1;
    }
    cout << *max_element(cur.begin(), cur.end()) - 1 << endl;
    // print(res);

    return 0;
}











Measured memory_bytes: 54648
// C - Build Stairs
#include <stdio.h>

int main(void){
    int n, num;
    int h[100001];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &h[i]);
    if(n==1){puts("Yes"); return 0;}
    for(int i=n-2; i>=0; i--){
        if(h[i]>h[i+1]+1){
            puts("No"); return 0;
        }else if(h[i] == h[i+1]+1)h[i]--;    
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 512
import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val hs: List[Int] = (0 until n).map(_ => readLine.toInt).toList

  val sorted = hs.sorted

  val min = (sorted.take(n-k+1) zip sorted.drop(k-1))
    .map({ case (a, b) => b - a})
    .min

  println(min)

}


Measured memory_bytes: 49196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;
}

Measured memory_bytes: 256
# D - Friend Suggestions

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.parents[self.root(x)]

N,M,K = map(int,input().split())
friend = UnionFind(N+1)
block = [1]*(N+1)
for _ in range(M):
    x,y = map(int,input().split())
    block[x] += 1
    block[y] += 1
    friend.union(x,y)
for _ in range(K):
    x,y = map(int,input().split())
    if friend.same(x,y):
        block[x] += 1
        block[y] += 1
ans = [friend.size(i)-block[i] for i in range(1,N+1)]
print(*ans)

Measured memory_bytes: 18420
Sa = list(input())
Sb = list(input())
Sc = list(input())

a = "a"

while True:
    if a == "a":
        if len(Sa) == 0:
            print("A")
            break
        a = Sa[0]
        Sa.pop(0)
    if a == "b":
        if len(Sb) == 0:
            print("B")
            break
        a = Sb[0]
        Sb.pop(0)
    if a == "c":
        if len(Sc) == 0:
            print("C")
            break
        a = Sc[0]
        Sc.pop(0)


Measured memory_bytes: 9116
using System;
using System.Linq;
using System.Collections.Generic;
class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var aPlus1 = a.Select(e => e + 1);
        var aMinus1 = a.Select(e => e - 1);
        var allA = a.Concat(aPlus1.Concat(aMinus1));
        var group = allA.GroupBy(e => e).Select(e => e.Count());
        var ans = group.Max();

        Console.WriteLine(ans);
    }

}


Measured memory_bytes: 35728
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;

main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector <int> a(h + 1, w);
    a[h] = 0;
    for (int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        a[x] = min(a[x], y);
    }
    int maxy = 0;
    for (int i = 1; i < h + 1; i++){
        if (a[i] <= maxy){
            cout << i;
            return 0;
        }
        if (a[i] != maxy + 1) maxy++;
    }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    ll n,k;cin>>n>>k;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        a[i]++;
    }
    vector<mint>dp(k+1,0);
    dp[0]=1;
    for (int i = 0; i < n; ++i) {
        vector<mint>nx(k+1);
        for (int j = 0; j <=k; ++j) {
            if(j-a[i]>=0)nx[j]=dp[j]-dp[j-a[i]];
            else nx[j]=dp[j];
        }
        dp=nx;
//        for (int i = 0; i <=k; ++i) {
//            cout <<dp[i]<<" ";
//        }
//        cout <<endl;
    }
    for (int j = 0; j <n; ++j) {
        for (int i = 1; i <=k; ++i) {
            dp[i]+=dp[i-1];
        }
    }
//    for (int i = 0; i <=k; ++i) {
//        cout <<dp[i]<<" ";
//    }
//    cout <<endl;
    cout <<dp[k]<<endl;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, A, B; cin >> N >> A >> B;
    
    ll X = B - A - 1;
    if (X % 2 == 0) cout << "Borys" << endl;
    else cout << "Alice" << endl;
    
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Stack stack = new Stack();
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        for (String s : line.split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int first = stack.pop();
                int second = stack.pop();
                stack.push(second - first);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {

        static final int MAX = 200;

        int[] array;
        int index;

        Stack() {
            array = new int[MAX];
            index = 0;
        }

        void push(int value) {
            array[index] = value;
            index++;
        }

        int pop() {
            int value = array[index - 1];
            index--;
            return value;
        }

        boolean isEmpty() {
            return index == 0;
        }

        boolean isFull() {
            return index == MAX + 1;
        }
    }
}

Measured memory_bytes: 26320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000000
using namespace std;

string s,t;
int a,p;

int A(int x){return x==2?0:x==1?1:2;}
int B(int x,int y){return x==0||y==0?0:x==1||y==1?1:2;}
int C(int x,int y){return x==2||y==2?2:x==1||y==1?1:0;}
int E(){
	while(s[p]==')')p++;
	if(s[p]!='('){
		int q=p;
		while(s[p]=='-')p++;
		q=(p-q)%2;
		if(s[p]=='(') return q?A(E()):E();
		else return q?A(s[p]-'0'):s[p]-'0';
	}
	int x,y;char z;
	p++;x=E();p++;z=s[p];p++;y=E();p++;
	return z!='+'?B(x,y):C(x,y);
}

int main(){
	while(cin>>t,t!="."){
		a=0;
		rep(i,3)rep(j,3)rep(k,3){
			p=0;
			s=t;
			rep(v,s.size())s[v]=s[v]=='P'?'0'+i:s[v]=='Q'?'0'+j:s[v]=='R'?'0'+k:s[v];
			if(E()==2)a++;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 1200
package main

/*
計数ソート
*/

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

func countingSort(a []int, max int) []int {
	count := make([]int, max+1)

	// 出現数を記録する
	for i := 0; i < len(a); i++ {
		count[a[i]]++
	}
	// 自分より前にいくつの数があるか計算する
	sum, c := 0, 0
	for i := 0; i < len(count); i++ {
		c, count[i] = count[i], sum
		sum += c
	}
	b := make([]int, len(a))
	for i := 0; i < len(a); i++ {
		b[count[a[i]]] = a[i]
		count[a[i]]++
	}
	return b
}

func main() {
	scanner := makeScanner(6 * 2000000)
	eGetInt(scanner)
	s := eGetInts(scanner)
	b := countingSort(s, 10000)
	fmt.Printf("%v\n", ints(b))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(max int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 8192, 8192), max)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}



Measured memory_bytes: 106412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int x;
    cin >> x;
    n -= x;
  }
  cout << max(n,-1) << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  double sqrtNum = sqrt(n);
  ll ans=n-1;
  repo(a, sqrtNum){
    ll b;
    if(n%a==0){
      b=n/a;
      ans=min(ans, a+b-2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
m={"S":[], "D":[], "H":[], "C":[]}
for i in range(int(input())):
    mark, num=input().split()
    m[mark].append(int(num))
for j in ["S", "H", "C", "D"]:
    nai=set(range(1,14))-set(m[j])
    for k in nai:
        print(j, k)

Measured memory_bytes: 7604
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  while(cin >> n){
    TSTART();
    string ans;
    if(n[0] == n[2])ans = "Yes";
    else ans = "No";
    
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}



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

void debug()
{
  cout<<"success"<<endl;
}

int main()
{
  long long int a,b,c,d;
  
  cin>>a>>b>>c>>d;
  
  long long int e,f,g,h;
  
  e=a*c;
  f=a*d;
  g=b*c;
  h=b*d;
  
  e=max(e,f);
  g=max(g,h);
  
  e=max(e,g);
  
  cout<<e<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    bool flg = false;
    reverse(S.begin(), S.end());
    int N = S.size();
    int cur = 0;
    REP(i,N){
        int a = S[i] - '0';
        a += cur;
        if(a < 5){
            ans += a;
            cur = 0;
        }
        else if(a > 5){
            ans += 10 - a;
            cur = 1;
        }
        if(a == 5){
            if(i < N - 1 && S[i+1] - '0' >= 5){
                ans += 10 - a;
                cur = 1;
            }
            else{
                ans += a;
                cur = 0;
            }
        }
        //cout << ans << endl;
    }
    if(cur > 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	sum+=a[i];
    }
    int sum1=sum/n;
    int ans1=0;
    for(int i=0;i<n;i++)
    {
        ans1+=fabs(a[i]-sum1)*fabs(a[i]-sum1);
	}
	int sum2=sum/n+1;
	int ans2=0;
	for(int i=0;i<n;i++)
	{
	   ans2+=fabs(a[i]-sum2)*fabs(a[i]-sum2);	
	}
	if(ans1<ans2)
	cout<<ans1;
	else
	cout<<ans2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define bit_cnt(n) (__builtin_popcountll(n))
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi x(m);
  if(m==1){cout<<0<<endl;return 0;}
  for(int i=0;i<m;i++)cin>>x[i];
  sort(ALL(x));
  vi kyo(m-1);
  for(int i=0;i<m-1;i++)
    kyo[i]=x[i+1]-x[i];
  ll ans=0;
  sort(ALL(kyo));
  for(int i=0;i<min(m-1,n-1);i++)
    kyo.pop_back();
  for(int i=0;i<kyo.size();i++)
    ans+=kyo[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
def solve(X,Y):
  if Y % 2 == 1:
    return False
  if X * 4 < Y:
    return False
  c_legs, t_legs= 2, 4
  for c in range(X + 1):
    legs = c * c_legs + (X - c) * t_legs
    if legs == Y:
      return True
  return False

X, Y = map(int, input().split())
ans = "Yes" if solve(X,Y) else "No"
print(ans)

Measured memory_bytes: 9196
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from decimal import Decimal


def main():
    A, B, C = map(int, input().split())

    if Decimal(A)**Decimal(0.5) + Decimal(B)**Decimal(0.5) < Decimal(C)**Decimal(0.5):
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
string s,t;
char l[2005];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	char a;
	cin>>a;
	if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u')
	{
		cout<<"vowel";
	}
	else
	cout<<"consonant" ;
	cout<<"\n";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = new int[N + 1];
		for (int i = 1; i <= N; i++)
			a[i] = sc.nextInt();

		int s = 1;
		boolean z = false;

		for (int i = 1; i <= N; i++) {
			if (a[i] == 1)
				z = true;
		}
		if (z == false) {
			System.out.println(-1);
			return;
		}

		for (int j = 1; j <= N; j++) {
			for (int i = s; i <= N; i++) {
				if (i == N) {
					if (j == a[N]) {
						System.out.println(N - j);
						return;
					} else {
						System.out.println(N - j + 1);
						return;
					}
				}
				if (j == a[i]) {
					s = i + 1;
					break;
				}
			}
		}

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

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

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 998244353;

vector<pair<ll, ll>> vec;
vector<ll> pref;
ll dp[SIZE];

ll get_sum(int l, int r) {
	if (l < 0) l = 0;
	if (r < 0) r = -1;

	return pref[r + 1] - pref[l];
}

int main()
{
	fastInp;

	string s;
	cin >> s;
	if (s.back() == 's') {
		cout << s << "es" << '\n';
	} 
	else {
		cout << s << "s\n";
	}
	return 0;
}

Measured memory_bytes: 3068
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
if m%2:
  print(-1)
else:
  G = [[] for _ in range(n+1)]
  par = [-1]*(n+1)
  ch = [[] for _ in range(n+1)]
  seen = [False]*(n+1)
  used = set()
  C = [0]*(n+1)
  for _ in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
  
  stack = [1]
  seen[1] = True
  while stack:
    v = stack.pop()
    for nv in G[v]:
      if seen[nv]:
        if par[v] != nv:
          if (min(v, nv), max(v, nv)) not in used:
            used.add((min(v, nv), max(v, nv)))
            print(v, nv)
            C[v] ^= 1
      else:
        seen[nv] = True
        par[nv] = v
        ch[v].append(nv)
        stack.append(nv)
  
  def bottom_up(v):
    for nv in ch[v]:
      bottom_up(nv)
    if v == 1:
      return
    if C[v]:
      C[v] ^= 1
      print(v, par[v])
    else:
      C[par[v]] ^= 1
      print(par[v], v)
      
  bottom_up(1)

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

int Cards[4][13] = {0};
char egara[4] = {'S', 'H', 'C', 'D'};

int main() {

	int n = 0;
	cin >> n;
//	cout << n << endl;

	char c;
	int num;
	for(int i=0;i<n;i++){
		cin >> c >> num;
//		cout << c << num << endl;

		if(c == 'S'){
			Cards[0][num-1] = 1;
		}
		else if(c == 'H'){
			Cards[1][num-1] = 1;
		}
		else if(c == 'C'){
			Cards[2][num-1] = 1;
		}
		else if(c == 'D'){
			Cards[3][num-1] = 1;
		}
	}
	for(int q=0;q<4;q++){
		for(int i=0;i<13;i++){
			if(Cards[q][i] == 0){
				cout << egara[q] << " " <<i+1 << endl;
			}
		}
	}


	return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

int main(){
    string s,t;
    cin >> s >> t;
    vector<ll> anss,anst;
    bool ans=true;
    for(char c='a';c<='z';c++){
        ll scores=0,scoret=0;
        for(ll i=0;i<s.size();i++){
            if(s[i]==c) scores++;
            if(t[i]==c) scoret++;
        }
        anss.pb(scores);
        anst.pb(scoret);
    }
    sort(anss.begin(),anss.end());
    isort(anst);
    for(ll i=0;i<anss.size();i++){
        if(anss[i]!=anst[i]) ans=false;
    }
    if(ans) cout << "Yes" << endl;
    else cout <<"No" << endl;
}



Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	string s=a+b;
	int n=stoi(s);
	int c=sqrt(n);
	if(sqrt(n)==c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N ; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 0;
  for (int i = 0; i < N ; i++){
    if (i % 2 == 0){
    sum += vec.at(i);
    }
     
    if (i % 2 == 1){
      sum -= vec.at(i);
    }
  
  
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int n;
string s;
int main(){
    cin>>s>>n;
    For(i,0,n){
        if(s.at(i)!='1'){
            cout<<s.at(i)<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(13)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dn[4]={-1,1,0,0};
int dm[4]={0,0,-1,1};
ll longinf=(1ll<<60);

const ll MOD = 1e9+7;

ll add(ll a,ll b){
      return ((a%MOD)+(b%MOD))%MOD;
}

ll mul(ll a,ll b){
      return ((a%MOD)*(b%MOD))%MOD;
}

ll pow(ll a,ll b){
      if(b==0) return 1;
      else if(b%2==0) return ((pow(a,b/2)%MOD)*(pow(a,b/2)%MOD))%MOD;
      else return ((pow(a,b-1)%MOD)*(a%MOD))%MOD;
}
ll div(ll a,ll b){
      return ((a%MOD)*(pow(b,MOD-2)%MOD))%MOD;
}

const int index = 1e5+1;
ll frac[index+1];
void calc(){ //main関数内にcalc();を入れること
      frac[0]=1;
      rep0(i,index){
            frac[i+1]=mul(frac[i],i+1);
      }
}

ll dp[105][10];
ll r[10][3];
ll af[10][10];
int main(){
      ll H,W,K;
      cin>>H>>W>>K;
      K--;
      dp[0][0]=1;
      rep0(k,W){
            const int NN=1<<(W-1);
            rep1(n,NN){
                  bool ok=true;
                  rep0(j,W-1){
                        int d=(n>>j)&1;
                        int e=(n>>(j+1))&1;
                        if(d==1&&e==1){
                              ok=false;
                        }
                  }   
                  if(ok){
                        if(k>=1&&((n>>(k-1))&1)){
                              af[k][k-1]++;
                        }
                        if(k<(W-1)&&((n>>k)&1)){
                              af[k][k+1]++;
                        }
                        if(k>=1&&k<W-1&&!((n>>k)&1)&&!((n>>(k-1))&1)){
                              af[k][k]++;
                        }
                        if(k==0&&!((n>>k)&1)){
                              af[k][k]++;
                        }
                        if(k==(W-1)&&!(n>>(k-1)&1)){
                              af[k][k]++;
                        }
                  }
            }
      }
      /*rep0(i,W){
            rep0(j,W){
                  cout<<af[i][j]<<" ";
            }
            cout<<endl;
      }*/
      rep1(i,H){
            rep0(j,W){
                  dp[i][j]=mul(dp[i-1][j],af[j][j]);
                  if(j>0){
                        dp[i][j]=add(mul(dp[i-1][j-1],af[j-1][j]),dp[i][j]);
                  }
                  if(j<W-1){
                        dp[i][j]=add(mul(dp[i-1][j+1],af[j+1][j]),dp[i][j]);
                  }
            }
      }
      cout<<dp[H][K]<<endl;
      
      return 0;
}

Measured memory_bytes: 256
// Problem : C - Lamps
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> v(n);
	for(ll i=0;i<n;++i)
	{
		cin >> v[i];
	}
	for(ll i=0;i<k;++i)
	{
		vector<ll> temp(n+1,0);
		for(ll j=0;j<n;++j)
		{
			ll l=max(0ll,j-v[j]);
			ll r=min(n-1,j+v[j]);
			temp[l]++;
			temp[r+1]--;
		}
		for(ll j=1;j<=n;++j)
		{
			temp[j]+=temp[j-1];
		}
		set<ll> s;
		for(ll j=0;j<n;++j)
		{
			v[j]=temp[j];
			s.insert(v[j]);
		}
		if((int)s.size()==1)
		{
			k=k-i;
			--k;
			break;
		}
		if(i==k-1)
		k=0;
	}
	for(ll i=0;i<n;++i)
	{
		cout << min(v[i]+k,n) << " ";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define mp(a, b) make_pair(a, b)
ll ans;
ll exgcd(ll a, ll b, ll & x, ll & y)
{
	if(!b)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, x, y);
	ll t = x;
	x = y;
	y = t - (a / b) * y;
	return d;
}
pll get(ll a, ll b, ll c)
{
	ll x, y;
	ll d = exgcd(a, b, x, y);
	if(c % d != 0) return mp(-1, -1);
	x *= c / d;
	y *= c / d;
	b = abs(b / d);
	a = abs(a / d);
	x %= b;
	y %= a;
	if(x <= 0) x += b;
	if(y <= 0) y += a;
	return mp(x, y);
}
void calc(ll a, ll b)
{
	pll ret = get(b, -a, 1);
	if(ret.first == -1) return;
	//cout << a << ' ' << ret.second << ' ' << b << ' ' << ret.first << endl;
	ans = min(max(ret.first * b - 1, ret.second * a), ans);
}
int main()
{
	ll N;
	scanf("%lld", &N);
	ans = 2 * N;
	for(ll i = 1; i * i <= N; ++i)
		if(N % i == 0)
		{
			calc(2 * i, N / i);
			calc(i, 2 * N / i);
			calc(2 * N / i, i);
			calc(N / i, 2 * i);
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test() ll t;cin>>t;while(t--)
#define MOD 1000000007
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int main() {
    SPEED;
    //CODE
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256