akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n), b(n);
  	vector<int> c(n-1);
  	rep(i, n){
      int t;
      cin >> t; t--;
      a[i] = t;
    }
    rep(i, n) cin >> b[i];
  	rep(i, n-1) cin >> c[i];

  
  	int ans = 0;
  	rep(i, n){
    	ans += b[a[i]];
      	if(a[i]+1 == a[i+1]) ans += c[a[i]];
    }
  

    cout << ans << endl;
}

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

int main() {
    string s; cin >> s;
    if (s[0] != 'A' || count(begin(s) + 2, end(s) - 1, 'C') != 1) {
        return !(cout << "WA" << endl);
    }
    s[0] = 'a', *find(begin(s) + 2, end(s) - 1, 'C') = 'c';
    bool ok = all_of(begin(s), end(s), [&](auto &c) { return islower(c); });
    cout << (ok ? "AC" : "WA") << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
using namespace std;

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

	int page = (N % 2 == 1) ? N / 2 + 1 : N / 2;
	cout << page << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int):
    ans = 1
    for i in range(N):
        if ans <= K:
            ans *= 2
        else:
            ans += K
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    ans = float('inf')
    for i in range(-100, 100+1):
        cnt = 0
        for a in A:
            cnt += (i-a) ** 2 
        ans = min(ans, cnt)
    
    print(ans)

if __name__ == '__main__':
    solve()

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



int main(){
	int a, b;
	cin >> a >> b;
	string ans = "";
	if(a < b){
		rep(i,b) ans += to_string(a);
	}else{
		rep(i,a) ans += to_string(b);
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    int N;
    cin >> N;
    vll A(N),B(N),C(N);
    cin >> A >> B >> C;
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    ll ans = 0;
    for(auto b:B){
        ll ab = lower_bound(A.begin(),A.end(),b) - A.begin();
        ll bc = N - (upper_bound(C.begin(),C.end(),b) - C.begin());
        ans += ab*bc;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5588
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    # print(U)
    for i in U:
        if k <= i[1]:
            print(i[0])
            break
        k -= i[1]
    else:
        print(U[-1][0])
        # if k <= 0:
        #     print(i[0])
        #     break
        # print(i, k)

c()

Measured memory_bytes: 18960
import java.awt.*;
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {
    int mod  = (int) 1e9+7;
    //int n = (int) 1e6+5;
    //long[][] memo = new long[n][27];
    void solve(int a) {
        int sum = 0;
        int v = 1;
        for(int i=0;i<3;i++){
            v*=a;
            sum+=v;
        }
        System.out.println(sum);
    }
    //0 1 2 3 4 5 6 7
    //1 7 3 4 7 6 2 9
    //1 7 4 3 7 6 2 9;
    //1 2 1 2 1
    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        //s = br.readLine().split(" ");
        //s = br.readLine().split(" ");
        test.solve(n);
    }
}


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

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

using namespace std;

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

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/numeric>
/**
    PROGRESS IS PROGRESS
    NO MATTER HOW SMALL
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define MOD 1000000007

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


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout) ;
    ll a, b, c, k; cin>>a>>b>>c>>k;
    ll sum = min(a, k);
     k-= min(a, k);
    k -= min(k, b);
    sum -= min(k, c);
    cout<<sum;
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
int par [100001];
int root [100001];

int find(int x)
{
	if(root [x] == x) return x;
	return root [x] = find(root [x]);
}

void unite(int x,int y)
{
	x = find(x); y = find(y);
	root [y] = x;
}

int main()
{
	while(scanf("%d%d",&N,&M) && N){
		FOR(i,2,N + 1){
			int u;
			scanf("%d",&u);
			par [i] = u;
		}
		par [1] = 1;
		vector< pair<int,int> > qy(M);
		deque<bool> d(N + 1);
		FOR(i,0,M){
			char str [20];
			int x;
			scanf("%s%d",str,&x);
			if(str [0] == 'M' && d [x]) continue;
			if(str [0] == 'M'){
				d [x] = true;
			}
			qy [i] = make_pair(x,str [0] == 'Q');
		}
		FOR(i,2,N + 1) if(d [i] == false){
			qy.push_back(make_pair(i,0));
		}
		reverse(qy.begin(),qy.end());
		ll ans = 0;
		for(int i = 1;i <= N;i++){
			root [i] = i;
		}
		FOR(i,0,qy.size()){
			if(qy [i].second == 0){
				unite(par [qy [i].first],qy [i].first);
			}
			else{
				ans += find(qy [i].first);
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 6124
N = input()
C = [input()-1 for _ in range(N)]

P = [-1]*(2*10**5)
T = [0]*N
M = 10**9+7
T[0] = 1
P[C[0]] = 0
for i in range(1,N):
  T[i] = T[i-1]
  p = P[C[i]]
  if p>=0 and i-p>=2:
    T[i] += T[p]
    T[i] %= M
  P[C[i]] = i
print T[-1]


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

pair<LL,LL> a[1000001];


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    LL k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort (a, a + n);
    int i = 0;
    while (k > 0) {
        if (k <= a[i].second) {
            break;
        }
        k-=a[i].second;
        i++;
    }
    cout << a[i].first << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF (1<<29)

#define DEBUG(x) cout << #x << ": " << x << endl;

int N, M, R; // 町数、道数、訪れる町数
int d[201][201]; // 町と町の距離
int r[9];//なにこれ
int A, B, C; // A町、B町、AB間の距離
int res;//なにこれ
bool used[9];

void dfs(int c, int las, int dist);

int main() {
    cin >> N >> M >> R; // 1段目の読み込み
    // 町の間の距離の初期化作業 -----------------------------------------------------------
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i != j) { // A町からA町のように、無意味なものは初期化しない
                d[i][j] = INF; // 町の間の距離をできるだけ大きな数値で初期化
            }
        }
    }
    // END -------------------------------------------------------------------------

    // どの町を訪れるか入力 --------------------------------------------------------------
    vector<int> road;
    for (int i = 1; i <= R; i++) {
        //cin >> r[i]; // 2段目の読み込み
        int x;
        cin >> x;
        road.push_back(x);
    }
    sort(road.begin(), road.end());
    // END ---------------------------------------------------------------------------

    for (int i = 1; i <= M; i++) {
        cin >> A >> B >> C; // 3段目以降の読み込み
        if (d[A][B] > C) { // CはA,B間の距離
            d[A][B] = d[B][A] = C; // より小さい距離を格納
                                   // d[A][B]とd[B][A]は同じ
        }
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                /*
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j]; // より小さいものを代入
                }
                */
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = INF;
    do {
        int dist = 0;
        for (int i = 0; i < (R - 1); i++) {
            dist += d[road[i]][road[i+1]];
        }
        ans = min(ans, dist);
    } while (next_permutation(road.begin(), road.end()));
    
    cout << ans << endl;

}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;

    bool f = true;
    if (C > D)
    {
        bool e = false;
        //! すれ違う必要あり
        FOR(i, D + 1, B)
        {
            if (S[i] == '.' && S[i + 1] == '.' && S[i - 1] == '.')
                e = true;
        }
        f = e;
    }
    //! AがCに行ける？
    FOR(i, C, A)
    {
        if (S[i] == '#' && S[i + 1] == '#')
            f = false;
    }
    FOR(i, D, B)
    {
        if (S[i] == '#' && S[i + 1] == '#')
            f = false;
    }

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return(false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return(true);
	}

	int find(int k) {
		if (data[k] < 0) return(k);
		return(data[k] = find(data[k]));
	}

	int size(int k) {
		return(-data[find(k)]);
	}
};

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

	ll n, m;
	cin >> n >> m;

	vector<ll> a(m), b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	UnionFind uf(n);
	vector<ll> ans;
	ll score = n * (n - 1LL) / 2LL;
	for (int i = m - 1; i >= 0; i--) {
		ans.push_back(score);

		if (uf.find(a[i]) == uf.find(b[i])) {
			continue;
		}

		score -= uf.size(a[i]) * uf.size(b[i]);
		uf.unite(a[i], b[i]);
	}

	reverse(begin(ans), end(ans));

	for (auto v : ans) {
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 4212
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
	vector<ll> cnt(n, 0);
	ll ans = 0;
	REP(i, n) if(s[i] == '.') ans++;
	ll c = 0;
	REP(i, n) {
		if(s[i] != '.') {
			c++;
		}
		cnt[i] = c;
	}
	c = 0;
	for(ll i = n - 1; i >= 0; i--) {
		cnt[i] += c;
		if(s[i] == '.') c++;
	}
	REP(i, n) ans = min(ans, cnt[i]);
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 2180
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //昇順
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}

  bool contain(Point a){
    return sgn((a-p).norm(),r)<=0;
  }

  Circle circumCircle(Point a,Point b){
    Point q=(a+b)/2;
    return Circle(q,(a-q).norm());
  }

  Circle circumscribedCircle(Point p, Point q, Point r){
    Point a=(q-p)*2,b=(r-p)*2;
    Point c(p.dot(p)-q.dot(q),p.dot(p)-r.dot(r));
    Circle res;
    res.p.x=a.y*c.y-b.y*c.x;
    res.p.y=b.x*c.x-a.x*c.y;
    res.p=res.p/a.cross(b);
    return Circle(res.p, p.dist(res.p));
  }

  Circle minEnclosingCircle(vector<Point>ps){
    if(ps.size()==0)return Circle(Point(0,0),0);
    if(ps.size()==1)return Circle(ps[0],0);

    Circle circle=circumCircle(ps[0],ps[1]);
    for(int i=2;i<ps.size();i++){
      if(!circle.contain(ps[i])){
	circle=circumCircle(ps[0],ps[i]);
	for(int j=1;j<i;j++){
	  if(!circle.contain(ps[j])){
	    circle=circumCircle(ps[j],ps[i]);
	    for(int k=0;k<j;k++){
	      if(!circle.contain(ps[k])){
		circle=circumscribedCircle(ps[i],ps[j],ps[k]);
	      }
	    }
	  }
	}
      }
    }
    return circle;
  }

};

int main(void){

  int n;
  cin >> n;
  vector<Point>ps(n);

  for(int i=0;i<n;i++)cin >> ps[i].x >> ps[i].y;
  Circle c;
  printf("%.20f",c.minEnclosingCircle(ps).r);
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
# Aizu Problem 0111: Doctor's Memorable Code
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def bin5(k):
    b = bin(k)[2:]
    while len(b) < 5:
        b = '0' + b
    return b


CODE1 = {' ': '101', "'": '000000', ",": '000011', '-': '10010001',
         '.': '010001', '?': '000001',
         'A': '100101', 'B': '10011010', 'C': '0101', 'D': '0001',
         'E': '110', 'F': '01001', 'G': '10011011', 'H': '010000',
         'I': '0111', 'J': '10011000', 'K': '0110', 'L': '00100',
         'M': '10011001', 'N': '10011110', 'O': '00101', 'P': '111',
         'Q': '10011111', 'R': '1000', 'S': '00110', 'T': '00111',
         'U': '10011100', 'V': '10011101', 'W': '000010',
         'X': '10010010', 'Y': '10010011', 'Z': '10010000'}
CODE1_rev = {value: key for key, value in CODE1.items()}

CODE2 = {bin5(k): chr(65+k) for k in range(26)}
symbols = [' ', '.', ',', '-', "'", '?']
for k in range(len(symbols)):
    CODE2[bin5(26+k)] = symbols[k]
CODE2_rev = {value: key for key, value in CODE2.items()}


def encode(string):
    enc = ''.join([CODE1[char] for char in string])
    while len(enc) % 5 != 0:
        enc += '0'
    return ''.join([CODE2[enc[5*k:5*k+5]] for k in range(len(enc) // 5)])

def decode(string):
    bitstring = ''.join([CODE2_rev[char] for char in string])
    decoded = ""
    while len(bitstring) > 0:
        k = 0
        while True:
            k += 1
            cand = bitstring[:k]
            if cand in CODE1_rev:
                decoded += CODE1_rev[cand]
                bitstring = bitstring[k:]
                break
            if k >= len(bitstring):
                return decoded
    return decoded


for line in sys.stdin:
    print(decode(line.replace('\n', '')))

Measured memory_bytes: 7640
n,*t=map(int,open(0).read().split())
s=i=j=0
for t,x,y in zip(t[::3],t[1::3],t[2::3]):
  d=abs(y-i)+abs(x-j)
  if t-s<d or d%2!=(t-s)%2:
    print('No')
    exit()
  s,i,j=t,y,x
print('Yes')

Measured memory_bytes: 26632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	long mod = 2019;
	public void run() {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();

		long ans = 1001001001;
		for(long i=l+1; i<=Math.min(r, l+mod); i++) {
			for(long j=l; j<i; j++) {
				long tmp = i*j;
				tmp %= mod;
				ans = Math.min(ans, tmp);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 35728
#include <iostream>
using namespace std;
int a[26]={};
int main(){
	char s;
	while (cin >> s){
    	s=tolower(s);
    	a[s-97]++;
	}
    for(int i=0;i<26;i++){
		cout<<char(i+97)<<" : "<<a[i]<<endl;
    }
}



Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const int OO = (int)1e8;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
ll power(ll base, ll num)
{
	ll sum = 1;
	for (int i = 0; i < num / 2; i++)
		sum *= base;
	if (num % 2 == 0)
		return sum * sum;
	return sum * sum * base;
}
ll convertToDecimal(string str)
{
	ll sum = 0;
	int j = 0;
	for (int i = str.size() - 1; i >= 0; i--)
	{
		if (str[i] == '1')
			sum += power(2, j);
		j++;
	}
	return sum;
}
void convertToBinary(ll num)
{
	string str = "";
	while (num)
	{
		if (num % 2)
			str += '1';
		else
			str += '0';
		num /= 2;
	}
	reverse(all(str));
	cout << str << endl;
}
int main()
{
	IO;
	//in_out_txt();
	int n;
	cin >> n;
	int i = 1;
	ll t0 = 2, t1 = 1, t2;
	if (n == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	while (i < n)
	{
		t2 = t0 + t1;
		t0 = t1, t1 = t2;
		i++;
	}
	cout << t2 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input().strip())

def make_prime_list(N):
  prime_list = [2,3]
  for i in range(5, N+1):
    flag = True
    for p in prime_list:
      if i % p == 0:
        flag = False
        break
    if flag:
      prime_list.append(i)
    
  return prime_list

prime_list = make_prime_list(N)
  
def prime_factorization(n, prime_list):
  result = []
  for p in prime_list:
    while True:
      if n % p == 0:
        result.append(p)
        n = n//p
      else:
        break
  return result
  
all_counter = Counter()
for i in range(2,N+1):
  all_counter += Counter(prime_factorization(i, prime_list))

ans = 1
for k in all_counter.keys():
  ans *= all_counter[k]+1
  
print(ans%1000000007)
  

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

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

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  int ans = 0;
  for (int a = 1; a <= N; a++) {
    int b = N - a;
    if (a < b) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    vector<int> res(n, 0);
    iota(res.begin(), res.end(), 0);
    auto cmp = [&](int l, int r) {
        return A[l] < A[r];
    };
    sort(res.begin(), res.end(), cmp);

    for  (int i = 0; i < n; ++i) {
        cout << res[i] + 1 << (i == n - 1 ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 1664
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    static ArrayList<Node>[][] matches;
    static int [][]count;
    static int [][] cost;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        count = new int[n+1][n+1];
        cost = new int[n+1][n+1];
        matches = new ArrayList[n+1][n+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++)
                matches[i][j] = new ArrayList<Node>();
        }
        for(int i=1;i<=n;i++){
            int next = in.nextInt();
            int pmin = Math.min(i,next);
            int pmax = Math.max(i,next);
            for(int j=1;j<n-1;j++){
                next = in.nextInt();
                int mn = Math.min(i,next);
                int mx = Math.max(i,next);
                count[mn][mx] +=1;
                matches[pmin][pmax].add(new Node(mn,mx));
                pmin = mn;pmax=mx;
            }
        }
        LinkedList<Node> queue = new LinkedList<>();
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++) {
                if(matches[i][j].size()>0 && count[i][j]==0){
                    queue.addLast(new Node(i,j));
                }
            }
        }
        while (queue.size()>0){
            Node next = queue.removeFirst();
            for(Node v:matches[next.l][next.h]){
                dfs(v,0);
            }
        }
        int day =0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(count[i][j]>0){
                    System.out.println(-1);
                    return;
                }
                day=Math.max(day,cost[i][j]);
            }
        }
        System.out.println(day+1);
    }
    static public class Node{
        int l;int h;
        public Node(int a,int b){
            l=a;h=b;
        }
    }
    static void dfs(Node vertice , int v){
        int curCost = 1+v;
        cost[vertice.l][vertice.h]= Math.max(curCost,cost[vertice.l][vertice.h]);
        count[vertice.l][vertice.h]--;
        if (count[vertice.l][vertice.h]==0 && matches[vertice.l][vertice.h].size()>0){
            for(Node value:matches[vertice.l][vertice.h]){
                dfs(value,cost[vertice.l][vertice.h]);
            }
        }
    }

}


Measured memory_bytes: 270608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n, 0));
	rep(i,2) rep(j,n) cin >> a[i][j];
	
	reverse(a[1].begin(), a[1].end());
	
	vector<vector<int>> sum_v(2, vector<int>(n, 0));
	sum_v[0][0] = a[0][0];
	sum_v[1][0] = a[1][0];
	for(int i = 0; i < 2; ++i){
		for(int j = 1; j < n; ++j){
			sum_v[i][j] = sum_v[i][j-1] + a[i][j];
		}
	}
	
	reverse(sum_v[1].begin(), sum_v[1].end());
	
	int mx = 0;
	for(int i = 0; i < n; ++i){
		mx = max(mx, sum_v[0][i] + sum_v[1][i]);
	}
	
	cout << mx << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
#define ashar(x , y , z) cout<<setprecision(x)<<fixed<<y ; if (z==1) cout<<"\n" ;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7 , inf2 = 1e12;
int const mxn = 5e6 + 10 ;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int l[30][30] ; 
long long  dp[30][(1<<21)+10] ; 
int main(){
	migmig
	int n ; 
	cin>>n ; 
	for (int i = 0 ; i <n ; i ++){
		for (int j = 0 ; j <n ; j++)
			cin>>l[i][j] ; 
	}
	
	for (int mask = 0 ; mask  <(1<<n) ; mask ++){
		for (int i = 0 ; i <n ; i++)
			if ((1<<i)&mask and l[0][i])
				dp[0][mask]++ ; 
	}
	
	
	for (int v = 1 ; v < n ; v++){
		for (int mask = (1<<(v-1))-1 ; mask < (1<<n) ; mask++){
			if (__builtin_popcount(mask) < v) continue ; 
			for (int u = 0 ; u < n ; u++){
				if (l[v][u] and mask&(1<<u)){
					dp[v][mask] += dp[v-1][mask - (1<<u)] ; 
					if (dp[v][mask] >= inf)
						dp[v][mask]%=mod ; 
				}
			}
		}
	}
	cout<<dp[n-1][(1<<n)-1]%mod ; 

}



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

#define rep(i, s, t) for(int i = (s), i##E = (t); i <= i##E; ++i)
#define dec(i, s, t) for(int i = (s), i##E = (t); i >= i##E; --i)

using namespace std;

const int N = 1e5 + 10;

int n, m, vis[N], col[N];
vector<int> G[N];

bool dfs_color(int u)
{
	vis[u] = 1;
	rep(i, 0, (int) G[u].size() - 1)
	{
		int v = G[u][i];
		if(vis[v]) 
		{
			if(col[v] == col[u]) return false;
			continue;
		}
		col[G[u][i]] = col[u] ^ 1;
		if(!dfs_color(G[u][i])) return false;
	} return true;
}

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, 1, m)
	{
		static int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	} 
	
	if(dfs_color(1))
	{
		int c1 = 0, c2 = 0;
		rep(i, 1, n) c1 += col[i], c2 += !col[i];
		printf("%lld\n", 1LL * c1 * c2 - m);
	}else printf("%lld\n", 1LL * n * (n - 1) / 2 - m);
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#define llint long long

using namespace std;

llint n, m, mod;
llint dp[5005][5005];
llint dpsum[5005][5005];
llint dp2[5005][5005];
llint num[5005][5005];

int main(void)
{
	cin >> n >> mod;
	if(n == 2){
		cout << 3 << endl;
		return 0;
	}
	m = (n+1)/2-1;
	
	dp[0][0] = 1;
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= n; j++){
			dp[i][j] = dp[i][j-1];
			if(i-j >= 0) dp[i][j] += dp[i-j][j], dp[i][j] %= mod;
		}
	}
	for(int j = 0; j <= n; j++){
		llint sum = 0;
		for(int i = 0; i <= n; i++){
			sum += dp[i][j], sum %= mod;
			dpsum[i][j] = sum;
		}
	}
	
	for(int i = 0; i <= n; i++) dp2[0][i] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			llint ret = dp[i][j];
			if(i-m >= 0 && j-1 >= 0) ret += mod - dp2[i-m][j-1];
			if(i-2*m >= 0 && j-2 >= 0) ret += mod - dp2[i-2*m][j-2];
			if(i-3*m >= 0 && j-3 >= 0) ret += mod - dp2[i-3*m][j-3];
			if(i-(m+1) >= 0 && j-1 >= 0) ret += mod - dp[i-(m+1)][j-1];
			if(i-(m+2) >= 0 && j-1 >= 0) ret += mod - dpsum[i-(m+2)][j-1];
			dp2[i][j] = ret % mod;
		}
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			if(i+j > n) break;
			llint tmp = 0;
			for(int k = 0; k <= 3; k++){
				if(i-k*m < 0 || j-k < 0) break;
				if(n % 2 == 0) tmp += dp2[i-k*m][j-k] * (k+1);
				else tmp += dp2[i-k*m][j-k];
			}
			num[i][j] = tmp % mod;
		}
	}
	for(int j = 0; j <= n; j++){
		llint sum = 0;
		for(int i = 0; i <= n; i++){
			if(i+j > n) break;
			sum += num[i][j], sum %= mod;
			num[i][j] = sum;
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++){
			ans += dp[i-j][m] * num[j-1][n-i] % mod;
		}
	}
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 782592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int n = Integer.parseInt(scanner.next());
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        
        for(int i =0; i < n; i++) {
        	String s = scanner.next();
        	
        	switch(s) {
        	case "AC":
        		ac++;
        		break;
        	case "WA":
        		wa++;
        		break;
        	case "TLE":
        		tle++;
        		break;
        	case "RE":
        		re++;
        		break;
        	}
        }
        
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 47596
/*相信玄学*/
#include<bits/stdc++.h>
using namespace std;
int a[10010];
int main()
{
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	if(ans>n) {cout<<"-1"; return 0;}
	else cout<<n-ans;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	u64 X;
	cin >> X;

	map<u64, u64> pow5s;
	for(u64 i=0; pow(i, 5)<=pow(2, 63); i++) {
		pow5s[pow(i, 5)] = i;
	}
	
	//for(const auto& p5 : pow5s) cout << p5.first << endl;
	
	for(u64 b=0; pow(b, 5)<=pow(2, 63); b++) {
		u64 b5 = pow(b, 5);
		u64 a5 = X + b5;
		u64 ma5 = X - b5;

		//cout << a5 << " " << ma5 << endl;
		
		if(pow5s.count(a5)) {
			u64 a = pow5s[a5];
			cout << a << " " << b;
			return 0;
		} else if(X >= b5 && pow5s.count(ma5)) {
			u64 a = pow5s[ma5];
			cout << a << " " << (-1) *(s64)b;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 4624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> A(n);
  vector<ll> B(n);
  vector<ll> C(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  rep(i, n) cin >> C[i];
  sort(all(A));
  sort(all(B));
  sort(all(C));
  vector<ll> dpA(n);
  vector<ll> dpB(n);
  vector<ll> dpC(n);
  rep(i, n) dpA[i] = 1;
  ll a = -1;
  ll sumA = 0;
  rep(i, n){
   	while(a+1<n && A[a+1]<B[i]){
      a++;
      sumA += dpA[a];
    }
    dpB[i] = sumA;
  }
  ll b = -1;
  ll sumB = 0;
  rep(i, n){
   	while(b+1<n && B[b+1]<C[i]){
      b++;
      sumB += dpB[b];
    }
    dpC[i] = sumB;
  }
  ll ans = 0;
  rep(i, n) ans += dpC[i];
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 7980
// H - Grid 1.cpp
// https://atcoder.jp/contests/dp/tasks/dp_h


#include <iostream>
#include <cstring>
using namespace std;
typedef unsigned long long int llu;

int nRows, nCols;
char matrix[1000][1000];
int memoTable [1000000];
int nWays(int i = 0, int j = 0){

    if(i == nRows-1 && j == nCols-1){
        return 1;
    }

    if(memoTable[i * nCols + j] != -1){
        return memoTable[i * nCols + j];
    }

    if(matrix[i][j] == '#'){
        memoTable[i * nCols + j] = 0;
        return 0;
    }

    int ways = 0;

    if(i+1 < nRows){
        ways = nWays(i+1, j);
    }

    if(j+1 < nCols){
        ways = (ways + nWays(i, j+1)) % 1000000007;
    }

    memoTable[i * nCols + j] = ways;
    return ways;
}

int main(){

    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); cout<<"H - Grid 1.cpp\n";
    cin >> nRows >> nCols;

    for(int i=0; i<nRows; ++i)
        for(int j=0; j<nCols; ++j)
            cin >> matrix[i][j];    

    memset(memoTable, -1, sizeof(memoTable));
    cout<<nWays();
    return 0;
}



Measured memory_bytes: 5248
#include<iostream>
#include<math.h>
 using namespace std ;
 int main()
{
short int a,b,c,d;

cin>>a;
cin>>b;
cin>>c;
cin>>d;
if((abs(c-a))<=d) cout<< "Yes";
else
 if((abs(c-b)<=d)&& ( abs(b-a)<=d) ) cout<< "Yes";
else
cout<< "No";




}

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

int main(void)
{
    long long int a=700,b,c,i,j,k,n;
    char x;
    for(i=0;i<3;i++){
        cin >> x;
        if(x=='o') a +=100;
    }

    cout << a;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  REP(i, n) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3780
import sys

N,M = map(int, sys.stdin.readline().strip().split())
A = list(map(int, sys.stdin.readline().strip().split()))

votes_M = sorted(A, reverse=True)[M-1]
votes = sum(A)

if votes_M >= (votes / (M * 4)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    ll t;
    cin >> t;
    int s = t%60;
    t/=60;
    int m = t%60;
    t/=60;
    int h = t%60;
    cout << h <<":"<<m<<":"<<s<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1; i<=(n); i++)
using namespace std;
 
int main(){
    int S; cin >> S;
    int ans=0;
    rep(i,S){
        string s=to_string(i);//数値から文字列へ変換！
        if (s.size()%2!=0) ans++;
    }
    cout << ans;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

int n;
ll k;
int a[maxn];
int vis[maxn];

void Find_vcycle(int u, int &t){
  vis[u] = 1;
  if (vis[a[u]]) {
    t = a[u]; return;
  }
  Find_vcycle(a[u], t);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i){
    int x; cin >> x;
    a[i] = x;
  }
  if (k <= n){
    int u = 1;
    while (k){
      --k; u = a[u];
    }
    cout << u; return 0;
  }
  int t = -1;
  Find_vcycle(1, t);
  int u = 1;
  while (u != t){
    --k; u = a[u];
  }
  int len = 1;
  u = a[t];
  while (u != t){
    ++len; u = a[u];
  }
  k = k % len;
  u = t;
  while (k){
    --k; u = a[u];
  }
  cout << u;

return 0;
}




Measured memory_bytes: 5184
N = int(input())
x = []
u = []
for i in range(N):
    x_next,u_next = input().split()
    x.append(x_next)
    u.append(u_next)
x = [float(i) for i in x]

def solve():
    value = 0
    for i in range(N):
        if(u[i]=='BTC'):
            value = value + x[i]*380000.0
        else:
            value = value + x[i]
    return value
print(solve())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;



void solve()
{
	int n;
	cin>>n;
	int k;
	cin>>k;
	
	map<int,vector<int>>mp;
	
	while(k--)
	{
		int d;
		cin>>d;
		
		for(int i=0;i<d;i++)
		{
			int a;
			cin>>a;
			mp[a].pb(d);
		}
	}
	
	int cnt=0;
	
	for(int i=1;i<=n;i++)
	{
		if(mp[i].size()==0)
		cnt++;
	}
	
	
	cout<<cnt<<endl;
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 3724
import Foundation
import CoreFoundation

#if swift(>=4.0)
#else
extension String {
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map{String($0)}
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func joined(separator separator: String = " ") -> String {
        return self.map{String($0)}.joinWithSeparator(separator)
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func reverse() {
        self = self.reversed()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: Character = " ") -> [String] {
    return readLine()!.split(separator: separator)
}
func readIntSplit(by separator: Character = " ") -> [Int] {
    return readLine()!.split(separator: separator).map{Int($0)!}
}
infix operator ** { associativity right precedence 155 }    // 右結合，乗除算より強くビットシフトより弱い
func **(lhs: Int, rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
func **(lhs: Int, rhs: Double) -> Double {
    return pow(Double(lhs), rhs)
}
//func gcd(_ x: Int, _ y: Int) -> Int {
//    return y>0 ? gcd(y, x%y) : x
//}
//func lcm(_ x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // タプル配列のソート
//print("Ready")

/*************** メインプログラム ***************/

let input = readIntSplit()
let (A, B) = (input[0], input[1])
print((A+B)%2>0 ? "IMPOSSIBLE":(A+B)/2)


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

using namespace std;
const int N = 2e5+7;

int h[N],e[N*2],ne[N*2],idx;
int w[N];
int ans[N]; 
int low[N];

void add(int a,int b){
	e[idx] = b,ne[idx] = h[a] , h[a] = idx++;
}

void dfs(int s,int fa,int pos)
{
	int temp1=-1,temp2=0,k=0;
	if(low[pos] < w[s]) temp1 = low[pos+1] ,low[++pos] = w[s];  //做好记录
	else {
		int j = lower_bound(low+1,low+pos+1,w[s]) - low ;
		temp2 = low[j],k = j;
		low[j] = w[s];
	}
	ans[s] = pos;
	for(int i=h[s];~i;i=ne[i]){
		int j = e[i];
		if(j==fa) continue;
		dfs(j,s,pos);
	}
	if(temp1!=-1) low[pos] = temp1;			//回溯
	else low[k] = temp2;
}

int main()
{
	int n,a,b;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	memset(h,-1,sizeof h);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		add(a,b),add(b,a);
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 23596
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
  int n, sum=0;

  cin >> n;

  int i;
  for (i=0; i<n; i++) {
    int a;
    cin >> a;
    sum += a - 1;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	var ans int

	for i := 0; i < n; i++ {
		a := nextInt()
		aCalc := calc(a)
		if i == 0 || ans > aCalc {
			ans = aCalc
		}
	}
	fmt.Println(ans)
}

func calc(a int) int {
	result := 0
	for a%2 == 0 {
		result++
		a /= 2
	}
	return result
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n;
  scanf("%d",&n);
  vector<uli>a(n);
  for(int i=0;i<n;i++)scanf("%lld",&a[i]);
  uli l=2,r=2;
  for(int i=n-1;i>=0;i--){
    uli m=a[i];
    uli from=((l+m-1)/m)*m;
    uli to=(r/m)*m;
    if(from>to){
      puts("-1");
      return 0;
    }
    l=from;
    r=to+m-1;
  }
  printf("%lld %lld\n",l,r);
  return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

double ans = 0;

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    double x;
    string u;

    scanf("%lf", &x);
    cin >> u;

    if (u == "BTC") {
      ans += x * 380000.0;
    }
    else {
      ans += x;
    }
  }

  printf("%lf\n", ans);

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int):
    open = 1
    count = 0
    while(open<B):
        open -= 1
        open += A 
        count += 1
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0

n = (A-1) // C
# n = math.ceil(A / C) - 1
m = B // C
if m >= n:
  count_div += m - n

l = (A-1) // D
# l = math.ceil(A / D) - 1
k = B // D
if k >= l:
  count_div += k - l

j = (A-1) // E
# j = math.ceil(A / E) - 1
i = B // E
if i >= j:
  count_div -= i - j

print(B - A + 1 - count_div)

Measured memory_bytes: 64364