akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int n;

int main() {
  cin >> n;
  string a, b, c;
  cin >> a>> b >> c;
  int cnt = 0;
  for(int i=0; i<n; i++){
    if(a[i] == b[i] && b[i] == c[i]) continue;
    if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) {
      cnt += 2;
    } else{
      cnt += 1;
    }
  }
  cout << cnt << endl;

  return 0;
}


//EOF


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U>& a) { cin >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

class UnionFind {
private:
  std::vector<size_t> P;
  std::vector<size_t> S;
  size_t find(size_t x) { return P[x] == x ? x : P[x] = find(P[x]); }
public:
  UnionFind(size_t n) {
    P.resize(n);
    iota(P.begin(), P.end(), 0);
    S.resize(n);
    fill(S.begin(), S.end(), 1);
  }
  void unite(size_t x, size_t y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (S[x] < S[y]) {
      P[x] = y;
      S[y] += S[x];
    } else {
      P[y] = x;
      S[x] += S[y];
    }
  }
  bool same(size_t x, size_t y) { return find(x) == find(y); }
  size_t size(size_t x) { return S[find(x)]; }
};

using P = pair<i64, i64>;
signed main() {
  i64 n, m;
  cin >> n >> m;
  vector<P> ab(m);
  cin >> ab;
  auto uf = UnionFind(n);
  vector<i64> res(m);
  i64 acc = n * (n - 1) / 2;
  RREP(i, m) {
    i64 a = ab[i].first - 1, b = ab[i].second - 1;
    res[i] = acc;
    if (!uf.same(a, b)) {
      acc -= uf.size(a) * uf.size(b);
      uf.unite(a, b);
    }
  }
  REP(i, m) {
    cout << res[i] << endl;
  }
}

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

using namespace std;

#define EPS 1e-9
#define For(i,N) FOR(i,N)
#define Forr(i,a,b) FORR(i,a,b)
#define Fotr(i,a,b,c) FOTR(i,a,b,c)
#define FOR(i,N) FORR(i, 0, N)
#define FORR(i,a,b) FOTR(i, a, b, 1)
#define FOTR(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define FOREACH(i,x) for(__typeof__((x).begin())i=(x).begin();i!=(x).end();i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define BCHK(a,x) (((a)>>(x))&1)
#define BSET(a,x) ((a)|(1<<(x)))
#define BCLR(a,x) ((a)&(~(1<<(x))))
#define BTGL(a,x) ((a)^(1<<(x)))
#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
#define read() freopen("input.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
#define cpp_io() {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define BUFFSIZE 30000
#define INF 1000000000
#define MAX 300010
#define MOD 1000000007
#define pb push_back
#define mkpr make_pair
#define pii pair<int, int>
#define PI acos(-1)
#define ll long long
#define fi first
#define si second
#define all(x) x.begin(), x.end()

char CRTBUFF[BUFFSIZE];
#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};
ll power(ll x,ll y)
{
    if( y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);

}
int main(){
    cpp_io();
    #ifdef LOCAL
        //read();
        //write();
    #endif
    int n;
    cin>>n;
    int a[n+10];
    map<int,int>mp;
    int bit=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
        if(mp[a[i]]>1) bit = 1;
    }
    if(bit==1) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;





    return 0;

}


Measured memory_bytes: 10368
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int r,g;
	cin>>r>>g;
	cout<<2*g-r<<endl;;
}

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


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


    // まず、最長共通部分列 (LCS) の長さを求める
    // dp[i+1][j+1]: s の i 文字目までと t の j 文字目までのLCSの長さ
    int dp[3001][3001] = {};
    for( int i = 0; i < s.length(); ++i ){
        for( int j = 0; j < t.length(); ++j ){
            if( s[i] == t[j] ) dp[i+1][j+1] = dp[i][j] + 1;
            else               dp[i+1][j+1] = max( dp[i+1][j], dp[i][j+1] );
        }
    }

    // dp[s.length()][t.lenth()] から復元して答えの文字列を求める
    string ans = "";
    int i = s.size(), j = t.size();
    while( i > 0 and j > 0 )
    {
        if( dp[i][j] == dp[i-1][j] ) --i;
        else if( dp[i][j] == dp[i][j-1] ) --j;
        else{
            ans = s[i-1] + ans;
            --i, --j;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
set<int> kk;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        kk.insert(k);
    }

    if(kk.size()==n)
        cout<<"YES";
    else
        cout<<"NO";
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        long i=1;

        while(N >= pow(K, i)){
            i++;
        }
        System.out.println(i);
    }

    private static long pow(long n, long k){
        if(k==0){return 1;}
        if(k == 1){return n;}
        else{
            return pow(n, k-1)*n;
        }
    }
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
bool f(int x)
{
    vector<int> v;
    while (x > 0)
        v.push_back(x % 10), x /= 10;
    reverse(all(v));
    rep(i, v.size() / 2)
    {
        if (v[i] != v[v.size() - 1 - i])
            return false;
    }
    return true;
}
void solve(void)
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; ++i)
    {
        if (f(i))
            ans++;
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3592
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun check (k line val)
  (let* ((vals (sort (mapcar (lambda (x) (mod x val)) line) #'<))
         (l-sum 0)
         (r-sum (- (* (length line) val) (apply #'+ vals))))
    (loop for i in vals
          do
             (progn
               (incf l-sum i)
               (decf r-sum (- val i)))
          when (>= l-sum r-sum)
            return (<= l-sum k))))

(defun main (k line)
  (let ((sum (apply #'+ line)))
    (loop for i from 1
          until (> (* i i) sum)
          when (and (zerop (mod sum i)) (check k line i))
            maximize i
          when (and (zerop (mod sum i)) (check k line (/ sum i)))
            maximize (/ sum i))))

(let* ((n (read))
       (k (read))
       (line (read-times n)))
  (princ (main k line)))


Measured memory_bytes: 21564
# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    N = int(stdin.readline().rstrip())
    P = stdin.readline().rstrip().split()
    P = [int(i) for i in P]

    ans = 1
    min = P[0]
    for i in range(N-1):
        if P[i+1] < min:
            ans += 1
            min = P[i+1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25768
#include <iostream>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC99();
}

void ABC99(){
    int n;
    cin>>n;
    if(n<1000)cout<<"ABC";
    else cout<<"ABD";
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

/*ll ma=998244353;
ll power(ll v,ll ti){
if(ti==1)
    return v;
ll x=power(v,ti/2);
x=(x*x)%ma;
if(ti%2==1)
    x=(x*v)%ma;
return x;

}
struct t{
int a,b;
};
vector<vector<t > >g;
vector<int> v;


ll n;


void dfs(int i,int sum){
v[i]=1;


for(int j=0;j<go[i].size();j++){
    int x=go[i][j].a;
    int y=go[i][j].b;
    if(v[x]==0){
        dfs(x,min(y,sum));

    }

}

}*/
int x[200001];
bool c(int i,int j){
return x[i]<x[j];
}

 int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,q;
cin>>n>>q;
vector<int> m;
int s[n],t[n];
for(int i=0;i<n;i++){
    cin>>s[i]>>t[i]>>x[i];

    m.pb(i);


}
sort(m.begin(),m.end(),c);
set<int> si;
map<int,int> f;
for(int i=0;i<q;i++)
{
    int d;
    cin>>d;
    f[d]=i;
    si.insert(d);


}
vector<int> ans(q,-1);
for(int j=0;j<n;j++){
    if(si.size()==0)
    break;
        int i=m[j];
    set<int>::iterator it1,it2,it3;
    it3=it1=si.lower_bound(s[i]-x[i]);
    it2=si.lower_bound(t[i]-x[i]);
    for(;it1!=it2;it1++){
        ans[f[*it1]]=x[i];
    }
    si.erase(it3,it2);

}

  for(int i=0;i<q;i++)
        cout<<int(ans[i])<<endl;






}


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

int main()
{
	int n, x, mx, mn;
	
	scanf("%d", &n);
	scanf("%d", &x);
	mx = mn = x;
	for (int i = 1; i < n; i++) {
		scanf("%d", &x);
		mx = max(x, mx);
		mn = min(x, mn);
	}
	printf("%d\n", mx - mn);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        // 良い展望台フラグ
        boolean[] good = new boolean[N];
        // 展望台の標高
        HashMap<Integer,Integer> high = new HashMap<Integer,Integer>();
        for (int i = 0; i < N; i++) {
            high.put(i+1,sc.nextInt());
            good[i] = true;
        }
        int A = 0;
        int B = 0;
        for (int i = 0; i < M; i++) {
              A = sc.nextInt();
              B = sc.nextInt();
            if(high.get(A)>=high.get(B)){
                good[B-1] = false;
            }
            if(high.get(A)<=high.get(B)){
                good[A-1] = false;
            }
        }
        // 良い展望台の数
        int count = 0;
        for (int i = 0; i < N; i++) {
            if(good[i]){
                count++;
            }
        }
        System.out.println(count);

    }
}


Measured memory_bytes: 59276
#include <bits/stdc++.h>
using namespace std;
int a[50][50],c[50],sum[50];
int main(){
	int n,m,x,ans=1<<30;
	cin>>n>>m>>x;
	for (int i=1;i<=n;i++){
		cin>>c[i];
		for (int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	} 
	for (int i=0;i<(1<<n);i++){
		memset(sum,0,sizeof(sum));
		int cost=0;
		for (int j=0;j<n;j++){
			if(i&(1<<j)){
				cost+=c[j+1];
				for (int k=1;k<=m;k++){
					sum[k]+=a[j+1][k];
				}
			}
		}
		bool bad=0;
		for (int k=1;k<=m;k++){
			if (sum[k]<x){
				bad=1;
			}
		}
		if (bad){
			continue;
		}
		ans=min(ans,cost);
	} 
	if (ans==1<<30){
		cout<<-1;
	}else{
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3596
(let ((a (read))
      (b (+ 2(read))))
  (format t "~A~%" (concatenate 'string (loop :repeat b collect #\#)))
  (loop :repeat a do(format t "#~A#~%" (read-line)))
  (format t "~A~%" (concatenate 'string (loop :repeat b collect #\#))))

Measured memory_bytes: 16096
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
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; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int m,k;
    cin >> m >> k;
    if(k >= 1<<m) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        cout << "0 0" << endl;
        return 0;
    }
    if(m == 1) {
        if(k == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    rep(i,1<<m) if(i != k) cout << i << " ";
    cout << k << " ";
    rrep(i,1<<m) if(i != k) cout << i << " ";
    cout << k << endl;
}


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

string to2(string s) {
  string t="";
  for(int i=0; i<s.size(); i++) {
    int x;
    if(isdigit(s[i])) x=s[i]-'0';
    else x=s[i]-'a'+10;
    string r="";
    while(x) {
      r+='0'+x%2;
      x/=2;
    }
    while(r.size()<4) r=r+'0';
    reverse(r.begin(),r.end());
    t+=r;
  }
  return t;
}

string toN(string s) {
  int x=0,y=1;
  for(int i=s.size()-1; i>=0; i--) {
    if(s[i]=='1') x+=y;
    y*=2;
  }
  stringstream ss;
  string t;
  ss << x;
  ss >> t;
  return t;
}
string toD(string s) {
  int x=0,y=5000000;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='1') x+=y;
    y/=2;
  }
  stringstream ss;
  string t;
  ss << x;
  ss >> t;
  while(t.size()<7) t='0'+t;
  int i;
  for(i=t.size()-1; i>=1; i--) {
    if(t[i]!='0') break;
  }
  return t.substr(0,i+1);
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    s=to2(s);
    if(s[0]=='1') cout << '-';
    cout << toN(s.substr(1,24))+'.'+toD(s.substr(25)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

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

    cout<<a*a-b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


string s;
int k;
set<string> st;

int main(){
	cin >> s;
	cin >> k;
	int n = s.size();
	
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= n-i && j <= k; j++){
			st.insert(s.substr(i,j));
		}
	}
	
	for(auto i = st.begin(); ; i++, k--){
		if(k == 1){
			cout << *i << endl;
			break;
		} 
	}
	
	return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    string s;
  	int count = 0;
    cin >> s;
    set<char> c;
    char found;
    char alph[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 'w', 'x', 'y', 'z'};
    for(int i; i<s.length(); i++){
        c.insert(s[i]);
    }
    for(int i=0; i<26; i++){
        if(c.find(alph[i])==c.end()){
            found = alph[i];
            break;
        }
      	count++;
    }
    if(count==26) cout << "None" << endl;
    else cout << found << endl;
    return 0;
}

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

int main(){
    ll N,W;
    cin>>N>>W;
    V v(N),w(N);
    rep(i,N)cin>>v[i]>>w[i];
    VV dp(N+1,V(W+1,0));
    rep(i,N){
        rep(j,W+1){
            if(j<w[i])dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
        }
    }
    cout<<dp[N][W]<<endl;
}



Measured memory_bytes: 10824
////////////////////////////////////
///     Please Give Me AC!!!     ///
////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

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

    int idx;
    rep(i, S.size()){
        if(S[i] != '1'){
            idx = i;
            break;
        }
    }

    if(idx < K){
        cout<< S[idx] << endl;
    }else{
        cout<< 1 << endl;
    }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b)
{if (a < b) {a = b; return true;} return false;}
template<class T> inline bool chmin(T& a,T b)
{if (a > b) {a = b; return true;} return false;}

int main(){
    int N, W;
    long long dp[110][100100] = {0};
    cin >> N >> W;
    vector<int> weight(N);
    vector<long long> value(N);
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }
    
    for (int i = 0; i < N; i++) {
        for(int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }
    
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 86272
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

const int maxn = 1005;
int top, stack[maxn];

void push(int x)
{
	stack[++top] = x;
}

int pop()
{
	top--;
	return stack[top + 1];
}

int main()
{
	int a, b;
	top = 0;
	char s[105];
	while (scanf("%s",s)!=EOF)
	{
		if (s[0] == '+')
		{
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-')
		{
			b = pop(), a = pop();
			push(a - b);
		}
		else if (s[0] =='*')
		{
			a = pop(), b = pop();
			push(a*b);
		}
		else
		{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 2704
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if ((a - b) % 2 == 0 && (a - b)) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
  return 0;	
}

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

using namespace std;

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

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

  if (max_damage >= h)
  {
    cout << "Yes" << endl;
  } else
  {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

const ll MAX = (ll)pow(10, 5)*2 + 1;
vector <ll> a_p(MAX), b_p(MAX);
vector <ll> a_d(MAX), b_d(MAX);

void init(ll n) {
  rep(i, n) {
    a_p.at(i) = i;
    b_p.at(i) = i;
    a_d.at(i) = 0;
    b_d.at(i) = 0;
  }
  return;
}

ll a_find(ll n) {
  if (a_p.at(n) == n) return n;
  else return a_p.at(n) = a_find(a_p.at(n));
}
ll b_find(ll n) {
  if (b_p.at(n) == n) return n;
  else return b_p.at(n) = b_find(b_p.at(n));
}

void a_unite(ll n, ll m) {
  n = a_find(n);
  m = a_find(m);
  if (n == m) return;
  if (a_d.at(n) < a_d.at(m)) a_p.at(n) = m;
  else {
    a_p.at(m) = n;
    if (a_d.at(n) == a_d.at(m)) a_d.at(n)++;
  }
  return;
}
void b_unite(ll n, ll m) {
  n = b_find(n);
  m = b_find(m);
  if (n == m) return;
  if (b_d.at(n) < b_d.at(m)) b_p.at(n) = m;
  else {
    b_p.at(m) = n;
    if (b_d.at(n) == b_d.at(m)) b_d.at(n)++;
  }
  return;
}

int main() {
  ll n, k, l; cin >> n >> k >> l;
  init(n);
  rep(i, k) {
    ll p, q; cin >> p >> q;
    a_unite(p-1, q-1);
  }
  rep(i, l) {
    ll p, q; cin >> p >> q;
    b_unite(p-1, q-1);
  }
  map <pair <ll, ll>, ll> score;
  rep(i, n) {
    pair <ll, ll> p = make_pair(a_find(i), b_find(i));
    if (score.count(p)) score.at(p)++;
    else score[p] = 1;
  }
  rep(i, n) {
    ll res = score.at(make_pair(a_find(i), b_find(i)));
    if (i) cout << ' ' << res;
    else cout << res;
  }
  cout << endl;
}

Measured memory_bytes: 20848
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    long long h, w, k;
    cin >> h >> w >> k;

    char c[h][w];
    char c2[h][w];

    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> c[i][j];
            c2[i][j] = c[i][j];
        }
    }

    long long ans = 0;
    for(long long bit_y = 0; bit_y < (1 << h); bit_y++){
        for(long long bit_x = 0; bit_x < (1 << w); bit_x++){
            
            for(long long mask_y = 0; mask_y < h; mask_y++){
                for(long long mask_x = 0; mask_x < w; mask_x++){
                    if(bit_y & (1 << mask_y) || bit_x & (1 << mask_x)){
                        c[mask_y][mask_x] = 'R';
                    }
                }
            }

            long long cnt = 0;

            for(long long i = 0; i < h; i++){
                for(long long j = 0; j < w; j++){
                    if(c[i][j] == '#') cnt++;
                    c[i][j] = c2[i][j];
                }
            }
            
            if(cnt == k) ans++;
        }
    }

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

Measured memory_bytes: 3600
#include<iostream>

int main(){

  int h, w;
  while(1){
    std::cin >> h >> w;
    if(h == 0 && w == 0) break;

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	if(i == 0 || i % 2 == 0){
	  if(j == 0 || j % 2 == 0){
	    std::cout << '#';
	  }else{
	    std::cout << '.';
	  }
	}else if (j == 0 || j % 2 == 0){
	  std::cout << '.';
	}else {
	  std::cout << '#';
	}
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
	int v,n,sumn=0;
	int sum=0,kind=0;
	while(cin >> v){
		cin.ignore();
		cin >> n;
		
		sum += v*n;
		sumn+= n;
		kind++;
	}
	cout << sum << endl;
	printf("%.0f\n", floor((double)sumn/kind+0.5));
}

Measured memory_bytes: 0
n = int(input())
a = [i for i in map(int, input().split())]

#print(n)
#print(a)

# ボールに書かれた数の出現数
syutsugen_counts = [0] * n
# 同じボールを選ぶ方法
choice_counts = [0] * n
# ボールが1つ減った時に同じボールを選ぶ方法
decrease_one_choice_counts = [0] * n

total_choice_count = 0

for i in range(n):
  ball_num = a[i] - 1
  syutsugen_counts[ball_num] += 1

for i in range(n):
  syutsugen_count = syutsugen_counts[i]
  if syutsugen_count < 2:
    continue
  # 出現数が2以上から同じボールを選べる
  choice_count = int((syutsugen_count * (syutsugen_count-1) / 2))
  choice_counts[i] = choice_count
  total_choice_count += choice_count
  
  # 出現数が2の場合はここまで
  if syutsugen_count < 3:
    continue
  
  # 出現数が3以上なら一つ減った場合でも同じボールが選べる
  decrease_one = syutsugen_count - 1
  decrease_one_choice_count = int((decrease_one * (decrease_one-1) / 2))
  decrease_one_choice_counts[i] = decrease_one_choice_count

for i in range(n):
  ball_num = a[i] - 1
  choice_count = choice_counts[ball_num]
  decrease_one_choice_count = decrease_one_choice_counts[ball_num]
  print(total_choice_count - choice_count + decrease_one_choice_count)

Measured memory_bytes: 87244
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, p;
    cin >> a >> p;

    int tp = a * 3 + p;
    cout << (tp / 2) << endl;

}

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

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	
	vector<int> P(N);

	for (auto &x : P) {
		cin >> x;
	}

	int n1 = count_if(P.begin(), P.end(), [&](auto x) {return x <= A; });
	int n2 = count_if(P.begin(), P.end(), [&](auto x) {return A + 1 <= x && x <= B; });
	int n3 = count_if(P.begin(), P.end(), [&](auto x) {return B + 1 <= x; });

	int ans = min({ n1, n2, n3 });
	cout << ans << endl;
}


Measured memory_bytes: 256
var a,b:array[0..20000]of longint;
    n,x,i:longint;
begin
  readln(n);
  for i:=1 to n do
    a[i]:=20009*i;
  for i:=1 to n do
    b[i]:=20009*(n-i+1);
  for i:=1 to n do
  begin
    read(x);
    dec(a[x],n-i+1);
  end;
  for i:=1 to n do
    write(a[i],' ');
  writeln;
  for i:=1 to n do
    write(b[i],' ');
  writeln;
end.

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int n,m,i,j,l,k,x,fc=1;
	int c[1001],d[1001];
	scanf("%d",&n);
	for(i=1;i<=2*n;i++)d[i]=i;
	scanf("%d",&m);
	for(j=0;j<m;j++){
		scanf("%d",&k);
		if(k==0){
			for(i=1;i<2*n+1;i+=2){
				c[i]=d[fc];
				fc++;
			}
			for(i=2;i<2*n+1;i+=2){
				c[i]=d[fc];
				fc++;
			}
			fc=1;
		}
		else{
			x=2*n-k;
			for(i=1;i<=x;i++)c[i]=d[k+i];
			for(i=1;i<=k;i++){
				x++;
				c[x]=d[i];
			}
		}
		for(i=0;i<2*n+1;i++)d[i]=c[i];
	}
	for(i=1;i<=2*n;i++)printf("%d\n",c[i]);
	return 0;
}



Measured memory_bytes: 2104
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
    print(abs(a[0] - W))
else:
    x = abs(a[-2] - a[-1])
    y = abs(a[-1] - W)
    
    ans = max(x, y)
    print(ans)


Measured memory_bytes: 38844
N, K = map(int, input().split())

X = [x for x in range(1,N+1)]
Xn = [x for x in X if x % K == 0]

c_odd = 0
c_even1 = 0
c_even2 = 0

for x in X:
    if x % K == 0:
        c_odd += 1
        c_even1 += 1
    elif x % K == K/2:
        c_even2 += 1

if K % 2 != 0:
    ans = c_odd ** 3
else:
    ans = c_even1 ** 3 + c_even2 ** 3
      
print(ans) 

Measured memory_bytes: 12568
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
char s[maxn], t[maxn];
int main()
{
    scanf("%s%s", s, t);
    int len = strlen(s);
    bool f = true;
    for (int i = 0; i < len; i++) {
        if(s[i] != t[i]) f = false;
    }
    if(f) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string s;
	int a = INF, b = MINF;
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'C') a = min(a, i);
		if (s[i] == 'F') b = i;
	}
	if (a < b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}



int main()
{
  int a, b;
  cin>>a>>b;
  int ans = a - 2*b;
  if(ans < 0)
  {
    cout<<0<<endl;
  }
  else
  {
    cout<<ans<<endl;
  }
  return 0;
}


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

const int mod = 1e9 + 7;

int C[3000][3000];

int c(int x, int y) {
	if (y == 0 || x == y)return 1;
	else if (C[x][y] > 0)return C[x][y];
	else return C[x][y] = (c(x - 1, y - 1) + c(x - 1, y)) % mod;
}

signed main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		if (n - k < i) {
			cout << 0 << endl;
			continue;
		}
			cout << (c(n - k + 1, i + 1) * c(k - 1, i)) % mod << endl;
	}
}


Measured memory_bytes: 45696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;



int main() {
    string s, t;
    cin >> s >> t;
    int ctr = 0;
    rep (i, s.size()) {
        if (s[i] != t[i]) {
            ctr++;
        }
    }
    cout << ctr << endl;
}




Measured memory_bytes: 3848
#include<cstdio>
int last[500];
long long s[500][30];
long long c[30];

int main(){
    int d;
    scanf("%d",&d);
    for(int i = 1; i <= 26; i++) scanf("%lld",&c[i]);
    for(int i = 1; i <= d; i++){
        for(int j = 1; j <= 26; j++) scanf("%lld",&s[i][j]);
    }
    long long cur = 0;
    for(int i = 1; i <= d; i++){
        int t;
        scanf("%d",&t);
        cur += s[i][t];
        last[t] = i;
        for(int j = 1; j <= 26; j++) cur -= c[j]*(i-last[j]);
        printf("%lld\n",cur);
    }
    return 0;
}


Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,st=1,id,len,res[N],ans[N],dis[N],en=1,tot,head[N],nex[N<<1],to[N<<1];
bool vis[N],path[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs1(int u,int p)
{
    dis[u]=dis[p]+1;
    if(dis[u]>dis[st]) st=u;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs1(v,u);
    }
}
void dfs2(int u,int p)
{
    dis[u]=dis[p]+1;
    if(dis[u]>dis[en]) en=u;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs2(v,u);
    }
}
void dfs3(int u,int p)
{
    vis[u]=true;
    if(u==en)
    {
        for(int i=1;i<=n;i++)
            path[i]=vis[i];
    }
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs3(v,u);
    }
    vis[u]=false;
}
void dfs4(int u,int p)
{
    int s=++id;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        if(!path[v])
            ans[++len]=++id;
    }
    ans[++len]=s;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        if(path[v])
            dfs4(v,u);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs1(st,0);
    dfs2(st,0);
    dfs3(st,0);
    dfs4(st,0);
    if(len!=n){printf("-1\n");return 0;}
    for(int i=1;i<=n;i++)
        res[i]=ans[i];
    len=id=0;
    dfs4(en,0);
    bool flag;
    for(int i=1;i<=n;i++)
        if(res[i]!=ans[i])
        flag=res[i]<ans[i];
    if(flag)
        for(int i=1;i<=n;i++)
        printf(i==n?"%d\n":"%d ",res[i]);
    else for(int i=1;i<=n;i++)
        printf(i==n?"%d\n":"%d ",ans[i]);
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

void dfs(int n, string s, char mx){
    if(s.size() == n){
        cout << s << endl;
        return;
    }
    for(char ch = 'a'; ch <= mx+1; ++ch){
        dfs(n,s+ch,max(mx,ch));
    }
}

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

    dfs(n,"",'a'-1);
    
    return 0;
}


Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int n=s.size();
  if(s[0]==s[s.size()-1]) pr(n%2?"Second":"First");
  else pr(n%2?"First":"Second");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 512
import Control.Monad

main = do
    n <- readLn :: IO Int
    let primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    let factors = do
        p <- primes
        let hoge = do 
            ni <- [2..n]
            return $ getFactNum p ni
        return $ sum hoge
        -- sum map getFactNum p [2..n]  
    --print $ factors
    -- 2_4_4
    let a = length $ filter (\x -> x >= 2 && x < 4) factors 
    let b = length $ filter (\x -> x >= 4) factors 
    -- 4_14
    let c = length $ filter (\x -> x >= 4 && x < 14) factors 
    let d = length $ filter (\x -> x >= 14) factors 
    -- 2_24
    let e = length $ filter (\x -> x >= 2 && x < 24) factors 
    let f = length $ filter (\x -> x >= 24) factors 
    -- 74
    let g = length $ filter (\x -> x >= 74) factors 
    print $ a*b*(b-1) `div` 2 + b*(b-1)*(b-2) `div` 2 +  c*d + d*(d-1) + e*f + f*(f-1) + g


getFactNum :: Int -> Int -> Int
getFactNum p ni 
    | amari == 0 =  getFactNum p (ni `div` p) + 1
    | otherwise = 0
    where amari = ni `mod` p

Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> class UnionFind {
  vector<int> par, rank;
  vector<T> diffWeight;
public:
  UnionFind(int n, T SUM_UNITY = 0) {
    par = vector<int>(n, -1);
    rank = vector<int>(n);
    diffWeight = vector<T>(n, SUM_UNITY);
  }
  int root(int x) {
    if (par[x] < 0)
      return x;
    int r = root(par[x]);
    diffWeight[x] += diffWeight[par[x]];
    return par[x] = r;
  }
  int size(int x) {
    return -par[root(x)];
  }
  T weight(int x) {
    root(x);
    return diffWeight[x];
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y, T w = 0) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if(x == y) {
      return false;
    }
    if(rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if(rank[x] == rank[y])
      rank[x]++;
    par[x] += par[y];
    par[y] = x;
    diffWeight[y] = w;
    return true;
  }
  T diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  if(M) {
    vector<int> L(M), R(M), D(M);
    rep(i, M) {
      cin >> L[i] >> R[i] >> D[i];
      L[i]--; R[i]--;
    }
    UnionFind<int> uf(N);
    rep(i, M) {
      if(!uf.unite(L[i], R[i], D[i]) && uf.diff(L[i], R[i]) != D[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3712
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n  =readint()
a = readints()

b = 0
for i in range(n):
    b^=a[i]
ans = [b^a[i] for i in range(n)]

printline(ans)



Measured memory_bytes: 129612
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int reverse = reverse(N);
        if(N == reverse){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    private static int reverse(int s){
        int length = String.valueOf(s).length();
        char[] ch = new char[length];
        for(int i = 0; i < length; i++){
            ch[i] = String.valueOf(s).charAt(i);
        }
        if(length % 2 == 0){
            for(int i = 0; i < length/2; i++){
                char change = ch[i];
                ch[i] = ch[length -1 - i];
                ch[length - 1 - i] = change;
            }
        }else{
            for(int i = 0; i < length/2; i++){
                char change = ch[i];
                ch[i] = ch[length -1 - i];
                ch[length - 1 - i] = change;
            }
        }
        String string = "";
        for(int i = 0; i < length; i++){
            string = string + String.valueOf(ch[i]);
        }
        //System.out.println(string);
        int str = Integer.parseInt(string);
        return str;
    }
}

Measured memory_bytes: 21844
S = input()
T = input()

adic = {}
bdic = {}

for i in range(len(S)):
  if adic.get(S[i], T[i]) != T[i] or bdic.get(T[i], S[i]) != S[i]:
    print("No")
    exit()
  adic[S[i]] = T[i]
  bdic[T[i]] = S[i]

print("Yes")

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

int main() {
  int K;
  string S;
  
  cin >> K;
  cin >> S;
  int k_size = S.length();
  string ans = "";
  
  if(K >= k_size) {
  	cout << S << endl;
  }else {
  	for(int i = 0 ; i < K ; i++) {
      ans += S[i];
    }
    ans += "...";
    cout << ans << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     int N;
      cin >> N;
      for (int i = 0; i < N; i++){
        string P;
        cin >> P;
        if (P == "Y"){
          cout << "Four" << endl;
          break;
        }
        else if (i == N-1 && P != "Y"){
          cout << "Three" << endl;
          break;
        }
        else continue;
      }
    }

Measured memory_bytes: 3536
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
		int n = Integer.parseInt(first[0]);
		int m = Integer.parseInt(first[1]);
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
			String[] line = br.readLine().split(" ", 3);
			uft.union(Integer.parseInt(line[0]) - 1, Integer.parseInt(line[1]) - 1);
		}
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set.add(uft.find(i));
		}
		System.out.println(set.size());
	}
	
	static class UnionFindTree {
		int[] parents;
		
		public UnionFindTree(int size) {
			parents = new int[size];
			for (int i = 0; i < size; i++) {
				parents[i] = i;
			}
		}
		
		public int find(int x) {
			if (parents[x] == x) {
				return x;
			}
			int y = find(parents[x]);
			parents[x] = y;
			return y;
		}
		
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		
		public void union(int x, int y) {
			if (same(x, y)) {
				return;
			}
			parents[find(x)] = find(y);
		}
	}
}


Measured memory_bytes: 49468
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int dp[100001][3];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int> > ABC(N, vector<int>(3));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> ABC[i][j];
        }
    }
    for (int i = 0; i < 3; ++i) {
        dp[0][i] = ABC[0][i];
    }
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            int before = 0;
            for (int k = 0; k < 3; ++k) {
                if (j == k) {
                    continue;
                }
                before = max(before, dp[i-1][k]);
            }
            dp[i][j] = before+ABC[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        ans = max(ans, dp[N-1][i]);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  int j = 1;
  for(int i = 0;i < n;i++){
    cin>>a.at(i);
  }
  for(int i = 0;i < n;i++){
    if(a.at(j - 1) == 2){
      cout<<i + 1<<endl;
      return 0;
    }
    j = a.at(j - 1);
  }
  cout<<-1<<endl;
  }

Measured memory_bytes: 3152