akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int m[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        m[a]++;
    }
    for (int i = 1; i <= n; i++)
        cout << m[i] << endl;
    return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll ans = 0;
	vll N(3);
	std::cin >> N[0] >> N[1] >> N[2];
	sort(N.begin(), N.end());

	ans = N[2] - N[1];

	ll tmp = N[2] - N[0] - ans;
	if (tmp % 2==0) {
		ans += tmp / 2;
	}
	else {
		ans += tmp / 2 + 2;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int p[1000001];
int mod = 100000007;
int main() {
  int n;
  cin >> n;
  int a[n+1] = {};

  for(int i = 1;i<n+1;i++){
    cin >> a[i]; 
  }
  int b[n+1] = {};
  
  int tmp = 0;
  int res = 0;
  for(int i = n ;i> 0;i--){
    tmp = 0;
    
    for(int j = 2;j<=n;j++){
      if(i*j <= n){
        if(b[i*j] == 1){ tmp++; }
      }else{break;}
    }
    
    if((a[i] == 0 && tmp%2 ==1) || (a[i] == 1 && tmp%2 == 0)){
      b[i] = 1;
      //cout << a[i] << tmp<<  << endl;
      res++ ;
    }
  }
  cout << res << endl; 
  for(int i = 1; i<n+1;i++){
    if(b[i] == 1){
      cout << i << " " ;
    }
  }
}

Measured memory_bytes: 5000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, w;
  cin >> n >> w;
  long long dp[n + 1][w + 1];
  vector<pair<long, long>> item(n);
  for(int i = 0; i < n; ++i){
    cin >> item[i].first >> item[i].second;
  }
  for(int i = 0; i < w + 1; ++i) dp[0][i] = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < w + 1; ++j){
      if(j >= item[i].first) dp[i + 1][j] =  max(dp[i][j - item[i].first] + item[i].second, dp[i][j]);
      else dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

const int N = 1e5+7;

int n, curr, ans = inf;

VI G[N];

bitset<N> path;

int cost[N];
int p[N];

void dfs(int v)
{
	path[v] = 1;
	int cnt = 0;

	for(auto it:G[v])
	{
		if(it!=p[v])
		{
			p[it] = v;
			dfs(it);
			++cnt;

			if(!path[it])
				path[v] = 0;
			else
				++cost[v];
		}
	}

	curr += max(0, cost[v]-1);

	if(cnt>1)
		path[v] = 0;
}

void go(int v)
{
	ans = min(ans, curr+1);

	for(auto it:G[v])
	{
		if(it!=p[v])
		{
			curr -= max(0, cost[v]-1);

			if(path[it])
				--cost[v];

			curr += max(0, cost[v]-1);

			go(it);

			curr -= max(0, cost[v]-1);

			if(path[it])
				++cost[v];

			curr += max(0, cost[v]-1);
		}
	}
}

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

	cin >> n;

	for(int i = 1; i < n; ++i)
	{
		int a, b;
		cin >> a >> b;
		++a;
		++b;
		G[a].pb(b);
		G[b].pb(a);
	}

	int r = 1;

	for(int i = 2; i <= n; ++i)
	{
		if(G[i].size()>G[r].size())
			r = i;
	}

	if(G[r].size()<=2)
	{
		cout << 1;
		exit(0);
	}

	dfs(r);
	go(r);

	cout << ans;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

string buf[29][29];

int main(){
	int h=read(),w=read();
	REP(i,h)REP(j,w)
		buf[i][j]=readString();
	int aR=-1,aC=-1;
	REP(i,h)REP(j,w)
		if(buf[i][j]=="snuke"){
			assert(aR==-1&&aC==-1);
			aR=i,aC=j;
		}
	cout<<char('A'+aC)<<aR+1<<endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


const ll MOD = 1000000007;

int main2() {
  int N; cin >> N;
  string s[2]; cin >> s[0] >> s[1];

  ll ans = 1;
  int state = 0;
  for (int i = 0; i < N; ) {
    if (s[0][i] == s[1][i]) {
      if (state == 0) ans = (ans * 3);
      else if (state == 1) ans = (ans * 2);
      else if (state == 2) ans = (ans * 1);
      state = 1;
      i++;
    } else {
      if (state == 0) ans = (ans * 6);
      else if (state == 1) ans = (ans * 2);
      else if (state == 2) ans = (ans * 3);
      state = 2;
      i += 2;
    }
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
i=0
xy = []
while true
    tmp = gets.chomp.split.map(&:to_i)
    xy.push(tmp)
    i += 1
    if n == i
        break
    end
end
xy2 = xy.permutation.to_a
d = Array.new(xy2.size,0)
j = 0
for j in 0..(xy2.size-1)
    temp = 0.0
    k = 0
    for k in 0..(n-2)
        temp += ((xy2[j][k][0] - xy2[j][k+1][0]) ** 2 + (xy2[j][k][1] - xy2[j][k+1][1]) ** 2) ** 0.5
    end
    d[j] += temp
end

sum = d.inject(:+)
ave = sum / d.size
print ave

Measured memory_bytes: 22360
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class UnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)
		self.size = [1] * (n + 1)

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

	def union(self, x, y):
		x = self.find(x); y = self.find(y)
		if self.rank[x] < self.rank[y]:
			if self.same_check(x, y) != True:
				self.size[y] += self.size[x]
				self.size[x] = 0
			self.par[x] = y
		else:
			if self.same_check(x, y) != True:
				self.size[x] += self.size[y]
				self.size[y] = 0
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def siz(self, x):
		x = self.find(x)
		return self.size[x]

#処理内容
def main():
	N, M = getlist()
	UF = UnionFind(N)
	for i in range(M):
		A, B = getlist()
		A -= 1; B -= 1
		UF.union(A, B)

	#最後に根更新
	for i in range(N):
		UF.par[i] = UF.find(i)

	ans = 0
	# print(UF.size)
	for i in range(N):
		val = UF.size[i]
		ans = max(ans, val)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 85496
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int mod = 1e9 + 7;
ll pw(ll n, ll m){
	ll res = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vector<unordered_map<int,int>> f(n);
	unordered_map<int,int> m;
	rep(i, n){
		int a; cin >> a;
		for(int j = 2; j * j <= a; j++) if(a % j == 0){
			int k = 0;
			for(; a % j == 0; a /= j) k++;
			f[i][j] = k;
		}
		if(a > 1) f[i][a]++;
		for(const auto &j : f[i]) m[j.first] = max(m[j.first], j.second);
	}
	ll ans = 0;
	rep(i, n){
		ll p = 1;
		for(const auto &j : m){
			const auto k = f[i].find(j.first);
			p = p * pw(j.first, j.second - (k == f[i].end() ? 0 : k->second)) % mod;
		}
		ans += p;
	}
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 3328
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
1 2 3
---+/
/+---test
4
1 2 4 8
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  const A = readln.split.map!(to!long).array.sort!"a < b".array;

  const w  = 0;
  const wn = A.countUntil!(i => i != w);
  if (wn < 0) {
    "Yes".writeln;
    return;
  }

  const x  = A[wn];
  const xn = A[wn..$].countUntil!(i => i != x);
  if (xn < 0) {
    (wn*3 == N? "Yes": "No").writeln;
    return;
  }

  const y  = A[xn+wn];
  const yn = A[xn+wn..$].countUntil!(i => i != y);
  if (yn < 0) {
    "No".writeln;
    return;
  }

  const z  = A[yn+xn+wn];
  const zn = chain(A[yn+xn+wn..$], [-1]).countUntil!(i => i != z);

  ((wn == 0 && xn == yn && yn == zn && (x^y^z) == 0 && xn+yn+zn == N)? "Yes": "No").writeln;
}


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

const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  int N; cin >> N;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  vector<long long>dp(N,INF);
  dp.at(0) = 0;
  for(int i=1;i<N;i++){
    chmin(dp.at(i),dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
    if(i>1) chmin(dp.at(i),dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
  }
  cout << dp.at(N-1) << endl;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int mo=1e9+7,M=1e5+5;
ll n,k,m,num,ans,a[M][2],b[M],f[M];
ll qmi(ll x,ll n)
{
	ll t=1;
	for(;n;n>>=1,x=x*x%mo) if(n&1) t=t*x%mo;
	return t;
}
void dfs(int id=1,int x=1)
{
	if(id>m)
	{
		b[++num]=x;
		return;
	}
	for(int j=0,t=1;j<=a[id][1];j++,t=t*a[id][0]) dfs(id+1,x*t);
}
void pre()
{
	ll t=n;
	for(ll i=2;i*i<=t;++i)
		if(t%i==0)
			for(a[++m][0]=i;t%i==0;t/=i) a[m][1]++;
	if(t>1) a[++m][0]=t,a[m][1]=1;
	dfs();
	sort(b+1,b+num+1);
}
int main()
{
	n=read(),k=read();
	pre();
	fo(i,1,num)
	{
		int x=b[i];
		f[i]=qmi(k,(x+1)/2);
		fo(j,1,i-1)
			if(x%b[j]==0) f[i]=(f[i]-f[j]+mo)%mo;
		ans=(ans+(ll)f[i]*(x&1?x:x/2)%mo)%mo;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    X = int(input())
    # O(1)解法
    quo = X//100
    mo_ = X % 100
    # 0 <= Xを100で割った余り <= 5 * Xを100で割った時の商 (最大で、5 * 商まで表せれるから)
    if 0 <= mo_ <= 5*quo:
        print(1)
    else:
        print(0)

    # 
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<int,int >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define MOD         4294967296
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace __gnu_pbds;
using namespace std;
template <typename T>  using orderedSet =
    tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key


pii arr[10];
double cost;
int n;
bool vis[10]={0};
double dis(int i,int j)
{
    pii a=arr[i];
    pii b=arr[j];
    //cout<<i<<' '<<j<<endl;
    double dist=sqrt((a.ff-b.ff)*(a.ff-b.ff)+(a.ss-b.ss)*(a.ss-b.ss));
    //cout<<dist<<endl;
    return dist;
}
void call(int pos,double ttl,int cnt)
{
    //cout<<"p"<<pos<<endl;
    if(cnt==n) {cost+=ttl;return ;}
    vis[pos]=1;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            call(i,ttl+dis(pos,i),cnt+1);
            vis[i]=0;
        }
    }

}
int main()
{
    cin>>n;
    rep(i,n) cin>>arr[i].ff>>arr[i].ss;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            call(i,0,1);
            vis[i]=0;
        }
    }
    int div=1;
    for(int i=1;i<=n;i++) div*=i;
    //cout<<cost<<endl;
    double ans=cost/div;
    cout<<fixed<<setprecision(8)<<ans<<endl;
}



Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
h_lst = [int(x) for x in stdin.readline().rstrip().split()]

max_count = 0
count = 0

for i in range(n-1):
  if h_lst[i] >= h_lst[i+1]:
    count += 1
  else:
    max_count = max(max_count, count)
    count = 0

print(max(max_count, count))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int takahashi = 0;
    	string eating;
    	cin >> eating;
    	for(int i = 0;i < 4;i++){
    		if(eating.at(i) == '+'){
    			takahashi++;
    		}
    		else{
    			takahashi--;
    		}
    	}
    	cout << takahashi << endl;
    }

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

int main()
{
    string s;
    cin >> s;

    long long int K;
    cin >> K;

    int one = 0;

    for( int i = 0; i < s.length(); ++i ){
        if( s[i] == '1' ) ++one;
        else break;
    }

    if( K <= one ) cout << 1 << endl;
    else cout << s[one] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> h(n),table(n);
    for(int i=0;i<n;i++)    cin>>h[i];
    table[n-1]=0;
    table[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--){
        if(table[i+1]+abs(h[i]-h[i+1])<table[i+2]+abs(h[i]-h[i+2])){
            table[i]=table[i+1]+abs(h[i]-h[i+1]);
        }
        else{
            table[i]=table[i+2]+abs(h[i]-h[i+2]);
        }
    }
    cout<<table[0]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <math.h>

using namespace std;

bool isSquare(int num){
    int original=num;
    num=sqrt(original);
    return original==num*num;
}

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

    string a;
    string b;
    cin>>a>>b;
    string c=a+b;
    int num=atoi(c.c_str());

    if(isSquare(num)){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int N,A,B;
  long long int i;
  long long int h[100000];
  long long int K;
  long long int left,right;
  long long int sum;

  scanf("%lld %lld %lld",&N,&A,&B);
  //printf("%d\n", N);

  for(i=0;i<N;++i){
    scanf("%lld",&h[i]);
    //printf("h[%lld]=%lld\n", i,h[i]);
  }

  left=0;
  right=1000000000;
  //K=(right+left)/2;

  //printf("%d\n", K);

  while(left!=right-1){
    K=(right+left)/2;
    sum=0;
    for(i=0;i<N;i++){
      if(h[i]-K*B > 0){
        sum += (h[i]-K*B)%(A-B) ? (h[i]-B*K)/(A-B)+1 :(h[i]-B*K)/(A-B);
      }
    }
    if(sum <= K){
      right=(right+left)/(long long int)2;
    }else{
      left=(right+left)/(long long int)2;
    }
    //printf("%lld,%lld\n", left,right);

    /*if(left==right-1){
      break;
    }*/
  }

  printf("%lld\n", right);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(a,s,d) for(int a=s;a<d;a++)
using namespace std;
typedef long long ll;
set<string> s;

int main()
{
    int n;cin>>n;
    string temp;cin>>temp;s.insert(temp);
    rep(i,1,n)
    {
        string t;cin>>t;
        if(s.count(t))
        {
            printf("No\n");
            return 0;
        }
        if(t[0]!=temp[temp.length()-1])
        {
            printf("No\n");
            return 0;
        }
        s.insert(t);temp=t;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
_input = input
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

#ここに書きたいコードを書く
#データ読み込み
#n=int(input())
m=input().split()
n=int(m[0])
#s=[list(map(int, input().split())) for i in range(n)]
s=list(map(int, input().split()))

day_money = [0] * n
day_money[0] = 1000

for sell_day in range(n):
	for buy_day in range(sell_day):
		day_money[sell_day] = max(day_money[buy_day], (day_money[buy_day]//s[buy_day])*s[sell_day]+day_money[buy_day]%s[buy_day])
		#print(day_money)
		
print(day_money[n-1])

input = _input


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	string n; cin >> n;
	if (n[0] == n[2])coutY();
	else coutN();
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll a, b, c;
	cin >> a >> b >> c;
	
	if(a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;

	return 0;
}


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

int solve(string x, string y){
    int m = x.length();
    int n = y.length();
    int maxl = 0;
    int c[1001][1001];
    
    for(int i = 0; i < m; i++) c[i][0] = 0;
    for(int i = 0; i < n; i++) c[0][i] = 0;
    x = ' ' + x;
    y = ' ' + y;

    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][j-1], c[i-1][j]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main(){
    int q, l = 0;
    string x,y;
    vector<int> a;

    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> x >> y;
        a.push_back(solve(x,y));
    }

    for(auto i: a){
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 7080
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 1;
		Map<Integer, Integer> counter = new HashMap<>();
		for(int i = 0; i < N; i++) {
			int input = sc.nextInt();
			int input_minus = input - 1;
			int input_plus = input + 1;
			if(counter.containsKey(input)) {
				counter.put(input, counter.get(input) + 1);
				if(counter.get(input) > max) {
					max = counter.get(input);
				}
			} else {
				counter.put(input, 1);
			}
			if(counter.containsKey(input_minus)) {
				counter.put(input_minus, counter.get(input_minus) + 1);
				if(counter.get(input_minus) > max) {
					max = counter.get(input_minus);
				}
			} else {
				counter.put(input_minus, 1);
			}
			if(counter.containsKey(input_plus)) {
				counter.put(input_plus, counter.get(input_plus) + 1);
				if(counter.get(input_plus) > max) {
					max = counter.get(input_plus);
				}
			} else {
				counter.put(input_plus, 1);
			}
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 65680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,ans;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    ans=max(c,max(d,e));
    cout<<ans;
    return 0;
}

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

using namespace std;

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

using _loop_int = 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 CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

ll k,x,y;

pll solve(ll k, ll sx, ll sy, ll tx, ll ty){
    // DEBUG(sx); DEBUG(sy); DEBUG(tx); DEBUG(ty); DEBUG(k);
    REP(i,2)REP(j,3){
        ll y = (sy + ty + (i==0?1:-1)*(sx-tx) + (j==0?1:j==1?-1:0)*2*k)/2;
        REP(ii,2){
            ll x = sx + (ii==0?1:-1)*(k-abs(y-sy));
            // DEBUG(x); DEBUG(y);
            if(abs(x-sx)+abs(y-sy)!=k)continue;
            if(abs(x-tx)+abs(y-ty)!=k)continue;
            return pll(x,y);
        }
    }
}

int main(){
    cin>>k>>x>>y;
    if(k%2==0 && (abs(x)+abs(y))%2==1){
        puts("-1");
        return 0;
    }
    vector<pll> path;
    ll cx = 0, cy = 0;
    while(cx!=x || cy!=y){
        ll d = abs(cx-x) + abs(cy-y);
        if(d == k){
            path.push_back(pll(x,y));
            break;
        }else if(d < 2*k && d % 2 == 0){
            // 2-step
            pll P = solve(k,cx,cy,x,y);
            path.push_back(P);
            path.push_back(pll(x,y));
            break;
        }else if(d < k && d % 2 == 1){
            // 3-step
            if(abs(cx-k-x)+abs(cy-y)<k){
                cx -= k;
            }else if(abs(cx+k-x)+abs(cy-y)<k){
                cx += k;
            }else if(abs(cx-k)+abs(cy-k-y)<k){
                cy -= k;
            }else{
                cy += k;
            }
            path.push_back(pll(cx,cy));
            pll P = solve(k,cx,cy,x,y);
            path.push_back(P);
            path.push_back(pll(x,y));
            break;
        }else{
            // naive step
            ll dx = x - cx; ll dxir = x==cx ? 0 : (x-cx) / abs(x-cx);
            ll dy = y - cy; ll dyir = y==cy ? 0 : (y-cy) / abs(y-cy);
            ll ex=0, ey=0;
            ll sb = min(k, abs(dx));
            ex += sb * dxir;
            ey += (k-sb) * dyir;
            cx += ex;
            cy += ey;
            path.push_back(pll(cx,cy));
        }
    }
    printf("%d\n",(int)path.size());
    for(pll P : path){
        printf("%lld %lld\n",P.first,P.second);
    }
    return 0;
}


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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> X(3,vector<ll>(N));
    for ( int i = 0; i < N; i++ ) {
        cin >> X[0][i] >> X[1][i] >> X[2][i];
    }

    const ll INF = 1LL<<60;
    ll ans = -INF;
    int bw = 3;
    for ( int b = 0; b < 1<<bw; b++ ) {
        vector<ll> ns;
        for ( int i = 0; i < N; i++ ) {
            ll s = 0;
            for ( int ii = 0; ii < bw; ii++ ) {
                if ( (b >> ii) & 1 ) {
                    s -= X[ii][i];
                } else {
                    s += X[ii][i];
                }
            }
            ns.push_back(s);
        }
        sort(ns.rbegin(), ns.rend());
        ll ss = 0;
        for ( int j = 0; j < M; j++ ) {
            ss += ns[j];
        }
        ans = max(ans, ss);
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>

using namespace std;

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

	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;

	for(int i = 0; i < N; i++){
		string str;
		cin >> str;	
		if(str == "AC"){
			a++;
		}
		else if(str == "WA"){
			b++;	
		}
		else if(str == "TLE"){
			c++;	
		}
		else if(str == "RE"){
			d++;	
		}
	}

	cout << "AC x " << a << "\n";
	cout << "WA x " << b << "\n";
	cout << "TLE x " << c << "\n";
	cout << "RE x " << d << "\n";
}


Measured memory_bytes: 3628
s = list(str(input()))
t = list(str(input()))

s_sorted = sorted(s)
t_sorted = sorted(t, reverse=True)

ans = -1
for i in range(min(len(s), len(t))):
    if s_sorted[i] < t_sorted[i]:
        ans = 1
        break
    elif s_sorted[i] > t_sorted[i]:
        ans = 0
        break
    else:
        continue

if ans == -1:
    if len(s) < len(t):
        ans = 1
    else:
        ans = 0

if ans:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(void) {
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> w(n + 1);
    for(int i = 1; i < n; i++){
        w[i].push_back(i + 1);
        w[i + 1].push_back(i);
    }
    w[x].push_back(y);
    w[y].push_back(x);

    vector<int> ans(n + 1);
    queue<int> q;

    for(int k = 1; k <= n; k++){
        vector<int> dist(n + 1, -1);
        q.push(k);
        dist[k] = 0;

        while(!q.empty()){
            int top = q.front();
            q.pop();
            
            for(int i: w[top]){
                if(dist[i] != -1){
                    continue;
                }
                else{
                    q.push(i);
                    dist[i] = dist[top] + 1;
                    ans[dist[i]] += 1;
                }
            }
        }
    }

    for(int i = 1; i < n; i++){
        cout << ans[i] / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := calcCircumference(n)
	fmt.Println(answer)
}

func calcCircumference(radius int) float64 {
	return float64(2*radius) * math.Pi
}


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

using namespace std;

using ll = long long;

int idx(const char a) { return (int)(a - 'a'); }

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

    int n;
    string s;
    cin >> n >> s;

    constexpr ll MOD = 1e9 + 7;
    ll res = 1;
    vector<int> cnt(26, 1);
    ++cnt[idx(s[0])];

    for (int i = 1; i < n; ++i) {
        ll sum = 1;
        ++cnt[idx(s[i])];
        for (int j = 0; j < 26; ++j) {
            if (idx(s[i]) != j && cnt[j] != 1)
                (sum *= cnt[j]) %= MOD;
        }
        (res += sum) %= MOD;
    }

    cout << (res % MOD) << endl;

    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1000000007ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int gcc(int n, int m) {
    int a = max({n, m});
    int b = min({n, m});
    if(b == 0) return a;
    int c;
    while(a % b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int evenzero = 0;
    int oddzero = 0;
    rp(i, 0, n){
        if(s[i] == '0'){
            if(i % 2 == 0) evenzero ++;
            else oddzero ++; 
        }
    }
    int ans = min({n - evenzero - (n/2 - oddzero), n - oddzero - (n/2 + n%2 - evenzero)});
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 512
import math
n, m = map(int, input().split())

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ll = 0
if n > 1:
  ll = comb(n, 2)
rr = 0
if m > 1:
  rr = comb(m, 2)
print(ll + rr)



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

int main() {
  int n;
  cin>>n;
  vector<long long> s(n+1,0);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    s[i+1]=s[i]+a;
  }
  sort(s.begin(),s.end());
  
  long long ans=0,cnt=0;
  for(int i=0;i<n;i++){
    if(s[i]==s[i+1]) {cnt++;ans+=cnt;}
    else cnt=0;
  }
  cout<<ans<<endl;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}

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

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


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int COUNT = 1000000;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var count = 0;
		var t = create(c, s, d);
		for (var i = 0; count < COUNT; i++) {
			for (var j = 1; j < K; j++) {
				count++;
				var mdi = i % d;
				var mti = (t[mdi] + j - 1) % K;
				var check = check(c, s, t, d, mdi, mti);
				if (check > 0) {
					t[mdi] = mti + 1;
					break;
				}
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;

		//		System.out.printf("*****%d, %d, %d, %d, %d,     %d, %d\r\n", t[0], t[1], t[2], t[3], t[4], mdi + 1, mti + 1);
		//		System.out.printf("*****%d, %d, %d, %d, %d, %d, %d, %d\r\n", s[mdi][mti], s[mdi][ti], c[mti], c[ti], last1,
		//				last2, count1, count2);

		return sum;
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		return index;
	}
}


Measured memory_bytes: 46576
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
//#include "pch.h"    
using namespace std;
unordered_map<int, bool> here;
 
using ll = long long;
const int nax = 1e5 + 10;
vector<int> edges[nax];

int main() {
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt = 0;
    while(1) {
        if(cnt & 1) {
            a -= d;
            if(a <= 0) {
                cout << "No\n";
                return 0;
            }
            //means it is Aoki's turn;
        }else{
            c -= b;
            if(c <= 0) {
                cout << "Yes\n";
                return 0;
            }
        }
        ++cnt;
    }
}


Measured memory_bytes: 5972
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  // int dp[n];
  int idx=-1;
  k--;
  rep(i,0,s.length()) if(s[i]!='1') {idx=i; break;}
  // cout<<idx<<endl;
  if(idx==-1 || k<idx){
    cout<<s[k]<<endl;
  }
  else{
    cout<<s[idx]<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
int main(){

    int N=0;
    char s[100001]={};
    int sum=0;
    int flag=1;
    int temp=0;
    int count=0;
    scanf("%d",&N);
    scanf("%s",s);
    sum=N;
    int i=0;
    while(i+1<N){
        flag=1;
        count=0;
        while(flag>0){
            flag=0;
            temp=i+1;
            if(s[i]==s[temp+count]){
                s[temp]='A';
                flag=1;
                count++;
                sum--;
            }

        }
        i+=count+1;
    }


   printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;

int n, k;
string s;

void solve()
{
	s[k-1] = tolower(s[k-1]);
	cout << s << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 256
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];a=[n*[0]for _ in[0]*n];r=range(n)
for b in range(64):
  e=1<<b;u=[k&e for k in f];v=[k&e for k in g];l=[0]*n;m=l[:]
  for i in r:
    for j in r:
      if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):a[i][j]|=e;l[i]+=1;m[j]+=1
  for i in r:
    if(l[i]==0)*s[i]*u[i]:
      for j in r:
        if(t[j]^1)*(n-m[j]>1):a[i][j]|=e;m[j]+=1;break
  for j in r:
    if(m[j]==0)*t[j]*v[j]:
      for i in r:
        if(s[i]^1)*(n-l[i]>1):a[i][j]|=e;l[i]+=1;break
h=a[0][:];w=[i[0]for i in a]
for i in r:
  for j in r:w[i]=(w[i]|a[i][j]if s[i]else w[i]&a[i][j]);h[j]=(h[j]|a[i][j]if t[j]else h[j]&a[i][j])
if(g!=h)|(f!=w):print(-1);exit() 
for i in a:print(*i)

Measured memory_bytes: 99348
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    vll v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    sort(all(v));
    reverse(all(v));
    ll ans=0;
    vll k;
    k.pb(v[0]);
    for(ll i=1;i<n;i++)
    {
        k.pb(v[i]);
        k.pb(v[i]);
    }
    for(ll i=0;i<n-1;i++)
    {
        ans+=k[i];
    }
    cout<<ans<<nn;








}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



Measured memory_bytes: 8976
H,W=map(int,input().split())
s=[input() for _ in range(H)]
S=[]
S.append(['.' for _ in range(W+2)])
for i in range(H):
    s[i]='.'+s[i]+'.'
    S.append(list(s[i]))
S.append(['.' for _ in range(W+2)])
for i in range(1,H+1):
    for j in range(1,W+1):
        cnt=0
        if S[i][j]=='.':
            for k in range(-1,2):
                for l in range(-1,2):
                    if S[i+k][j+l]=='#':
                        cnt+=1
            S[i][j]=str(cnt)
for i in range(1,H+1):
    print(''.join(S[i][1:W+1]))



Measured memory_bytes: 9228
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string S;
    cin >> S;
    string out = "TBD";
    ll Y = stoi(S.substr(0,4));
    ll M = stoi(S.substr(5,2));
    if(Y<2019) out = "Heisei";
    else if(Y==2019){
        if(M<=4) out = "Heisei";
        }
    cout << out << endl;
    return 0;
}


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

int main(){
  int a,b;
    while(cin >> a >> b){
      int x=a+b;
    int count=0,i;
    for(i=1;i<=1000000;i*=10){
      if(x/i>=1){
	count++;
      }
      if(x/i<0){
	break;
      }
    }
    cout << count << endl;

  }





 return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int ans[50];
int main(int argc, char const *argv[]){
	int n,m,a,b,i;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		ans[a-1]++;
		ans[b-1]++;
	}
	for(i=0;i<n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;


int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n,a;
  cin>>n>>a;
  ll re=n;
  rrep(sz,42)if(sz){
    if((1<<sz)>=n){
      MN(re,sz*2+a*(sz-1));
      continue;
    }      
    ll l=sz*2,r=ceil(pow(n,1./sz))*sz+sz;
    while(r-l>1){
      ll m=(l+r)/2;
      ll prod=1;
      rep(j,sz){
	prod*=m/sz+(j<m%sz);
	if(prod>=n) break;
      }
      //cout<<pll(m,sz)<<prod<<endl;
      if(prod>=n){
	r=m;
      }else{
	l=m;
      }

      //cout<<r+a*(sz-1)<<endl;
      MN(re,r+a*(sz-1));
    }
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 512
def ball(s , t , a , b , u):

    if u == s:
        a -= 1
    else:
        b -= 1

    return str(a) + " " + str(b)

def main():
    s , t = map(str , input().split())
    a , b = map(int , input().split())
    u = str(input())
    print(ball(s , t , a , b , u))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N,Y = [int(x) for x in input().split()]
ans = [-1,-1,-1]
for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if(i*10000+j*5000+k*1000 == Y):
            ans = [i,j,k]
            break

print(ans[0],ans[1],ans[2])


Measured memory_bytes: 3060