akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
const int NUM =100000;
//const int NUM_s=50000;

bool Search(int key,int *S,int n){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(right+left)/2;
    if(S[mid]==key){
      return true;
    }
    if(S[mid]<key){
      left=mid+1;
    }
    else right=mid;
  }

  return false;
}

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

  int sn;
  int tn;
  int count=0;
  int S[NUM];
  int tmp;
  //int T[NUM_s];


  cin>>sn;
  for(int i=0;i<sn;i++){
    cin>>S[i];
  }

  cin>>tn;
  for(int i=0;i<tn;i++){
    cin>>tmp;
    if(Search(tmp,S,sn)){
      count++;
    }
  }

  cout<<count<<endl;

  return 0;
}



Measured memory_bytes: 3508
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
struct Rect {
  int w, h;
};

bool operator < ( const Rect &r1, const Rect &r2 ) {
  int r1cl = r1.h * r1.h + r1.w * r1.w;
  int r2cl = r2.h * r2.h + r2.w * r2.w;
  if( r1cl == r2cl ) {
    return r1.h < r2.h;
  } else {
    return r1cl < r2cl;
  }
}

int main() {
  vector<Rect> vr;
  
  for( int w = 2; w <= 150; w++ ) {
    for( int h = 1; h < w; h++ ) {
      Rect r;
      r.w = w;
      r.h = h;
      vr.push_back( r );
    }
  }
  
  sort( vr.begin(), vr.end() );
  int iw, ih;
  int len = vr.size();
  while( 1 ) {
    cin >> ih >> iw;
    if( !iw && !ih ) { break; }
    for( int i = 0; i < len; i++ ) {
      if( vr[ i ].w == iw && vr[ i ].h == ih ) {
        cout << vr[ i + 1 ].h << " " << vr[ i + 1 ].w << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1348
(defparameter *n* (read))
(defparameter *m* (read))

(defun f (m)
  (labels ((f1 (m div lst)
             (let ((x (/ m div)))
               (cond ((= x 1) (cons div lst))
                     ((integerp x) (f1 x div (cons div lst)))
                     ((< m (* div div)) (cons m lst))
                     ((oddp div) (f1 m (+ div 2) lst))
                     (t (f1 m (1+ div) lst))))))
    (f1 m 2 nil)))

(defun combination (n r)
  (if (or (zerop r) (zerop n))
      1
      (* (/ n r)
         (combination (1- n) (1- r)))))

(defun g (lst)
  (mapcar (lambda (n) (count n lst)) (remove-duplicates lst)))

(defun h (n lst)
  (apply #'* (mapcar (lambda (x)
                       (combination (+ x (1- n)) x))
                     lst)))

(defun i (n m)
  (if (= m 1)
      1
      (rem (h n (g (f m))) (+ 1000000000 7)) ))

(princ (i *n* *m*))

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

#define Pair make_pair
#define Push push_back
typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli a, b, c;
	cin >> a >> b >> c;
	
	for (int i = 0; i < 10; ++i) {
		c = a*c - b;
		cout << c << '\n';
	}
	
	return;
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
           while(true)
            {
                string[] sss = Console.ReadLine().Split();
                int a = int.Parse(sss[0]); int b = int.Parse(sss[1]); int c = int.Parse(sss[2]);int d = a + b;
                if (a == -1 && b == -1 && c == -1)
                    break;
                else if (d > 79)
                    Console.WriteLine("A");
                else if (a + b <= 79 && a + b > 64)
                    Console.WriteLine("B");
                else if (a + b > 49 && a + b <= 64)
                    Console.WriteLine("C");
                else if (a + b > 29 && a + b < 49 && c > 49)
                    Console.WriteLine("C");
                else if (a + b > 29 && a + b < 49 && c <= 49)
                    Console.WriteLine("D");
                else
                    Console.WriteLine("F");
            }
        }
    }
}

    

Measured memory_bytes: 8952
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int MOD = 1000000007;
const ll INF = 1e18;

int main() {
    int a, b;
    cin >> a >> b;
    int t = a + b;
    if (t & 1) cout << "IMPOSSIBLE" << endl;
    else cout << t / 2 << endl;

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> h(H), w(W);
    set<P> st;
    rep(i, M) {
        int hh, ww;
        cin >> hh >> ww;
        hh--; ww--;
        h[hh]++; w[ww]++;
        st.insert({hh, ww});
    }

    int ih = 0, iw = 0;
    vector<int> maxh, maxw;
    repd(i, 1, H) {
        if (h[i] > h[ih]) {
            ih = i;
        }
    }
    // cout << ih << endl;
    rep(i, H) {
        if (h[ih] == h[i]) maxh.push_back(i);
    }
    repd(i, 1, W) {
        if (w[i] > w[iw]) {
            iw = i;
        }
    }
    rep(i, W) {
        if (w[iw] == w[i]) maxw.push_back(i);
    }

    int ans = w[maxw[0]] + h[maxh[0]];
    rep(i, maxh.size()) {
        rep(j, maxw.size()) {
            if (st.count({maxh[i], maxw[j]}) == 0){
                cout << ans << endl;
                return 0;
            }
        }
    }
    
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 23804
#include <iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    bool flag = (a % 3 == 0) || (b % 3 == 0) ||
    ((a + b) % 3 == 0);
    std::cout << (flag ? "Possible" : "Impossible") << std::endl;
    return 0;
}


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

template<typename T>
struct WeightedUnionFind {
    vector<int> data;
    vector<T> ws;
    WeightedUnionFind(int sz) : data(sz, -1), ws(sz) { }
    bool merge(int x, int y, T w) {             // ws(y) = ws(x) + w
        w += weight(x); w -= weight(y);
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y), w = -w;
        data[x] += data[y]; data[y] = x; ws[y] = w;
        return true;
    }
    bool find(int x, int y) { return root(x) == root(y); }
    T diff(int x, int y) { return weight(y) - weight(x); }
    T weight(int t) { root(t); return ws[t]; }
    int root(int k) {
        if (data[k] < 0) return k;
        int par = root(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }
};

int main() {
    int N, M;
    while (cin >> N >> M, N) {
        WeightedUnionFind<int> wuf(N);
        while (M--) {
            char c; cin >> c;
            if (c == '!') {
                int a, b, w; cin >> a >> b >> w; a--, b--;
                wuf.merge(a, b, w);
            } else {
                int a, b; cin >> a >> b; a--, b--;
                if (!wuf.find(a, b)) puts("UNKNOWN");
                else cout << wuf.diff(a, b) << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	long long int a[200001],b[200002],z=0;
	b[0]=0;
	cin>>n;
	for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i+1]=(b[i]+a[i])%(1000000007);
    }
    for(int i=1;i<n;i++)
    {
        z=(z+b[i]*a[i])%(1000000007);
    }
    cout<<z<<endl;
	return 0;
}


Measured memory_bytes: 6692
#include <iostream>

using namespace std;

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

int main() {
	int v[9];
	int sum;

	while (1) {
		cin >> sum;
		if (sum == 0) break;
		REP(i,9) cin >> v[i];

		REP(i,9) sum -= v[i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;
using pii=pair<int,int>;

int main(void){
	int n, m;
	while(cin>>n>>m,n) {
		vector<pii> pd(n);
		long long res = 0;
		rep(i,n) {
			cin >> pd[i].second >> pd[i].first;
			res += pd[i].first * pd[i].second;
		}
		sort(pd.begin(), pd.end(), greater<pair<int,int>>());
//		reverse(pd.begin(), pd.end());
		for(int i = 0; i < n && m > 0; i++) {
			res -= min(pd[i].second, m) * pd[i].first;
			m -= pd[i].second;
		}
		cout << res << endl;
	}
        
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,dp[5050][5050][2],a[5050],sz[5050],r[5050][2];;
vector<ll>g[5050];
void dfs(int v,int p){
    sz[v]=1;
    dp[v][0][0]=a[v];
    if(a[v]>0)dp[v][0][1]=a[v];
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u==p)continue;
        dfs(u,v);
        for(int j=0;j<=sz[u]+sz[v];j++)r[j][0]=INF,r[j][1]=INF;
        for(int j=0;j<sz[v];j++){
            for(int k=0;k<sz[u];k++){
                if(dp[u][k][0]<0||dp[u][k][1]!=INF){
                    r[j+k+1][0]=min(r[j+k+1][0],dp[v][j][0]);
                    r[j+k+1][1]=min(r[j+k+1][1],dp[v][j][1]);
                }  
                r[j+k][0]=min(r[j+k][0],dp[v][j][0]+min(dp[u][k][0],dp[u][k][1]));
                r[j+k][1]=min(r[j+k][1],dp[v][j][1]+dp[u][k][1]);
            }
        }
        sz[v]+=sz[u];
        for(int j=0;j<sz[v];j++)dp[v][j][0]=r[j][0],dp[v][j][1]=r[j][1];
    }
}
int main(void){
    scanf("%lld",&n);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[i][j][0]=INF,dp[i][j][1]=INF;
    for(int i=0;i<n;i++)scanf("%lld",a+i);
    for(int i=0;i<n-1;i++){
        ll x,y;
        scanf("%lld%lld",&x,&y);
        g[--x].PB(--y);
        g[y].PB(x);
    }
    dfs(0,-1);
    for(int i=0;i<n;i++){
        if(dp[0][i][0]<0||dp[0][i][1]!=INF){
            printf("%d\n",i);
            return 0;
        }
    }
}


Measured memory_bytes: 396288
from collections import defaultdict
from collections import Counter

N,M,K = map(int,input().split())

fn = defaultdict(lambda: 1)
CD = [0]*K

par = list(range(N))

def root(x):
    S = set()
    S.add(x)
    y = x
    while True:
        if par[y] == y:
            for s in S:
                par[s] = y
            return y
        S.add(y)
        y = par[y]

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")

Measured memory_bytes: 96984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N,K;
    cin >> N >> K;
    ll ans = 1;
    for (int i = 0; i < N; i++){
        ans = ans*2 <= ans + K ? ans*2 : ans+K; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    private static void chmin<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == 1 ? val : num;
    private static void chmax<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == -1 ? val : num;
    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        //WriteLine(Solve());
    }
    static void Solve()
    {

        var str = ReadLine();
        var res = new int[str.Length];
        var last = 1;
        for(var i=0;i<str.Length-1;i++)
            if(str[i]=='R'&&str[i+1]=='L')
            {
                res[i] += (last+1)/2;
                res[i+1] += last/2;
            }
            else { if (str[i] == 'L') last = 1; else last++; }
        last = 1;
        for (var i = str.Length-1; i >0; i--)
            if (str[i-1] == 'R' && str[i] == 'L')
            {
                res[i] += (last+1)/2;
                res[i - 1] += last/2;
            }
            else { if (str[i] == 'R') last = 1; else last++;  }

        WriteLine(string.Join(" ", res));
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
int A,B;
cin >> A >> B;

if(A%3==0){
cout << "Possible" << endl;
}
else if(B%3==0){
cout << "Possible" << endl;
}
else if((A+B)%3==0){
cout << "Possible" << endl;
}
else{
cout << "Impossible" << endl;
}

return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<int,int> A;
    map<int,int> B;
   
    REP(i,n){
        int a;
        cin >> a;
        if(i%2==0) {
            A[a]++;
        }
        if(i%2==1) {
            B[a]++;
        }
    }
    int a1num=-1,a1val=0;
    int a2num=-1,a2val=0;
    int b1num=-1,b1val=0;
    int b2num=-1,b2val=0;
    for(auto itr= A.begin(); itr!=A.end(); itr++){
        int x= itr->first;
        int y= itr->second;
        if(a1val<y){
            a2num= a1num;
            a2val= a1val;
            a1num= x;
            a1val= y;
        }else if(a2val<y){
            a2num= x;
            a2val= y;
        }
        // if(i!=6) cout << " ";
    }
    for(auto itr= B.begin(); itr!=B.end(); itr++){
        int x= itr->first;
        int y= itr->second;
        if(b1val<y){
            b2num= b1num;
            b2val= b1val;
            b1num= x;
            b1val= y;
        }else if(b2val<y){
            b2num= x;
            b2val= y;
        }
        // if(i!=6) cout << " ";
    }
    int p,q;
    if(a1num!=b1num) {
        p= a1val;
        q= b1val;
    } else if(a2val>=b2val){
        p= a2val;
        q= b1val;
    } else if(a2val<b2val){
        p= a1val;
        q= b2val;
    }
    // cout << a1val << " " << a2val<< endl;
    // cout << b1val << " " << b2val << endl;

    cout << n-(p+q) << endl;
}

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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (string& i : S) cin >> i;
	sort(S.begin(), S.end());
	for (string& i : S) cout << i;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a, b;
int dp[3010][3010];
int n, m;
deque<char> ans;

void solve() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i] == b[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]);
		}
	}
	int x = n - 1, y = m - 1;
	while (x >= 0 && y >= 0) {
		if (a[x] == b[y]) ans.push_front(a[x]), x--, y--;
		else if (dp[x][y + 1] > dp[x + 1][y]) x--;
		else y--;
	}
	for(auto ch : ans) printf("%c", ch);
}

int main() {
	cin >> a >> b;
	n = a.size(), m = b.size();
	solve();
	return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
vector<string >ve;
int main(){
	string a;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		sort(a.begin(),a.end());
		ve.push_back(a);
	}
	sort(ve.begin(),ve.end());
	long long sum=0;
	long long ans=0;
 	for(int i=0;i<ve.size()-1;i++)
 	{
	 	if(ve[i]==ve[i+1])
 			ans++;
 		
 		else {
 			sum+=ans*(ans+1)/2;
 			ans=0;
		 }
	}
	sum+=ans*(ans+1)/2;
	cout<<sum<<endl;
	return 0;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


int main(){
	string s; cin>> s;
	string a="", b ="",c="";
	rep(i,0,3)
		a+= conv(s[i]);
	rep(i,5,6)
		b+= conv(s[i]);
	rep(i,8,9)
		c+= conv(s[i]);
	int y = conv(a), m = conv(b), d= conv(c);
	if(y > 2019 || m > 4|| d > 30)
		cout<<"TBD";
	else
		cout<<"Heisei";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        WriteLine(string.Join(" ", Enumerable.Range(1, 55555).Where(IsPrime).Where(x => x % 5 == 1).Take(int.Parse(ReadLine()))));
    }

    static bool IsPrime(int n)
    {
        if (n < 2) return false;
        var r = (int)Math.Sqrt(n);
        for (int i = 2; i <= r; i++) if (n % i == 0) return false;
        return true;
    }
}

Measured memory_bytes: 11348
#include <iostream>

using namespace std;

const int MAX = 100000;
int w[MAX];
int n, k;

int check(int P) {
    int i = 0;
    for (int j = 0; j < k; ++j) {
        long long s = 0;
        while (s + w[i] <= P) {
            s += w[i];
            ++i;
            if (i >= n) return n;
        }
    }
    return i;
}

long long solve() {
    long long l = 0;
    long long r = 100000 * 10000;
    while (r - l > 1) {
        long long m = (r + l) / 2; 
        int v = check(m);
        if (v >= n) r = m;
        else l = m;
    }
    return r;
}

int
main(int argc, const char *argv[])
{
    cin >> n >> k;
    for (int i = 0; i != n; ++i) cin >> w[i];
    long long ans = solve();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int w,a,b;
  cin >> w >> a >> b;
  if(a+w<b){
    cout << b-(a+w) << endl;
  }else if(b+w<a){
    cout << a-(b+w) << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := NewScanner()
	n, k := scanner.NextInt(), scanner.NextInt64()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = scanner.NextInt() - 1
	}
	steps := make([]int, n)
	pos, num := 0, 1
	for ; steps[pos] == 0; pos = as[pos] {
		steps[pos] = num
		num++
	}

	p, q := steps[pos]-1, num-steps[pos]
	if k > int64(p) {
		res := (k - int64(p)) % int64(q)
		ans := 0
		for i := 0; i < int(res)+p; i++ {
			ans = as[ans]
		}
		fmt.Println(ans + 1)
	} else {
		ans := 0
		for i := 0; int64(i) < k; i++ {
			ans = as[ans]
		}
		fmt.Println(ans + 1)
	}
}

type Scanner struct {
	scanner *bufio.Scanner
}

func NewScanner() *Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &Scanner{s}
}

func (s *Scanner) NextWord() string {
	if !s.scanner.Scan() {
		log.Fatal("failed to find the next word")
	}
	return s.scanner.Text()
}

func (s *Scanner) NextInt() int {
	str := s.NextWord()
	i, err := strconv.Atoi(str)
	if err != nil {
		log.Fatalf("failed to parse %s to int", str)
	}
	return i
}

func (s *Scanner) NextInt64() int64 {
	str := s.NextWord()
	i, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		log.Fatalf("failed to parse %s to int64", str)
	}
	return i
}


Measured memory_bytes: 6532
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b) = in.readLine().split("\\s+").map(_.toInt)
    val s = in.readLine()

    out.println(
      if (s.length == a + b + 1 && s(a) == '-' && s.filter(c => c >= '0' && c <= '9').length == a + b) {
        "Yes"
      } else {
        "No"
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 27308
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;i++)cin>>l[i];
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<n-1;i++)
    for(int j=i+1;j<n;j++)
       ans+=max(0,(int)(lower_bound(l.begin()+j+1,l.end(),l[i]+l[j])-l.begin()-j)-1);
  cout<<ans<<endl;
}


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

int l,n,m;

int main()
{
//	freopen("biao.in","r",stdin);
//	freopen("c.in","w",stdout);
	scanf("%d",&l); 
	--l;
	for (n=1;(1<<(n))-1<=l;++n);
	
	m=2*n-2;
	
	if ((1<<(n-1))-1!=l)
	for (int i=0;i<=20;++i)
		if (l>>i&1)
			++m;
			
	cout<<n<<" "<<m<<endl; 
	for (int i=1;i<n;++i)
	{
		cout<<i<<" "<<i+1<<" "<<0<<endl;
		cout<<i<<" "<<i+1<<" "<<(1<<(i-1))<<endl;
	}
	
//	cout<<(1<<(n-1))-1<<" "<<l<<endl;
	if ((1<<(n-1))-1!=l)
	{
		int w=0;
		for (int i=20;~i;--i)
			if (l>>i&1)
			{
				if (w)
					cout<<i+1<<" "<<n<<" "<<w<<endl;
				w+=(1<<i);
			}
		cout<<1<<" "<<n<<" "<<w<<endl;
	}
	return 0;
} 

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

int main() {
  int N;
  cin>>N;
  int n=N%10;
  if(n==3) cout<<"bon"<<endl;
  else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}
  

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char const *argv[]) {
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  double dis,a,x3,y3,x4,y4;
  dis=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  if(x1!=x2){
    a=(y1-y2)/(x1-x2);
    if(a!=0){
      if(y1<=y2){
        x4=x1-dis*sqrt(pow(a,2)/(pow(a,2)+1));
        y4=(x1-x4)/a+y1;
        x3=x2+(x4-x1);
        y3=y2+(y4-y1);
      }else{
        x4=x1+dis*sqrt(pow(a,2)/(pow(a,2)+1));
        y4=(x1-x4)/a+y1;
        x3=x2+(x4-x1);
        y3=y2+(y4-y1);
      }
    }else{
      x3=x2;
      x4=x1;
      if(x1<x2){
        y3=y2+dis;
        y4=y3;
      }else{
        y3=y2-dis;
        y4=y3;
      }
    }
  }else{
    y3=y2;
    y4=y1;
    if(y1<y2){
      x3=x2-dis;
      x4=x1-dis;
    }else{
      x3=x2+dis;
      x4=x1+dis;
    }
  }
  printf("%.0f %.0f %.0f %.0f\n",x3,y3,x4,y4);
  return 0;
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define inf 4e18
#define MOD 1000000007
#define pi 3.141592653589
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	double a,b,h,m;
	const double rad=(pi/180);
	cin>>a>>b>>h>>m;
	double degMin=6*m;
	double degHr=30*h+m*(0.5);
	double diff=abs(degMin-degHr);
	diff=min(diff,360-diff);
	if (diff==90) cout<<sqrt(a*a+b*b)<<endl;
	else if (diff==0) cout<<(sqrt(a*a+b*b-2*a*b))<<endl;
	else{
		diff=diff*rad;
		double c=sqrt(a*a+b*b-2*a*b*cos(diff));
		cout<<fixed<<setprecision(10)<<c<<endl;
	}
}

Measured memory_bytes: 4180
#include<stdio.h>
#include<stdlib.h>
#define NMAX 100000
struct node {
  int id;
  int weight;
  struct node *next;
};
struct node **list;
long long int *dist;
void Insert(int, int, int);
void Dfs(int);
int main(void)
{
  int i, n, q, k;
  scanf("%d", &n);
  list = (struct node**)malloc(sizeof(struct node*) * n);
  for (i = 0; i < n; i++) {
    list[i] = NULL;
  }
  dist = (long long int*)malloc(sizeof(long long int) * n);
  for (i = 0; i < n - 1; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    Insert(a - 1, b - 1, c);
    dist[i] = -1;
  }
  dist[i] = -1;
  scanf("%d %d", &q, &k);
  dist[k-1] = 0;
  Dfs(k - 1);
  for (i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%lld\n", dist[x-1] + dist[y-1]);
  }
  for (i = 0; i < n; i++) {
    struct node *p, *q;
    if (list[i] != NULL) {
      for (q = list[i], p = q->next; p != NULL; q = p, p = p->next) {
        q->next = p->next;
        free(p);
      }
      free(list[i]);
    }
  }
  free(list);
  free(dist);
}
void Insert(int a, int b, int weight)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->weight = weight;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->weight = weight;
  p->next = list[b];
  list[b] = p;
}

void Dfs(int v)
{
  struct node *n;
  for (n = list[v]; n != NULL; n = n->next) {
    if (dist[n->id] != -1) continue;
    dist[n->id] = dist[v] + n->weight;
    Dfs(n->id);
  }
}

Measured memory_bytes: 12672
#include <vector>
#include <math.h>
#include <iostream>

using namespace std;

int paths[1001][1001];
bool grid[1001][1001];

#define MOD ((int)(1000000000 + 7))

int main(){

  int H, W;
  cin >> H >> W;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      paths[i][j] = 0;
    }
  }
  paths[0][0] = 1;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char val;
      cin >> val;
      if(val == '.') grid[i][j] = false;
      else grid[i][j] = true;
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(!grid[i][j]){
	if(j-1 >= 0 && !grid[i][j-1]) paths[i][j] += (paths[i][j-1]) % MOD;
	if(i-1 >= 0 && !grid[i-1][j]) paths[i][j] += (paths[i-1][j]) % MOD;
	//cout << i << " " << j << " " << paths[i][j] << endl;
      }
    }
  }

  cout << paths[H-1][W-1] % MOD << "\n";
  
  return 0;
}


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

int main() {
  	int a,b;
	cin >> a >> b;
  	if (b<10) a=a*10+b;
  	else if (b<100) a=a*100+b;
  	else a=a*1000+b;
  	if (floor(sqrt(a))*floor(sqrt(a))==a )cout << "Yes" <<endl;
  	else cout << "No" <<endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
		String str[] = br.readLine().split(" ");
 
		int d = Integer.parseInt(str[0]);
		int g = Integer.parseInt(str[1]);
 
		int p[] = new int[d];
		int c[] = new int[d];
 
		for (int i = 0; i < d; i++) {
			str = br.readLine().split(" ");
 
			p[i] = Integer.parseInt(str[0]);
			c[i] = Integer.parseInt(str[1]);
		}
 
		int ans = Integer.MAX_VALUE;
		for (int bit = 0; bit < (1 << d); bit++) {
			int problem = 0;
			int point = 0;
 
			for (int i = 0; i < d; i++) {
				if ((bit & (1 << i)) != 0) {
					problem += p[i];
					point += (1 + i) * 100 * p[i] + c[i];
				}
			}
			if (point >= g) {
				ans = Math.min(ans, problem);
				continue;
			}
			for (int i = 0; i < d; i++) {
				if ((bit & (1 << i)) != 0)
					continue;
				if ((g - point) / ((i + 1) * 100) <= p[i]) {
					problem += (g - point) / ((i + 1) * 100);
					ans = Math.min(ans, problem);
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main()
{
    int a;
    cin >> a;
    int b;
    cin >> b;
    if(a+b==3){
        cout << 3 << endl;
    }else if(a+b==4){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

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

bool pos(string& S, ll start, ll goal)
{
  ll N = S.size();
  ll cnt = 0;
  for (ll i = start + 1; i < goal; ++i) {
    if (S[i] == '#') {
      cnt += 1;
      if (cnt == 2) {
        return false;
      }
    }
    else {
      cnt = 0;
    }
  }
  return true;
}

int main()
{
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A -= 1;
  B -= 1;
  C -= 1;
  D -= 1;
  string S;
  cin >> S;
  bool need_check = false;
  if (D < C) {
    need_check = true;
  }

  if (!need_check) {
    if (pos(S, A, C) && pos(S, B, D)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    bool ok = false;
    ll cnt = 0;
    for (ll i = B - 1; i <= D + 1; ++i) {
      if (S[i] == '.') {
        cnt += 1;
        if (cnt >= 3) {
          ok = true;
          break;
        }
      }
      else {
        cnt = 0;
      }
    }
    if (pos(S, A, C) && pos(S, B, D) && ok) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

}

// 15 1 3 15 13
// ...#.#.#.#.#...


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;
int x[4000][4000], n;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		cin >> n;
		if (!n) { break; }
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> x[i][j]; x[i][n] += x[i][j]; x[n][j] += x[i][j]; x[n][n] += x[i][j];
			}
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				if (x[i][j] < 10) { cout << " " ; }
				if (x[i][j] < 100) { cout << " " ; }
				if (x[i][j] < 1000) { cout << " " ; }
				if (x[i][j] < 10000) { cout << " " ; }
				cout << x[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 63668
#入力部
n,m,x = map(int,input().split())
a = []
c = []
for s in range(n):
	c_tmp,*a_tmp = list(map(int,input().split()))
	c.append(c_tmp)
	a.append(a_tmp)
#ビット全探索処理
c_ans = []
for i in range(2**n):
	ans_box = [0]*m
	c_box = 0
	for j in range(n):
		if(i>>j)&1 == 1:
			for p in range(m):
				ans_box[p] += a[j][p]
			c_box += c[j]
	if min(ans_box) >= x:
		c_ans.append(c_box)
#出力部
print(min(c_ans) if len(c_ans)>0 else -1)

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

int main()
{
    long long n;
    std::cin >> n;
    std::string ans;
    char add;
    while (n > 0) {
        add = 'a' + static_cast<char>(n % 26) - 1;
        if (add < 'a') {
            add += -'a' + 'z' + 1;
            n -= 26;
        }
        ans += add;
        n -= n % 26;
        n /= 26;
    }
    for (int i = 0; i < ans.size(); i++) {
        std::cout << ans.at(ans.size() - i - 1);
    }
    std::cout << "\n";
    return 0;
}


Measured memory_bytes: 3128
from math import ceil
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for _ in [0]*d]
m=1000

for i in range(2**d):
    cnt=0
    s=g
    for j in range(d):
        k=(i&(2**j))>>j
        if k==1:
            s-=pc[j][0]*(j+1)*100+pc[j][1]
            cnt+=pc[j][0]
    if s<=0:
        m=min(m,cnt)
    else:
        for j in range(d-1,-1,-1):
            k=(i&(2**j))>>j
            if k==0:
                if pc[j][0]*(j+1)*100 >= s:
                    cnt+=ceil(s/((j+1)*100))
                    break
                else:
                    s-=pc[j][0]*100*(j+1)
                    cnt+=pc[j][1]
        m=min(m,cnt)
print(m)

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

int main(){
  int a, b ,c;
  cin >> a >> b >> c;
  if((a+b ==c) || (a+c==b) || (b+c==a)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

int N, A, B;

int calcSumOfDigits(int n)
{
    int sum_of_digits = 0;
    while (n > 0)
    {
        sum_of_digits += n % 10;
        n = n / 10;
    }
    return sum_of_digits;
}

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

    int res = 0;
    int sum_of_digits;
    for (int i = 1; i <= N; i++)
    {
        sum_of_digits = calcSumOfDigits(i);
        if (A <= sum_of_digits && sum_of_digits <= B)
        {
            res += i;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll a[n];
    arrinp(i, a, 0, n - 1);
    sort(a, a + n);
    ll sum = 0;
    sum += a[n - 1];
    int count = n - 2;
    int ind = n - 2;
    while(count > 0)
    {
        sum += a[ind];
        count--;
        if(count > 0)
        {
            sum += a[ind];
            ind--;
            count--;
        }
    }
    outline(sum)
    return 0;
}

Measured memory_bytes: 5212
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C);

// ===

fn main() {
    let s: String = read();
    let mut chars = vec![false; 256];
    for u in s.into_bytes() {
        chars[u as usize] = true;
    }
    if chars[b'a' as usize] && chars[b'b' as usize] && chars[b'c' as usize] {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
// AOJ ALDS1_3_A Stack
// 2018.4.27 bal4u
 
#include <stdio.h>
#include <ctype.h>
 
int stack[102]; int top;
char buf[2000];
 
int main()
{
    int  v1, v2;
    char *p;
 
    fgets(p=buf, 500, stdin);
    top = 0;
    while (*p >= ' ') {
        while (isspace(*p)) p++;
        if (isdigit(*p)) {
            v1 = 0;
            while (isdigit(*p)) v1 = 10*v1 + (*p++ & 0xf);
            stack[top++] = v1;
        } else {
            v1 = stack[--top];
            v2 = stack[--top];
            if      (*p == '+') v2 += v1;
            else if (*p == '-') v2 -= v1;
            else if (*p == '*') v2 *= v1;
            stack[top++] = v2;
            p++;
        }
    }
    printf("%d\n", stack[--top]);
    return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  int X, N;
  cin >> X >> N;

  int p[N];
  for (int i = 0; i < N; ++i)
    cin >> p[i];

  int ret = 0;
  int min_diff = 1000000;
  for (int i = -1; i < 100 + 2; ++i) {
    bool found = false;
    for (int j = 0; j < N; ++j)
      if (p[j] == i)
        found = true;
    if (found)
      continue;


    if (abs(X - i) < min_diff) {
      ret = i;
      min_diff = abs(X - i);
    }

  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    if (n < 10) ans += n;
    else if (n < 100) ans += 9;
    else if (n < 1000) ans += n - 90;
    else if (n < 10000) ans += 909;
    else if (n < 100000) ans += n - 9090;
    else ans += 90909;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    int n; cin >> n;
    int a = 0;
    vector<int> p(n);
    for (int i = 0;i < n;i++) cin >> p.at(i);
    for(int i = 0;i < n;i++){
        if(p.at(i) != i + 1) a++;
    }
    if(a <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    if(a==b){
        cout<<a*2<<endl;
        return 0;
    }

    cout<<max(a,b)*2-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < K; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int t; cin >> t; t--;
            A[t]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>

using namespace std;

int main(){
    char A,B;
    cin >> A >> B;

    if (A > B){
        puts(">");
    }else if(A == B){
        puts("=");
    }else{
        puts("<");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))

const int MOD = (int)1e9 + 7;

int N, K;
vector<int> A;

// dp[i][j] := i人目までにj個配る場合の数
// dp[i + 1][j] += Σ dp[i][(j - A[i]) .. j]
// 遷移を累積和で高速化 (遷移O(n) -> 構築O(n) & 遷移O(1))
ll dp[107][100100];

signed main() {

  cin >> N >> K;
  A.resize(N);
  REP(i, N) cin >> A[i];

  dp[0][0] = 1;

  REP(i, N) {
    vector<ll> acc(1, 0);
    REP(j, K + 1) acc.emplace_back(acc[j] + dp[i][j]);
    REP(j, K + 1) (dp[i + 1][j] += acc[j + 1] - acc[max<ll>(0, j - A[i])]) %= MOD;
  }

  cout << dp[N][K] << endl;

}


Measured memory_bytes: 81128
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long p = sc.nextLong();
		long ans = 1;
		
		if(n > 50){
			System.out.println(1);
		}else if(n == 1){
			System.out.println(p);
		}else if(n == 2){
			for(int i=2; i<=1000000; i++){
				long npi = 1;
				for(int j=0; j<n; j++){
					npi *= i;
				}
				if(npi == 0){
					break;
				}
				while(p % npi == 0 && npi > 0){
					ans *= i;
					p /= npi;
				}
			}
			
			System.out.println(ans);
		}else{
			for(int i=2; i<=10000; i++){
				long npi = 1;
				for(int j=0; j<n; j++){
					npi *= i;
				}
				if(npi == 0){
					break;
				}
				while(p % npi == 0 && npi > 0){
					ans *= i;
					p /= npi;
				}
			}
			
			System.out.println(ans);
		}
	}
	
	static long[][] factorization(long n){
		int order = 10;
		int scale = 0;
		while(order <= n){
			scale++;
			order *= 10;
		}
		
		long pre_result[][] = new long[scale+2][2];
		long n_cp = n;
		int point = 0;
		for(int i=2; i<=n_cp; i++){
			if(n_cp % i == 0){
				pre_result[point][0] = i;
				while(n_cp % i == 0){
					pre_result[point][1]++;
					n_cp /= i;
				}
				point++;
			}
			if(n_cp == 1){
				break;
			}
		}
		
		long result[][] = new long[point][2];
		for(int i=0; i<point; i++){
			result[i][0] = pre_result[i][0];
			result[i][1] = pre_result[i][1];
		}
		
		return result;
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool flag = true;
 for(int i = 0; i < A; i++) {
   if(S[i] >= '0' && S[i] <= '9') continue;
   else { flag = false; }
 }
 if(S[A] == '-') {

 } else if(S[A] != '-') {
   flag = false;
 }

 for(int i = A + 1; i < A + B + 1; i++) {
   if(S[i] >= '0' && S[i] <= '9') continue;
   else { flag = false; }
 }
 if(flag)
 cout << "Yes";
 else
 {
   cout << "No";
 }
  


  return 0;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,d;
  cin >> n >> d;

  int ans = n / (2 * d + 1);

  cout << kiriage(n,2*d+1);
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
from collections import deque

# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を INF で初期化
    d = [[float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    #queの定義
    que = deque([])
   
    for i in range(n):
        for j in range(m):
            # スタートとゴールの座標を探す
            if maze[i][j] == "#":
                sx = i
                sy = j
                que.append((sx, sy))
                d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    ans = 0
    for i in range(n):
        for j in range(m):
            ans = max(ans, d[i][j])
    
    return ans

n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]

print(bfs())


Measured memory_bytes: 161356
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for a in A:
    if a < 0:
        cnt += 1
if cnt % 2 == 0:
    print(sum(map(lambda a: abs(a), A)))
else:
    mina = min(map(lambda a: abs(a), A))
    print(sum(map(lambda a: abs(a), A))-2*mina)


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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;


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

   ll x=a*b;

    if(a<b){
        ll tmp=a;
        a=b;
        b=tmp;
    }

    ll r=a%b;

    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    ll ans = x/b;

    cout << ans << endl;
    
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   int ans[n + 1];
   memset(ans , 0 , sizeof(ans));
   for(int i = 1 ; i <= 100 ; i++)
      for(int j = 1 ; j <= 100 ; j++)
         for(int k = 1 ; k <= 100 ; k++)
            if(i * i + j * j + k * k + i * j + i * k + j * k <= n)
               ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
   for(int i = 1 ; i <= n ; i++)
      cout << ans[i] << "\n";
   return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#define MOD 1000000007;
int N, i, j;
char S[100001], c;
long long int dp[100001][4];
int main(){
	c=getchar(); while(c!=10){S[N++]=c; c=getchar();}

	dp[N][3]=1;
	for(i=N-1; i>=0; --i){
		for(j=3; j>=0; --j){
			dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
			if(j < 3 && (S[i] == '?' || S[i] == j+'A')){
				dp[i][j] += dp[i+1][j+1];
			}
			dp[i][j] %= MOD;
		}
	}
	printf("%lld\n", dp[0][0]);
}


Measured memory_bytes: 3328
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

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


//変数
int N;
vector<int> a;





//サブ関数
//入力
void input()
{
	cin >> N;
	a.resize(N);
	REP(i, N)cin >> a[i];
}


//計算
void calc()
{
	int res = 0;
	for (auto c : a)res += (c - 1);
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256