akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector< vector<int> > array_2D;
typedef pair<int, pair<int, int> > ppi;
typedef vector<int> vi;



int main() {


    ll k, l, r;
    cin >> k;
    cin >> l >> r;


    // if((r - l + 1) >= k)
    //     cout<< "OK";
    // else
    //     cout << "NG";
    bool f = false;
    for(int i = l; i <= r; i++) {
        if(i % k == 0)
            f = true;
    }


    if(f)
        cout << "OK\n";
    else
        cout << "NG\n";
    return 0;
}

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

using namespace std;

int main(){

  string pass;

  cin>>pass;

  if(pass.size()<6){
	cout<<"INVALID"<<endl;
	return 0;
  }

  bool t=false;
  
  for(int i=0;i<pass.size();++i){
	if(pass[i]>='0' && pass[i]<='9'){
	  t=true;
	  break;
	}
  }

  if(t==false){
	cout<<"INVALID"<<endl;
	return 0;
  }

  t=false;
  
  for(int i=0;i<pass.size();++i){
	if(pass[i]>='A' && pass[i]<='Z'){
	  t=true;
	  break;
	}
  }

  if(t==false){
	cout<<"INVALID"<<endl;
	return 0;
  }
  
  t=false;
  
  for(int i=0;i<pass.size();++i){
	if(pass[i]>='a' && pass[i]<='z'){
	  t=true;
	  break;
	}
  }

  if(t==false){
	cout<<"INVALID"<<endl;
	return 0;
  }

	cout<<"VALID"<<endl;

	return 0;
  
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int N, M;
vi G[1001];

vi bfs(int s) {
  // BFS
  queue<int> q;
  vi d(N, INF);
  vi prev(N, -1);

  d[s] = 0;
  q.push(s);

  while(!q.empty()) {
    int u = q.front(); q.pop();
    for(int v : G[u]) {
      if (v == s) {
        // found a cycle
	vi ret;
	int x = u;
	while (x>=0) {
           ret.push_back(x);
	   x = prev[x];
	}
        reverse(begin(ret), end(ret));
	return ret;
      }

      if (d[v] < INF) continue;

      d[v] = d[u]+1;
      prev[v] = u;
      q.push(v);
    }
  }

  return vi(N+1); // no cycle
}

int main(int argc, char** argv) {
  cin >> N >> M;

  REP(i, M) {
    int A, B;
    cin >> A >> B;
    A--; B--;

    G[A].emplace_back(B);
  }

  vi ret(N+1);
  REP(i, N) {
    auto path = bfs(i);
    if (path.size() < ret.size()) {
      ret = path;
    }
  }

  if (int(ret.size()) > N) {
    cout << -1 << endl;
    return 0;
  }

  cout << ret.size() << endl;
  for (int u : ret) {
    cout << u+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#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;i++)
typedef long long ll;

int main(){
  int a,b,c;
  set<int> s;
  cin >> a >> b >> c;
  s.insert({a,b,c});
  cout << s.size() << endl;
}


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

int main(){
  ll n;
  cin>>n;
  int m[n];fill(m,m+n,0);
  for(int i=1;i*i<=n;i++){
    for(int j=1;j*j<=n;j++){
      for(int k=1;k*k<=n;k++){
        if((i+j+k)*(i+j+k)-j*k-(j+k)*i-1<n)m[(i+j+k)*(i+j+k)-j*k-(j+k)*i-1]++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << m[i]<<endl;
  }
}

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

#define MAX_N 100
int N;
int L[2*MAX_N];

int main(){
	cin >> N;
	for(int i=0; i<2*N; i++) cin >> L[i];
	sort(L, L+2*N);
	int sol=0;
	for(int i=0; i<N; i++) sol+=L[2*i];
	cout << sol << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll N;
    cin >> N;
    ll sum =0;
    rep(i,1,N+1){
        if(i%3!=0&&i%5!=0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    vector<int>l(N);
    for (int i = 0; i < N; ++i) {
      cin >> l[i];
    }

    // 2bit全探索, 2*N bitで0から4^N - 1まで
    // 0がa, 1がb, 2がc, 3は使わない
    int ans = mod;
    for (int i = 0; i < pow(4,N); ++i) {
        int mp = 0;
        vector<int>abc(4,0);
        for (int j = 0; j < N; ++j) {
            int x = (i >> (j * 2)) & 3;
            if(abc[x] != 0 && x != 3) mp += 10;
            abc[x] += l[j];
        }
        if(abc[0] != 0 && abc[1] != 0 && abc[2] != 0) {
            mp = mp + abs(A - abc[0]) + abs(B - abc[1]) + abs(C - abc[2]);
            ans = min(mp, ans);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


puts gi.sort.shift(2).inject(:+)

Measured memory_bytes: 2300
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef  vector< vector<int> > vector2d;

int main (){
  

  int n,m;
  
  while(1){
    cin >>n>>m;
    if (n==0&&m==0) break;
    
    int i,j,temp,sumtaro=0,sumhanako=0,ansnum,diffe1,diffe2;
    vector<int> taro,hanako;
    vector2d ans;
    ans.resize(3);
    
    //太郎の入力、sumを計算しpushbackは重複をさける
    for(i=0;i<n;i++){
      cin >> temp;
      sumtaro += temp;
      if (find(taro.begin(),taro.end(),temp)==taro.end()){
	taro.push_back(temp);
      }
    }
    
    //花子の入力、同様に
    for(i=0;i<m;i++){
      cin >> temp;
      sumhanako += temp;
      if (find(hanako.begin(),hanako.end(),temp)==hanako.end()){
	hanako.push_back(temp);
      }
    }
    
    //メイン処理
    diffe1 = (sumtaro - sumhanako); //マイナス→たろー少ない
    
    if (diffe1%2==0){
	    diffe1 = diffe1 / 2 ;
	    
	    for(i=0;i<taro.size();i++){
	      for(j=0;j<hanako.size();j++){
		diffe2 = taro[i] - hanako[j];
		if (diffe2==diffe1){
		  ans[0].push_back(taro[i]);
		  ans[1].push_back(hanako[j]);
		  ans[2].push_back(taro[i]+hanako[j]);
		}
	      }
	    }
    }
    
    if (ans[2].size()==0){
      cout << -1 << endl;
    }else{
      ansnum = 0;
      for(i=1;i<ans[2].size();i++){
	if (ans[2][ansnum]>ans[2][i]){
	  ansnum = i;
	}
      }
      cout << ans[0][ansnum] << " " << ans[1][ansnum] <<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt{
    fint64 x;
    ModInt():x(0){}
    ModInt(fint64 x):
        x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
        {}
    // 負号
    ModInt operator -() const{
        return ModInt(-x);
    }
    // 加算
    ModInt &operator +=(const ModInt &rhs){
        x+=rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator +(const ModInt &rhs) const{
        return ModInt(*this)+=rhs;
    }
    // 減算
    ModInt &operator -=(const ModInt &rhs){
        x+=MOD-rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator -(const ModInt &rhs) const{
        return ModInt(*this)-=rhs;
    }
    // 乗算
    ModInt &operator *=(const ModInt &rhs){
        x*=rhs.x;
        if(x>=MOD) x%=MOD;
        return (*this);
    }
    ModInt operator *(const ModInt &rhs) const{
        return ModInt(*this)*=rhs;
    }
    // 除算
    ModInt &operator /=(const ModInt &rhs){
        (*this)*=rhs.inverse();
        return (*this);
    }
    ModInt operator /(const ModInt &rhs) const{
        return ModInt(*this)/=rhs;
    }
    // 等号
    bool operator ==(const ModInt &rhs){
        return x==rhs.x;
    }
    bool operator !=(const ModInt &rhs){
        return x!=rhs.x;
    }
    // 累乗
    ModInt pow(fint64 n) const{
        fint64 tmp=x;
        fint64 ret=1;
        while(n>0){
            if(n&1) ret=ret*tmp%MOD;
            tmp=tmp*tmp%MOD;
            n>>=1ll;
        }
        return ModInt(ret);
    }
    // 逆元
    ModInt inverse() const{
        fint64 a=x,b=MOD,s=1,t=0;
        while(b>0){
            fint64 u=a/b;
            a-=u*b;
            s-=u*t;
            swap(a,b);
            swap(s,t);
        }
        return ModInt(s);
    }
    // 入出力
    friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
        fint64 x; lhs>>x;
        rhs=ModInt<MOD>(x);
        return lhs;
    }
    friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
        return lhs<<rhs.x;
    }
};

using mint=ModInt<LMOD>;
int main() {
	int n; cin >> n;
	int d[n]; rep(i,n) cin >> d[i];
	if(d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	map<int, int> mp;
	rep(i,n - 1) {
		mp[d[i + 1]]+=1;
	}
	int pre = 0;
	mint prec = 1;
	mint ans = 1;
	for(auto e : mp) {
		// cerr << e.first<<endl;
		if(e.first != pre + 1) {
			cout << 0 << endl;
			return 0;
		}
		// cerr<< ans << endl;
		ans *= prec.pow(e.second);
		prec = e.second;
		pre = e.first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  double max2=0;
  ll sugar=0;
  ll water=0;
  
  for(ll i=0;i*100*A<F;i++){//A
    for(ll j=0;j*100*B<F;j++){//B
      for(ll k=0;k*C<F;k++){//C
        for(ll m=0;m*D<F;m++){//D
          if(i==0&&j==0){
            continue;
          }
          if(k*C+m*D+A*100*i+B*100*j>F){
            continue;
          }
        double unko=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          
          if(max2<=unko&&(k*C+m*D)<=E*(A*i+B*j)){//max<はアウト max=0反映されない
            max2=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          sugar=(k*C+m*D);
            water=(A*100*i+B*100*j);
          }
          }
        }
      }
    }
  
  
  cout<<water+sugar<<" "<<sugar<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			double x1 = Double.parseDouble(sc.next());
			double y1 = Double.parseDouble(sc.next());
			double x2 = Double.parseDouble(sc.next());
			double y2 = Double.parseDouble(sc.next());
			double x3 = Double.parseDouble(sc.next());
			double y3 = Double.parseDouble(sc.next());
			double x4 = Double.parseDouble(sc.next());
			double y4 = Double.parseDouble(sc.next());
			
			x2 -= x1;
			y2 -= y1;
			x4 -= x3;
			y4 -= y3;
			
			double cr = x2*x4 + y2*y4;
			if(Math.abs(cr) <= 1.0e-10) {
				out.println("YES");
			}
			else {
				out.println("NO");
			}
		}
		out.flush();
	}
}
	
//------------------------------//
//-----------//
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;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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();
        }
    }
}

Measured memory_bytes: 16964
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int W,H,x,y,r;cin>>W>>H>>x>>y>>r;
    if(x-r<0 || x+r>W)
       {cout <<"No"<<endl;}
    else if(y-r<0 || y+r>H)
       {cout<<"No"<<endl;}
    else {cout<<"Yes"<<endl;}
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int a, b, k;

    cin >> a >> b >> k;

    for (int i = 0; i < k; i++) {
        if (i % 2 == 0) {
            if (a % 2 == 1) {
                a--;
            }
            a /= 2;
            b += a;
        } else {
            if (b % 2 == 1) {
                b--;
            }
            b /= 2;
            a += b;
        }
    }

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(P& l, P& r){
  return l.second < r.second;
}

int main(void){
  vector<int> v(5);
  int i,sub=0,sum=0;
  REP(i,5){
    cin >> v[i];
    sum+=(v[i]/10)*10;
    if(v[i]%10==0) continue;
    sum+=10;
    if(sub<10-v[i]%10) sub = 10- v[i] % 10;
  }
  cout << sum - sub << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
    ll N;
    cin>>N;
    vector<ll>A(N);
    REP(i,N)cin>>A[i];    
    sort(A.begin(),A.end());

    vector<ll> imos = A;
    REP(i,N-1)imos[i+1]+=imos[i];

    int res = 1;
    for(int i=N-2; i>=0; i--)
    {
        if(A[i+1] <= imos[i]*2)
            res++;
        else
            break;
    }
    cout << res << endl;

    return 0;
}


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

const int MAX = 5000000;
int H, A[MAX+1];

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i + 1;
}
void maxHeapify(int *A, int i){
  int l = left(i);
  int r = right(i);
  int largest;
  if (l <= H && A[l] > A[i]){
    largest = l;
  } else {
    largest = i;
  }
  if (r <= H && A[r] > A[largest]){
    largest = r;
  }

  if ( largest != i){
    int tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void heapIncreaseKey(int *A, int i, int key){
  if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    int tmp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = tmp;
    i = parent(i);
  }
}

void insert(int key){
  H++;
  A[H] = -1;
  heapIncreaseKey(A, H, key);
}

int ExtractMax(int *A){
  int max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A, 1);
  return max;
}


int main() {
    ios::sync_with_stdio(false);

    H = 0;
    string s;
    long long k;

    while(cin >> s){
      if(s == "insert") {
        cin >> k;
        insert(k);
      } else if (s == "extract") {
        cout << ExtractMax(A) << endl;
      } else if (s == "end") {
        return 0;
      }
    }


}

Measured memory_bytes: 5312
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

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

using namespace std;

int main(void){
    const int64_t INF = 999999999999;
    int N,M;
    
    cin >> N >>M;
    int from[M];
    int to[M];
    int cost[M];
    int64_t dist[N];
    bool changed[2*N];
    
    REP(i,N){
        dist[i] = INF;
        changed[2*i]=false;
        changed[2*i+1]=false;
    }
    dist[0]=0;
    
    
    REP(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        // aからbにはいけるがcにはいけない
        from[i]=a;
        to[i]=b;
        cost[i]=-c;
    }
    
    REP(i,2*N){
        REP(j,M){
            if( dist[ to[j] ] > dist[from[j]]+cost[j] ){
                dist[ to[j] ] = dist[from[j]]+cost[j];
                if( to[j] == N-1 )
                    changed[i]=true;
            }
        }
    }
    
    if( changed[2*N-1] ){
        cout << "inf" << endl;
    }else{
        cout << -dist[ N-1 ] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int path[50] = {};

  for (int i=0;i<M;i++) {
    int a, b;
    cin >> a >> b;
    path[a-1]++;
    path[b-1]++;
  }

  for (int i=0;i<N;i++) {
    cout << path[i] << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  string ans = S;
  for (ll i = 0; i < S.size(); i++)
  {
    ans.at(i) += N;
    if (ans.at(i) > 'Z')
      ans.at(i) -= 26;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
T = int(raw_input())
N_list = list()
D_list = list()
for t in range(T):
    N, D = map(int, raw_input().split())
    N_list.append(N)
    D_list.append(D)
    
for t in range(T):
    N = N_list[t]
    D = D_list[t]
    if N % 2 == 0:
        res = N * 127 - D
    else:
        res = 127*(N-1) + D
    print res

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int L,i,x,N;
 cin >> L;
 x = 0;
  
  for (N = L;N > 0; N /= 10) {
   i = N % 10;
   x += i;
  }
  
  if (L % x == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int result = -1;
	rep(i, 10)
	{
		if ((int)((b * 10 + i) * 0.08) == a)
		{
			result = b * 10 + i;
			break;
		}
	}

	cout << result;
}

Measured memory_bytes: 256
<?php
[$a, $b, $c, $k] = explode(' ', trim(fgets(STDIN)));

$remain = $k;
$total = 0;

$total += 1 * max(min($remain, $a), 0);
$remain -= $a;

$remain -= $b;

$total += -1 * max($remain, 0);
$remain -= $c;

echo $total . "\n";

Measured memory_bytes: 16196
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int main(){
  int M;
  cin>>M;
  vector<ll> d(M),c(M);
  for(int i=0;i<M;i++){
    cin>>d.at(i)>>c.at(i);
  }

  ll ans=0;
  for(int i=0;i<M;i++){
    ans+=c.at(i);
  }
  ll sum=0;
  for(int i=0;i<M;i++){
    sum+=c.at(i)*d.at(i);
  }
  while(sum>9){
    ans+=sum/10;
    sum=sum/10+sum%10;
  }
  ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		int A = Integer.parseInt(N.substring(0, 1));
		int B = Integer.parseInt(N.substring(1, 2));
		int C = Integer.parseInt(N.substring(2, 3));
		int D = Integer.parseInt(N.substring(3, 4));
		
		if(A + B + C + D == 7) {
			System.out.println(A + "+" + B + "+" + C + "+" + D + "=7");
		} else if(A + B + C - D == 7) {
			System.out.println(A + "+" + B + "+" + C + "-" + D + "=7");
		} else if(A + B - C + D == 7) {
			System.out.println(A + "+" + B + "-" + C + "+" + D + "=7");
		} else if(A + B - C - D == 7) {
			System.out.println(A + "+" + B + "-" + C + "-" + D + "=7");
		} else if(A - B + C + D == 7) {
			System.out.println(A + "-" + B + "+" + C + "+" + D + "=7");
		} else if(A - B + C - D == 7) {
			System.out.println(A + "-" + B + "+" + C + "-" + D + "=7");
		} else if(A - B - C + D == 7) {
			System.out.println(A + "-" + B + "-" + C + "+" + D + "=7");
		} else if(A - B - C - D == 7) {
			System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
		}
		scan.close();

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int check(int a,int b,int c){
	if(a==b||a==c||b==c) re 0;
	if(a+b<=c||a+c<=b||b+c<=a) re 0;
	re 1;
}
int n;
int l[105];
int ans;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;i++) cin>>l[i];
	for(int i=0;i+2<n;i++)
		for(int j=i+1;j+1<n;j++)
			for(int k=j+1;k<n;k++)
				if(check(l[i],l[j],l[k]))
					ans++;
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<cstdio>
//ABC
//DEF
//GHI
using namespace std;;
typedef pair<int,int> P;
int n,out,can,dx[]={0,0,-1,1},dy[]={1,-1,0,0},dp[3][3][16];
int gox,goy,mox,moy,stx,sty;
int func(int y,int x,int bat){
	if(dp[y][x][bat]>=0)
	return dp[y][x][bat];
	if(bat==0){
		if(y==goy&&x==gox){
			can++;
			out++;
			return dp[y][x][bat]=1;
		}
		out++;
		return 0;
	}
	int nx,ny,sum=0;
	for(int i=0;i<4;i++){
		ny=dy[i]+y;
		nx=dx[i]+x;
		if(!(ny>=0&&ny<3&&nx>=0&&nx<3)||(nx==mox&&ny==moy))
			sum+=func(y,x,bat-1);
		else
			sum+=func(ny,nx,bat-1);
	}
	return dp[y][x][bat]=sum;
}
int main(){
	while(cin>>n,n){
		for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
		for(int k=0;k<=n;k++)
		dp[i][j][k]=-1;
		char a[3];
		can=0;
		out=0;
		int sx[3],sy[3];
		cin>>a[0]>>a[1]>>a[2];
		for(int i=0;i<3;i++){
			if(a[i]=='A'){
				sy[i]=0;sx[i]=0;
			}else if(a[i]=='B'){
				sy[i]=0;sx[i]=1;
			}else if(a[i]=='C'){
				sy[i]=0;sx[i]=2;
			}else if(a[i]=='D'){
				sy[i]=1;sx[i]=0;
			}else if(a[i]=='E'){
				sy[i]=1;sx[i]=1;
			}else if(a[i]=='F'){
				sy[i]=1;sx[i]=2;
			}else if(a[i]=='G'){
				sy[i]=2;sx[i]=0;
			}else if(a[i]=='H'){
				sy[i]=2;sx[i]=1;
			}else if(a[i]=='I'){
				sy[i]=2;sx[i]=2;
			}
		}
		sty=sy[0];stx=sx[0];
		goy=sy[1];gox=sx[1];
		moy=sy[2];mox=sx[2];
		func(sty,stx,n);
		int pre=1;
		for(int i=0;i<n;i++)
		pre*=4;
		printf("%.8lf\n",(double)dp[sty][stx][n]/pre);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n,m,k; cin>>n>>m>>k;
	rep(i,0,n+1){
		rep(j,0,m+1){
			if(j*(n-i)+i*(m-j)==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	
	return 0;
}

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

int main(){
  int dataset;
  int n,k;
  int x[100000+100];
  int d[100000+100];

  cin >> dataset ;
  while( dataset-- ){
    cin >> n >> k;
    for( int i=0;i<n;i++ )
      cin >> x[i];

    int ans = 0, len=0;
    sort( x,x+n );
    for( int i=1;i<n;i++ )
      d[len++] = x[i]-x[i-1];
    sort( d,d+len );

    len = n-k;
    for( int i=0;i<len;i++ )
      ans += d[i];

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

Measured memory_bytes: 1648
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 ; 

int n , res = 0 ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	bool have = 0 ;
	for ( int i = 0 ; i < n ; ++ i ) {
		int x ;
		cin >> x ;
		if ( have && x ) {
			-- x ;
			++ res ; 
		}
		res += ( x / 2 ) ;
		x &= 1 ;
		have = x ; 
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int N,cnt[4];
string S[4]={"AC","WA","TLE","RE"};

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		string T;
		cin>>T;
		for(int j=0;j<4;j++){
			if(T==S[j])cnt[j]++;
		}
	}
	for(int i=0;i<4;i++){
		cout<<S[i]<<" x "<<cnt[i]<<endl;
	}
}


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

map<int,bool> mp;

vector<int> vec;

void dfs(int a, int depth ){ 
  
  if( depth == 12 || mp[a] ){ 
    return ;
  }
  
  vec.push_back(a);
  
  mp[a] = true;
  
  int d = a%10;
  
  if( d >= 1 ){ 
    
    dfs( 10*a+d-1,depth+1 );
    
  }
  
  dfs(10*a+d,depth+1);
  
  if( d < 9 ){ 
    
    dfs( 10*a+d+1,depth+1);
    
  }
  
  return ;
  
}

  

signed main(void){ 
  
  int K; cin >> K;

  
  for(int i = 0; i < 10; i++){ 
    
    dfs(i,0);
    
  }
  
  sort(vec.begin(),vec.end());
  
  cout << vec[K] << endl;
  
  return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	ll res{0};
	for (ll i = 0; i < N;)
	{
		ll j = i;
		ll sum{0};
		while (j < N && A[j])
		{
			sum += A[j];
			++j;
		}

		res += sum/2;
		i = j + 1;
	}
	std::cout << res << std::endl;
}


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

int main() {
int H,N;
cin >> H >> N;
  int a,b;
  a = 0;
  for(int i = 0; i < N; i++){
    cin >> b;
  	a += b;
  }
  if(a>= H){
  	cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// 世界は変わらない
#include <bits/stdc++.h>
#define int long long int
#define eb emplace_back
#define vi vector <int>
#define pii pair <int, int>
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n, c = 0;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = n - 1;
    while(i < j) {
        if(s[i] == 'W' and s[j] == 'R') {
            c++;
            i++;
            j--;
        }
        if(s[i] == 'R')
            i++;
        if(s[j] == 'W')
            j--;
    }
    cout << c;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

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

signed main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	int cnt=1,ans=0;
	while(cnt<b){
		ans++;
		cnt+=(a-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//A
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    string s, t;
    cin >> s >> t;
    reg int Ans = 0;
    for (reg int i = 0; i < (int)s.size(); i++)
        if (s[i] == t[i]) Ans++;
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(raw_input())
t=map(int,raw_input().split())
a=map(int,raw_input().split())

if t[n-1]!=a[0]:
    print(0)
    exit()

ans=1
for i in xrange(n):
    if i==0 or i==n-1:
        continue
    elif t[i]>t[i-1]:
        if a[i]<t[i] and a[i]==a[i+1]:
            print(0)
            exit()
        elif a[i]!=t[i] and a[i]!=a[i+1]:
            print(0)
            exit()
    else:
        if t[i]==a[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
        elif t[i]>a[i]:
            if a[i]==a[i+1]:
                ans=(ans*a[i])%mod
        elif a[i]>t[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
            else:
                print(0)
                exit()
print(ans%mod)


Measured memory_bytes: 14540
#include <stdio.h>
#include <string.h>
char s[20],t[20];
int main(){
	int i,len;
	scanf("%s%s",s,t);
	len=strlen(s);
	for(i=0;i<len;i++)
		if(s[i]!=t[i])return 0*printf("No\n");
	return 0*printf("Yes\n");
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int ih[5] = { 0,1,0,-1,0 };
const int iw[5] = { 0,0,1,0,-1 };
int h, w, cnt = 0;
void dfs(int nh, int nw, vector<string> grid, vector<vector<bool>>& painted) {
	rep(i, 5) {
		int dh = ih[i] + nh, dw = iw[i] + nw;
		if (dh < 0 || dh >= h || dw < 0 || dw >= w)continue;
		if (grid[dh][dw] == '.' || painted[dh][dw])continue;
		painted[dh][dw] = true;
		cnt++;
		dfs(dh, dw, grid, painted);
	}
}

int main() {
	string ans = "Yes";
	cin >> h >> w;
	vector<string>grid(h);
	vector<vector<bool>>painted(h, vector<bool>(w, false));
	rep(i, h)cin >> grid[i];
	rep(i, h) {
		rep(j, w) {
			if (grid[i][j] == '.' || painted[i][j])continue;
			cnt = 0;
			dfs(i, j, grid, painted);
			if (cnt == 1) {
				ans = "No";
				break;
			}
		}
		if (cnt == 1)break;
	}
	cout << ans << endl;
	return 0;
}


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

#define ll long long

using namespace std;

int main() {
  string s;
  cin >> s;
  int len = s.size();
  ll result = 0;
  result += stoll(s);
  for (int flags = 1; flags < 1 << (len - 1); ++flags) {
    vector<int> pos;
    for (int p = 0; p < len - 1; ++p) {
      if (flags & 1 << p) pos.push_back(p);
    }
    int posLen = pos.size();
    for (int i = 0; i < posLen; ++i) {
      int start = i == 0 ? 0 : pos[i - 1] + 1;
      int length = pos[i] + 1 - start;
      result += stoll(s.substr(start, length));
    }
    result += stoll(s.substr(pos[posLen - 1] + 1, len - pos[posLen - 1]));
  }
  cout << result << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int dest[200010][60];

void solve() {
    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i < N; i++) {
        int a;
        cin >> a;
        --a;
        dest[i][0] = a;
    }

    for (ll j = 0; j < 59; j++) {
        for (ll i = 0; i < N; i++) {
            dest[i][j + 1] = dest[dest[i][j]][j];
        }
    }

    ll cur = 0;
    for (ll i = 0; i < 60; i++) {
        if (K & 1) cur = dest[cur][i];
        K >>= 1;
    }

    cout << cur + 1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

def main():
    N, M = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(M)]
    box = [1] * N
    red_flag = [0] * N
    red_flag[0] = 1
    ans = 0
    for i in range(M):
        if red_flag[xy[i][0] - 1] == 1:
            red_flag[xy[i][1] - 1] = 1
        box[xy[i][0] - 1] -= 1
        if box[xy[i][0] - 1] == 0:
            red_flag[xy[i][0] - 1] = 0
        box[xy[i][1] - 1] += 1
    for i in range(N):
        if box[i] != 0 and red_flag[i] == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int d, m;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> t(d);
    for(auto &&n : c) cin >> n;
    for(auto &&n1 : s) for(auto &&n2 : n1) cin >> n2;
    for(auto &&n : t){
        cin >> n;
        --n;
    }
    cin >> m;

    vector<int> l(26);

    vector<int> v(26);

    int sum, o, n, temp;
    
    rep(i, d){
        v[t[i]] += s[i][t[i]];
        l[t[i]] = -1;
        rep(j, 26) v[j] -= c[j] * (++l[j]);
        rep(j, 26) sum += v[j];
    }

    rep(i, m){
        sum = 0;
        cin >> temp >> n;
        o = t[--temp];
        t[temp] = --n;
        v[o] = v[n] = l[o] = l[n] = 0;
        rep(j, d){
            if(t[j] == o || t[j] == n){
                v[t[j]] += s[j][t[j]];
                l[t[j]] = -1;
            }
            v[o] -= c[o] * ++l[o];
            v[n] -= c[n] * ++l[n];
        }
        rep(j, 26) sum += v[j];
        cout(sum);
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vectotr<vector<long long>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    V a(n,0);
    rep(i,q){
        ll tmp;
        cin>>tmp;
        tmp--;
        a[tmp]++;
    }
    rep(i,n){
        if(k-(q-a[i])<=0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray();
        long k = sc.nextLong();
        for(int i = 0; i < k; i++){
            if(s[i] == '1'){
                continue;
            }else{
                System.out.println(s[i]);
                return;
            }
        }
        System.out.println(s[(int)k-1]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 21588
/* compatible with http://kk.kake.info.waseda.ac.jp/~kakehi/lp12/wl/ */
#include <stdio.h>
enum{M=4200};
bigint_init(int a[], int x){
	int z;
	z=0;
	while(z<=M){a[z]=0;z=z+1;}
	a[M]=0;
	while(x/10){a[a[M]]=x%10;a[M]=a[M]+1;x=x/10;}
	a[a[M]]=x%10;
	a[M]=a[M]+1;
}
bigint_print(int a[]){
	int i;
	i=a[M]-1;
	while(i>-1){fputc(a[i]+'0',stdout);i=i-1;}
}
bigint_add(int a[], int x[]){
	int i,c;
	i=0;
	c=0;
	while(i<M){
		a[i]=a[i]+x[i]+c;
		c=a[i]/10;
		a[i]=a[i]%10;
		if(a[i])a[M]=i+1;
		i=i+1;
	}
}
bigint_mul(int A[], int x[]){
	int i,j,c;
	int a[M];
	i=A[M]-1;c=0;
	while(c<M){a[c]=0;c=c+1;}
	c=0;
	while(i>-1){
		j=0;
		while(j<x[M]){
			a[i+j]=a[i+j]+A[i]*x[j];
			j=j+1;
		}
		i=i-1;
	}
	i=0;
	while(i<M){
		a[i]=a[i]+c;
		c=a[i]/10;a[i]=a[i]%10;
		if(a[i])A[M]=i+1;
		i=i+1;
	}
	i=0;while(i<M){A[i]=a[i];i=i+1;}
}
int main(){
	int f1[M+1],f2[M+1];
	int i,n,c;
	i=2;
	bigint_init(f1,1);
	while(i<1501){
		bigint_init(f2,i);
		bigint_mul(f1,f2);
		i=i+1;
	}
	bigint_init(f2,2);
	bigint_add(f1,f2);
	bigint_print(f1);
	fputc('\n',stdout);
	i=0;
	n=0;
	c=fgetc(stdin);
	while('0'<=c&&c<='9'){
		n=n*10;n=n+c-'0';
		c=fgetc(stdin);
	}
	while(i<n){
		bigint_init(f1,i+2);
		bigint_print(f1);
		fputc('\n',stdout);
		i=i+1;
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000

int main()
{
  ll N,K;
  ll R,S,P;
  string T;
  cin>>N>>K>>R>>S>>P;
  cin>>T;
  
  ll score=0;
  vector<ll> D(N+1,-1);//rsp
  
  for (ll i=0;i<N;i++)
  {
    if (i-K<0)
    {
      if (T[i]=='r'){
        score += P;
        D[i]=2;
      }
      else if (T[i]=='s'){
        score +=R;
        D[i]=0;
      }
      else if (T[i]=='p'){
        score +=S;
        D[i]=1;
      }
    }
    else if (i-K>=0)
    {
      if (T[i]=='r' && D[i-K]!=2){
        score += P;
        D[i]=2;
      }
      else if (T[i]=='s' && D[i-K]!=0){
        score +=R;
        D[i]=0;
      }
      else if (T[i]=='p' && D[i-K]!=1){
        score +=S;
        D[i]=1;
      }
    }
  }
  cout<<score<<endl;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc080/tasks/abc080_a

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    N, A, B = map(int, input().split())
    result = min(N * A, B)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
'use strict';
(function(stdin) {
  var inputs  = stdin.toString().trim().split('\n');
  var S = parseInt(inputs[0]);
  var h = Math.floor(S/(60*60));
  var m = Math.floor(S/60%60);
  var s = S % 60

  console.log([h,m,s].join(':'));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15556
#include <cstdio>
#include <algorithm>

#define ll long long;



int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int max = a;
    if(b > max)
        max = b;
    if(c > max)
        max = c;
    int rez = a + b + c - max;
    printf("%d", rez);

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s; cin >> s;
    if(s.size()==1)cout << s[0] - '0' << ln;
    else{
    int nine = count(all(s), '9');
    if(nine == s.size())cout << (ll)s.size() * 9 << ln;
    else{
        ll sum = 0;
        rep(i, s.size())sum+=s[i] -'0';
        ll res = s[0] - '1';
        rept(i, 1, s.size()){
            res += 9;
        }
        chmax(res, sum);
        cout << res << ln;
    }
    }
}


Measured memory_bytes: 3604
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input())
b = list(input())

if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
    int th,ts,ah,as;
    cin>>th>>ts>>ah>>as;
    int i=1;
    while(th>0 && ah>0)
    {
        if(i%2==0)
        {
            th=th-as;
            i++;
        }
        else
        {
            ah=ah-ts;
            i++;
        }
    }
    if(th<=0)
    cout<<"No";
    else
    cout<<"Yes";    
}

Measured memory_bytes: 3132
package main

import (
	"fmt"
	"strings"
)

func main() {
	for {
		var h, w int
		if _, err := fmt.Scan(&h, &w); err != nil {
			panic(err)
		}
		if h == 0 && w == 0 {
			break
		}

		row := strings.Repeat("#", w) + "\n"
		rect := strings.Repeat(row, h)
		fmt.Println(rect)
	}
}



Measured memory_bytes: 1320
#include<cstdio>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
const int N=2e5+5;
int n,k,a,h,ans,t[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();k=read();
	for(int i=1;i<=n;i++)a=read(),t[a]++;
	sort(t+1,t+n+1);
	while(h+1<=n&&t[h+1]==0)h++;
	if(n-h<=k){printf("0");return 0;}
	for(int i=h+1;i<=n-k;i++)ans+=t[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>


using namespace std;

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

const ll inf=1000000000LL*2000+1;


ll solve(vector<vector<pii> >& v)
{
	vector<pair<ll,int> > vf;
	int n=v.size()-1;
	ll result[2];
	int is_changed;

	vf.resize(v.size(), make_pair(-inf*2, 0));
	vf[1]=make_pair(0, 1);
	for(int j=0;j<2;j++)
	{
		for(int k=0;k<n;k++)
		{
			is_changed=0;
			for(int i=1;i<=n;i++)
			{
				if(vf[i].second==0) continue;
				vf[i].second=0;
				for(auto e: v[i])
				{
					int na=e.first;
					ll nc=vf[i].first+e.second;

					if(nc<=vf[na].first) continue;
					vf[na]=make_pair(nc, 1);
					is_changed=1;
				}
			}
			if(!is_changed) break;
		}
		result[j]=vf[n].first;
	}
	if(result[0]!=result[1]) return inf;
	return result[0];
}


int main(void)
{
	int n, m;
	vector<vector<pii> > v;
	ll result;

	while(scanf("%d%d", &n, &m)==2)
	{
		v.clear();
		v.resize(n+1);
		for(int i=0;i<m;i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			v[a].push_back(make_pair(b, c));
		}
		result=solve(v);
		if(result==inf) printf("inf\n");
		else printf("%lld\n", result);
	}

	return 0;
}



Measured memory_bytes: 256