akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll 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()
{
    ll N;
    cin >> N;
    ll sum = 0;
    repd(i, 1, N + 1) {
        if (i % 3 == 0 && i % 5 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        else sum += i;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main() {
  signed L, N, w, i, x, sum = 0;
  cin >> L >> N;
  
  for(i = 0; i < N; i++) {
    cin >> x >> w;
    sum += x * w;
  }

  
  if(sum < 0) {
    cout << 1 << endl << 1 << ' ' << 0 - sum << endl;
  }
  else if(sum > 0) {
    cout << 1 << endl << -1 << ' ' << sum << endl;
  }
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b;
    cin>>a>>b;
    if((a+b)%2==0)
    {
        cout<<(a+b)/2;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int r,c;
  int rc[1000][1000];
  int i,j;
  scanf("%d%d",&r,&c);
  for(i=0;i<r;i++)
    for(j=0;j<c;j++)
      scanf("%d",&rc[i][j]);

  for(j=0;j<r;j++)
    for(i=0;i<c;i++)
      rc[j][c]=rc[j][c]+rc[j][i];
  for(i=0;i<c;i++)
    for(j=0;j<r;j++)
      rc[r][i]=rc[r][i]+rc[j][i];
  for(i=0;i<c;i++)
    rc[r][c]=rc[r][c]+rc[r][i];
  for(j=0;j<r;j++)
    rc[r][c]=rc[r][c]+rc[j][c];
  rc[r][c]=rc[r][c]/2;

  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      if(j)
	printf(" ");
      printf("%d",rc[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}


int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll n;
	cin>>n;
	
	ll ans=0;
	
	ans+=n*(n+1)/2;
	
	ans-=(n/3)*(n/3+1)/2*3;
	ans-=(n/5)*(n/5+1)/2*5;
	ans+=(n/15)*(n/15+1)/2*15;
	
	cout<<ans;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int main(){
  int A[100], i, j, minj, count=0, N, tmp, a, b, min;

  scanf("%d",&N);
  if(N<1 || N>100) exit(1);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
    if(A[i]<0 || A[i]>100) exit(2);
  }

  for(i=0; i<N-1; i++){
    min=A[i];
    a=0;
    for(j=i; j<N; j++){
      if( min > A[j] ) {
	min = A[j];
	a=1;
	b=j;
      }
    }
    if(a==1){
      tmp = A[b];
      A[b] = A[i];
      A[i] = tmp;
      count++;
    }
  }


  for(i=0; i<N-1; i++) printf("%d ",A[i]);
  printf("%d\n",A[N-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2044
n = gets
nums = gets.chomp.split.map(&:to_i)
ans = 0
if nums.size<3
  puts 0
  exit
end
nums = nums.combination(3).to_a
nums.each do |pat|
  next if pat.uniq.size < 3 || pat.sum <= 2*pat.max
  ans +=1
end
p ans

Measured memory_bytes: 29448
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int k = s[1];

            WriteLine(k == 1 ? 0: n - k);
        }
    }
}


Measured memory_bytes: 13396
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x;
    cin >> x;
    ll ans = (x/500)*1000 + ((x%500)/5)*5;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long x, sum=100, j;
    float i;
    cin >> x;
    for(i=1;;i++) {
        j = sum*0.01;
        sum += j;
        if(sum >= x) {
            cout << i << endl;
            return 0;
        }

    }

    return 0;
}


Measured memory_bytes: 3784
import  java.io.*;
import  java.math.*;
import  java.util.*;


public class Main {
    public static void main(String[] args) {
    	Scanner cin = new Scanner(System.in);
    	int n = cin.nextInt();
    	long sum = 0;
    	for(int i = 1; i <= n; i++){
    		for(int j = 1; j <= n; j++){
    			for(int k = 1; k <= n; k++){
    				sum += gcd(gcd(i,j),k);
    			}
    		}
    	}
    	System.out.println(sum);
    }
    public static int gcd(int a,int b)
    {
        if(a==0) return b;
        if(b==0) return a;
        if(!(a%2==1)&&!(b%2==1))
        {
            return gcd(a>>1,b>>1)<<1;
        }
        else if(!(b%2==1))
        {
            return gcd(a,b>>1);
        }
        else if(!(a%2==1))
        {
            return gcd(a>>1,b);
        }
        else
        {
            return gcd(Math.abs(a-b),Math.min(a,b));
        }
    }
}

Measured memory_bytes: 37600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c;
  cin>>a>>b>>c;
  if(a && b && c==0)
    cout<<"Open"<<endl;
  else if(a==0 && b==0 && c)
    cout<<"Open"<<endl;
  else
    cout<<"Close"<<endl;
}

Measured memory_bytes: 3076
def part(n):
    n = int(n)
    num1 = n/10
    num2 = n % 10
    return num1, num2


def final():
    months, days = map(int, input().split())

    count = 0
    for month in range(1, months+1):
        for day in range(0, days+1):
            x, y = part(day)
            x = int(x)
            y = int(y)
            if x >= 2 and y >= 2 and (x*y) == month:
                count += 1

    print(count)


if __name__ == "__main__":
    final()


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll mods = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    //print(fixed << setprecision(10));
    
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> c(n,vector<int>(m+1));
    rep(i,n) rep(j,m+1) cin >> c[i][j];

    ll ans=-1,sum;
    vector<ll> s(m,0);
    bool flag;
    
    rep(bit,1<<n){
        rep(i,m) s[i]=0;
        sum = 0;
        flag = 0;
        rep(i,n){
            if(bit & (1<<i)){
                sum += c[i][0];
                rep(j,m) s[j] += c[i][j+1];
            }
        }
        rep(i,m) if(s[i]<x){
            flag=1; break;
        }
        if(flag==1) continue;
        if(ans == -1 || sum < ans) ans = sum;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

int main() {
    int n, m;
    cin >> n >> m;
    int x;
    cin >> x;
    ll xsum = 0;
    for (int i = 0; i < n - 1; i++) {
        int xx;
        cin >> xx;
        xsum += multiply(xx - x, multiply(i + 1, (n - 1 - i)));
        x = xx;
    }
    int y;
    cin >> y;
    ll ysum = 0;
    for (int i = 0; i < m - 1; i++) {
        int yy;
        cin >> yy;
        ysum += multiply(yy - y, multiply(i + 1, (m - 1 - i)));
        y = yy;
    }
    cout << multiply(xsum, ysum) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		if(n<1000) out.println("ABC");
		else       out.println("ABD");
	}
}


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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

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

    static int64_t dp[3002][3002][3][3];
    dp[A][B][0][0] = 1;
    for(int i=A; i<=C; i++) for(int j=B; j<=D; j++) for(int a=0; a<3; a++) for(int b=0; b<3; b++){
        // 上、隅以外
        {
            add(dp[i+1][j][1][b], dp[i][j][a][b] * (j-1));
        }
        // 上、隅
        {
            add(dp[i+1][j][1][min(2, 1+b)], dp[i][j][a][b]);
        }
        // 右、隅以外
        {
            if(a != 1 || i==A) add(dp[i][j+1][a][1], dp[i][j][a][b] * (i-1));
        }
        // 右、隅
        {
            add(dp[i][j+1][min(2, 1+a)][1], dp[i][j][a][b]);
        }
    }

    int64_t ans = 0;
    for(int a=0; a<3; a++) for(int b=0; b<3; b++) add(ans, dp[C][D][a][b]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 636676
fn main() {
    use proconio::input;
    input!(n: u32);
    input!(aa: [u64; n]);

    let mut max = aa[0];
    let mut ans = 0;
    for a in aa {
        if a < max {
            ans += max - a;
        } else if max < a {
            max = a;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 5540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    vvec<ll> dp(N+1, vec<ll>(2,-INFLL));
    dp[0][0] = 0;
    rep(i,N){
        rep(j,2)rep(k,2){
            if(i == N-1 && k == 1)continue;
            if(j == k)chmax(dp[i+1][k], dp[i][j] + A[i]);
            else chmax(dp[i+1][k], dp[i][j] - A[i]);
        }
    }
    cout << dp[N][0] << endl;
}


Measured memory_bytes: 9528
#include<stdio.h>
#include<string.h>

int main()
{
	int i,j,k,l1,l2,l;
	char str1[100];
	char str2[100];
	char str3[300];
	gets(str1);
	gets(str2);
	l1=strlen(str1);
	l2=strlen(str2);
	l=l1+l2;
	//printf("%d\n",l1);
	//printf("%d\n",l2);
	//printf("%d\n",l);
	k=0;j=0;
	for(i=0;i<l;i++)
	{
		if(i%2==0)
            {
                str3[i]=str1[j];
                j++;
            }
        else
            {
                str3[i]=str2[k];
                k++;
            }
	}
	for(i=0;i<l;i++)
		printf("%c",str3[i]);



	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] chara = str.split("", 0);
		int length = chara.length;
		for (int i = 0; i <= length / 2; i++) {
			int j = length - i - 1;
			if (i >= j) {
				break;
			}
			String temporary = chara[i];
			chara[i] = chara[j];
			chara[j] = temporary;
		}
		for (String charac : chara) {
			System.out.print(charac);
		}
		System.out.println();
	}
}

Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

struct edge{int to, cost;};

class Graph
{
public:
    int N;
    vector<vector<edge>> G;
    vec dp;

    Graph(int N): N(N){
        G = vector<vector<edge>>(N, vector<edge>(0));
        dp.resize(N);
    }

    void add_edge(int from, int to, int cost = 0){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost = 0){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, int p = -1){
        dp[v] = 0;
        int z = 0;
        for(auto e: G[v]) if(e.to != p){
            dfs(e.to, v);
            dp[v] += dp[e.to];
            if(dp[e.to] == 0) z++;
        }
        if(z > 1) dp[v] += z - 1;
    }

};

signed main(){

    int N; cin >> N;
    Graph G(N);
    int a, b;
    REP(i, N - 1){
        cin >> a >> b;
        G.add_edge2(a, b);
    }
    int r = -1;
    REP(i, N) if(SZ(G.G[i]) >= 3){
        r = i;
        break;
    }
    int ans;
    if(r == -1) ans = 1;
    else{
        G.dfs(r);
        ans = G.dp[r];
    }
    cout << ans << endl;

    return 0;
}


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

//////////////////////////////   Begin Macros

#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define rep1(i, N) for (int i = 1; i <= (int)(N); i++)
using ll = long long;

//////////////////////////////   End Macros

void solve()
{
  ll N;
  cin >> N;
  ll ans = N * (N + 1) * (N + 2) / 6;
  rep(i, N - 1)
  {
    ll u, v;
    cin >> u >> v;
    if (u > v)
      swap(u, v);
    ans -= u * (N - v + 1);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, m;
    readlnTo(n, m);
    auto c = new long[](n);
    foreach(i; iota(m)) {
        long a, b;
        readlnTo(a, b);
        ++c[a-1];
        ++c[b-1];
    }
    writeln(c.all!(a => a%2 == 0) ? "YES": "NO");
}



Measured memory_bytes: 4092
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count += 1
print(len(r) * len(g) * len(b) - count)


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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<vector<int>> res(H, vector<int>(W));

    int next_h = 0, next_w = 0;
    for (int a = 0; a < N; a++) {
        int n = A[a];
        int cnt = 0;
        for (int i = next_h; i < H && cnt < n; i++) {
            if (i % 2 == 0) {
                for (int j = next_w; j < W && cnt < n; j++) {
                    res[i][j] = a + 1;
                    cnt++;
                    if (j == W - 1 && i < H - 1) {
                        next_h = i + 1;
                        next_w = j;
                    } else {
                        next_h = i;
                        next_w = j + 1;
                    }
                }
            } else {
                for (int j = next_w; j >= 0 && cnt < n; j--) {
                    res[i][j] = a + 1;
                    cnt++;
                    if (j == 0 && i < H - 1) {
                        next_h = i + 1;
                        next_w = j;
                    } else {
                        next_h = i;
                        next_w = j - 1;
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(b-a<=0)printf("delicious\n");
	else if(b-a<=x)printf("safe\n");
	else printf("dangerous\n");
	return 0;
 } 

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

// THINK: INT vs LONG LONG?

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

	int n, x, y;
	cin >> n >> x >> y;
	--x, --y;
	vector<vector<int>> adj(n);
	for (int i = 0; i < n - 1; ++i) {
		adj[i].push_back(i + 1);
		adj[i + 1].push_back(i);
	}
	adj[x].push_back(y);
	adj[y].push_back(x);
	vector<int> cnt(n);
	for (int i = 0; i < n; ++i) {
		// bfs
		vector<int> dist(n, (int) 1e9 + 5);
		queue<int> q;
		q.push(i);
		dist[i] = 0;
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (int v: adj[u]) {
				if (dist[u] + 1 < dist[v]) {
					dist[v] = dist[u] + 1;
					q.push(v);
				}
			}
		}
		for (int j = i + 1; j < n; ++j) {
			cnt[dist[j]]++;
		}
	}
	for (int i = 1; i < n; ++i) {
		cout << cnt[i] << '\n';
	}
	return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool comp(P a, P b) {
    return a.first + a.second < b.first + b.second;
}

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

    vector<P> X(N);
    rep(i, N) {
        int x, l;
        cin >> x >> l;
        X[i] = P(x, l);
    }

    sort(X.begin(), X.end(), comp);

    int ans = 0, now = -INF;
    rep(i, N) {
        P p = X[i];
        if (p.first - p.second < now) continue;
        ans++;
        now = p.first + p.second;
    }

    cout << ans << endl;
}

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

int main() {
    int N, a, b, ans = 1;
    bool first = true, up;
    cin >> N >> a;
    for (int i = 1; i < N; i++) {
        cin >> b;
        if (a == b) continue;
        if (first) {
            up = a < b;
            first = false;
        }
        if (up && a > b || !up && a < b) {
            ans++;
            first = true;
            up = a < b;
        }
        a = b;
    }
    cout << ans << endl;
}

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

int main() {
  int n, m;
  vector<int> a, b;
  vector<int> v_or, v_and;

  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int A;
    cin >> A;
    a.push_back(A);
  }

  for(int i = 0; i < m; i++) {
    int B;
    cin >> B;
    b.push_back(B);
  }

  set_union(a.begin(), a.end(), b.begin(), b.end(), back_inserter(v\
_or));
  set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_ins\
erter(v_and));
  cout << (int)v_and.size() << ' ' << (int)v_or.size() << endl;

  for (int i = 0; i < (int)v_and.size(); i++)
    cout << v_and[i] << endl;
  for (int i = 0; i < (int)v_or.size(); i++)
    cout << v_or[i] << endl;

  return 0;
}



Measured memory_bytes: 5408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <cassert>
#include <cctype>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
typedef long long int LL;
const int MAXN = 100000 + 24;
char str[4],ans[20];
int ope[3];
bool flag;
void dfs(int op, int pos) {
	if (flag) return;
	ope[pos] = op;
	if (pos == 2) {
		int res = str[0]-'0';
		for (int i = 0; i <= 2; i++) {
			if (ope[i]) {
				res += (str[i + 1] - '0');
			}
			else {
				res -= (str[i + 1] - '0');
			}
		}
		if (res == 7) {
			flag = true;
		}
		return;
	}
	for (int i = 0; i <= 1; i++) {
		dfs(i, pos + 1);
	}
}
int main() {
#ifdef kirito
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // kirito
	while (~scanf("%s", str)) {
		flag = false;
		for (int i = 0; i <= 1 && !flag; i++) {
			dfs(i, 0);
		}
		int pos = 0;
		for (int i = 0; i < 4; i++) {
			ans[pos++] = str[i];
			if (i == 3) {
				ans[pos++] = '=';
				ans[pos++] = '7';
				ans[pos++] = 0;
			}
			else {
				ans[pos++] = (ope[i] ? '+' : '-');
			}
		}
		printf("%s\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



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

	For (a, -300, 300)
	For (b, -300, 300) {
		int dif = a - b;

		if (dif != 0 && n % dif == 0) {
			ld now = a * (ld)a * (ld)a * (ld)a + a * (ld)a * (ld)a * (ld)b + a * (ld)a * (ld)b * (ld)b 
				+ a * (ld)b * (ld)b * (ld)b + b * (ld)b * (ld)b * (ld)b;
			if (now < inf && (ll)now == n / dif) {
			  	cout << a << ' ' << b << '\n';
			   	exit(0);
			 }
		}
	}

	assert(0);
	return Accepted;
}

// B...a

Measured memory_bytes: 17736
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

void NO() {
    puts("-1");
    exit(0);
}

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

    int N, K;
    cin >> N >> K;
    V<int> a(N);
    rep(i, N) cin >> a[i];

    V<int> res;

    int pv = -1;
    rep(i, K + 1) {
        int mn = -1;
        rep(j, N) if(j != pv && (mn == -1 || a[mn] > a[j])) mn = j;
        rep(j, N) {
            if(j != pv && j != mn) {
                res.push_back(j + 1);
                if(--a[j] < 0) NO();
            }
        }
        res.push_back(mn + 1);
        if(--a[mn] < 0) NO();
        pv = mn;
    }

    cout << res.size() << endl;
    for(int x : res)
        cout << x << " ";

    return 0;
}

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

long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

long long solve(int N, long long M, vector<long long> &a) {
    while (a[0] % 2 == 0) {
        for (int i = 0; i < N; ++i) {
            if (a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        M /= 2;
    }
    for (int i = 0; i < N; ++i) if (a[i] % 2 == 0) return 0;

    // lcm
    long long lcm = 1;
    for (int i = 0; i < N; ++i) {
        long long g = GCD(lcm, a[i]);
        lcm = lcm / g * a[i];
        if (lcm > M) return 0;
    }
    return (M / lcm + 1) / 2;
}

int main() {
    int N; long long M;
    cin >> N >> M;
    vector<long long> a(N);

    for (int i = 0; i < N; ++i) cin >> a[i], a[i] /= 2;
    cout << solve(N, M, a) << endl;
}

Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

# 迷路読み込み
H,W = map(int, input().split())
c1,c2= map(int, input().split())
d1,d2= map(int, input().split())
A=[list(input()) for i in range(H)]
edges = [[] for i in range(H * W)]

for i in range(H):
    for j in range(W):
        for di in range(-2,3):
            for dj in range(-2, 3):
                ni, nj = i + di, j + dj
                if 0 <= ni < H and 0 <= nj < W and A[i][j]!='#' and A[ni][nj]!='#':
                    if di==0 and dj==0:
                        continue
                    elif (di==0 and dj==1) or (di==1 and dj==0) or (di==-1 and dj==0) or (di==0 and dj==-1):
                        edges[i * W + j].append((ni * W + nj,0))
                    else:
                        edges[i * W + j].append((ni * W + nj,1))

s=(c1-1)*W+c2-1
g=(d1-1)*W+d2-1
dist = [10**9]*(H*W)
dist[s] = 0
que = deque()
que.append(s)

while len(que) > 0:
    i = que.popleft()
    for j, c in edges[i]:
        d = dist[i] + c
        if d < dist[j]:
            dist[j] = d
            if c == 1:
                que.append(j)
            else:
                que.appendleft(j)


ans=dist[g]
if ans==pow(10,9):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 389696
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
int n, m;
const ll INF = 1e9;
const int MAX = 405;
ll g[MAX][MAX];
char mat[MAX][MAX];
void floydWarshall() {
    for (int k = 0; k < max(n * n, m * m); k++)
        for (int i = 0; i < max(n * n, m * m); i++)
            for (int j = 0; j < max(n * n, m * m); j++)
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}

void init() {
    for (int i = 0; i <= max(n * n, m * m); i++) {
        for (int j = 0; j <= max(n * n, m * m); j++) {
            g[i][j] = (i == j ? 0 : INF);
        }
    }
}
bool ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    cin >> n >> m;
    forn(i, n) {
        string s;
        cin >> s;
        forn(j, m) {
            mat[i][j] = s[j];
        }
    }
    init();
    forn(i, n) {
        forn(j, m) {
            if (mat[i][j] != '#') {
                int cur = i * m + j;
                g[cur][cur] = 0;
                if (ok(i, j + 1) && mat[i][j + 1] == '.') {
                    g[cur][cur + 1] = 1;
                }
                if (ok(i, j - 1) && mat[i][j - 1] == '.') {
                    g[cur][cur - 1] = 1;
                }
                if (ok(i + 1, j) && mat[i + 1][j] == '.') {
                    g[cur][cur + m] = 1;
                }
                if (ok(i - 1, j) && mat[i - 1][j] == '.') {
                    g[cur][cur - m] = 1;
                }
            }
        }
    }
    floydWarshall();
    ll mx = 0;
    forn(i, n) {
        forn(j, m) {
            if (mat[i][j] != '#') {
                forn(a, n) {
                    forn(b, m) {
                        if (mat[a][b] != '#') {
                            ll dis = g[i * m + j][a * m + b];
                            //cout << "[" << i * m + j << ", " << a * m + b << " ] = " << dis << endl;
                            if (dis != INF) mx = max(mx, dis);
                        }
                    }
                }
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

 
int main(){
  FAST_IO
  LL a, result, _b;
  double b;
  cin >> a >> b;
  _b = (b * 100 + 0.5);

  result = a * _b / 100LL;
  
  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 3720
def kaijou(n):
	res=1
	for i in xrange(1,n+1):
		res*=i
	return res

def comb(a,b):
	if(a<b or b<0):return 0
	if(b==0):return 1
	return kaijou(a)/kaijou(b)/kaijou(a-b)

a,b,c=map(int,raw_input().split())
c-=a*b
print comb(c+a-1,c)

Measured memory_bytes: 4320
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#define M_PI 3.14159265358979323846
#include <vector>
using namespace std;

int main(){
    unsigned long long int x;
    cin >> x;
    unsigned long long int a = 100;
    int t = 0;
    while(a < x){
      a += 0.01*a;
      t++;
    }
    cout << t;
}

  


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

ll a[2][101], dp[2][101],n;

void call(ll x, ll y, ll val)
{
    //cout << "XY " << x << " " << y << " " << val << endl;
    if(x >= 2) return;
    if(y >= n) return;
    if(x == 1 && y == n-1)
    {

        ll xx = a[x][y]+val;
        dp[x][y] = max(dp[x][y], xx);
        return;
    }
    ll xx = val+a[x][y];
    dp[x][y] = max(dp[x][y], xx);
    ll nv=dp[x][y];
    ll ny = y+1;
    call(x,ny,nv);
    ll nx = x+1;
    call(nx,y,nv);
}

int main()

{

    scanf("%lld", &n);
    for(ll i = 0; i < 2; i++)
        for(ll j = 0; j < n; j++) cin >> a[i][j];
    mset(dp,-1);
    //dp[0][0]=a[0][0];
    //dp[1][n-1]=a[1][n-1];
    call(0,0,0);
    cout << dp[1][n-1];
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define MOD 1000000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	vector<ull> abc(s.size()+5),ab(s.size()+5),a(s.size()+5),d(s.size()+5);
	abc[0]=(ull)0; // index0は始まる前
	ab[0]=(ull)0;
	a[0]=(ull)0;
	d[0]=(ull)1;
	
	for(int i=0;i<s.size();i++){
		if (s[i] == '?') {
			a[i + 1] = (3*a[i] + d[i])%MOD;
			ab[i + 1] = (3*ab[i] + a[i])%MOD;
			abc[i + 1] = (3*abc[i] + ab[i])%MOD;
			d[i+1]=3*d[i]%MOD;
		}
		else if (s[i] == 'A') {
			a[i + 1] = (a[i] + d[i])%MOD;
			ab[i + 1] = ab[i];
			abc[i + 1] = abc[i];
			d[i+1]=d[i];
		}
		else if (s[i] == 'B') {
			a[i + 1] = a[i];
			ab[i + 1] = (ab[i] + a[i])%MOD;
			abc[i + 1] = abc[i];
			d[i+1]=d[i];
		}
		else {
			a[i + 1] = a[i];
			ab[i + 1] = ab[i];
			abc[i + 1] = (abc[i]+ab[i])%MOD;
			d[i+1]=d[i];
		}
	}
	// for (int i = 0; i <= s.size(); i++) {
	// 	cout << a[i] << " " << ab[i] << " " << abc[i] << endl;
	// }
	cout<<abc[s.size()];
	return 0;
}

Measured memory_bytes: 3664
n = int(input())
a = list(map(int,input().split()))
cnt = {}
for x in a:
    if x not in cnt:cnt[x] = 1
    else: cnt[x] += 1
ans = 0
for key in cnt:
    if cnt[key] >= key:
        ans+= cnt[key] - key
    else:ans += cnt[key]
print(ans)

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

using ll = long long;
using namespace std;

ll n, a[5];

int main(){
	cin >> n;
	for(int i = 0; i < 5; ++i) cin >> a[i];
	ll mi = (ll)1e15;
	for(int i = 0; i < 5; ++i) mi = min(mi, a[i]);
	
	cout << (ll)ceil(1.0*n/mi)+4 << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a,b = I()
d = b-a
print((1+d)*d//2-b)

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

#define ll long long 

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

    int n; ll k;
    cin >> n >> k;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    vector<bool> visited(n+1);
    vector<int> last(n+1);

    // count how many times till back at 1
    int idx = 1;
    int cnt = 0;
    while (not visited[idx]) {
        //cout << "idx: " << idx << endl;
        //cout << "cnt: " << cnt << endl;
        visited[idx] = true;
        last[idx] = cnt;
        idx = a[idx];
        cnt++;
        if (cnt == k) {
            cout << idx << endl;
            return 0;
        }
    }

    //cout << "repeats after " << cnt - last[idx] << endl;
    //cout << "last idx was: " << idx << endl;
    k -= cnt;
    //cout << "k: " << k << endl;
    //cout << "last[idx]: " << last[idx] << endl;
    k = k % ((ll) cnt - last[idx]);
    //cout << "new k: " << k << endl;
    //cout << "idx before" << idx << endl;
    for (int i = 0; i < k; i++) {
        //cout << "here";
        idx = a[idx];
    }
    cout << idx << endl;
    



    return 0; 
}



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

typedef long long int ll;

int main()
{
	int k,a,b;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	int count=0;
	for(int i=a;i<=b;i++)
		if(i%k==0)
			count++;
	if(count>0)
		printf("OK\n");
	else
		printf("NG\n");
}



Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {


	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k)cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
min_f = 10
for i in range(1, n + 1):
    if i ** 2 > n:
        break
    if n % i != 0:
        continue
    min_seq = max(len(str(i)), len(str(n // i)))
    if min_seq < min_f:
        min_f = min_seq
print(min_f)

Measured memory_bytes: 3064
n,x = map(int,input().split())
l = list(map(int,input().split()))
a =[0]
ans = n+1
for i in range(n):
    s = a[i] + l[i]
    if s > x:
        ans = i+1
        break
    else:
        a.append(s)
print(ans)


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	dump(n - k + 1);
	return 0;
}

Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2019年06月01日 星期六 21时56分56秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000003;
int q, xd, d, n, fac[MOD + 200], ifac[MOD + 200];
int muln(int x, int y) { return 1LL * x * y % MOD; }
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = muln(x, x))
        if(y & 1) ret = muln(ret, x);
    return ret;
}
int inv(int xp) {
    return qpow(xp, MOD - 2);
}

int main() {
    fac[0] = ifac[0] = 1;
    for(int i = 1; i <= MOD; ++i) {
        fac[i] = muln(fac[i - 1], i);
        ifac[i] = inv(fac[i]);
    }

    scanf("%d", &q);
    while(q--) {
        scanf("%d%d%d", &xd, &d, &n);
        if(d == 0) printf("%d\n", qpow(xd, n));
        else {
            if(xd == 0 || n >= MOD) {
                puts("0");
                continue;
            }
            int dp = qpow(d, n), start = muln(xd, inv(d)), end = start + n - 1;
            if(end >= MOD) puts("0");
            else printf("%d\n", muln(fac[end], muln(dp, ifac[start - 1])));
        }
    }
    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll=pair<ll,ll>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) //a/bの除算の切り上げ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = acos(-1);
 
//a^b=b^a
//a^(b^c)=(a^b)^c
//a^a=0
//a+b=a^b + 2(a&b)
//(4a)^(4a+1)^(4a+2)^(4a+3)=0
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_),siz(sz_, 1LL){
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
   }
   void init(ll sz_){
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x){ // 根の検索
      while (par[x]!=x){
           x=par[x]=par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y){
       x=root(x);
       y=root(y);
       if (x==y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x]<siz[y]) swap(x, y);
       siz[x]+=siz[y];
       par[y]=x;
       return true;
  }
 
  bool same(ll x, ll y){ // 連結判定
       return root(x)==root(y);
  }
 
  ll size(ll x){ // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n){
   x=x%mod;
   if(n==0) return 1;
 
   else if(n%2==1){
       return (x*modpow(x, n-1))%mod;
   }
   else return modpow((x*x)%mod, n/2)%mod;
}
 
ll com(ll n, ll k){
   ll x=1;
   for(int i=n-k+1; i<=n; i++){
      x=x*i%mod;
   }
 
   ll y=1;
   for(int i=1; i<=k; i++){
       y=y*i%mod;
   }
   y=modpow(y,mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  }
 
   if(n%2==0 || n%3==0) return false;
 
   for(unsigned i = 5; i*i<=n; i+=6) {
       if(n%i==0) return false;
       if(n%(i+2)==0) return false;
   }
 
   return true;
}
 
int digsum(int n){
   int res=0;
   while(n > 0) {
       res+=n%10; //ここをres++;に変えたら桁数を求める関数になる,res+=n%10;なら格桁の和
       n/=10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i=1; i*i<=n; i++){
       if(n%i==0){
           ret.push_back(i);
           if(i*i!=n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    string s,t;
    cin >> s >> t;
    ll cnt=0;
    ll n=s.size();
    rep(i,n){
        if(s[i]!=t[i]) cnt++;
    }

    cout << cnt << endl;
 
}

Measured memory_bytes: 3852