akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

struct Node {
    parent: u64,
    size: u64,
}

fn findParent(n: u64, nodes: &mut Vec<Node>) -> u64 {
    let p = nodes[n as usize].parent;
    if p == 0 {
        n
    } else {
        let tmp = findParent(p, nodes);
        nodes[n as usize].parent = tmp;
        tmp
    }
}

fn union(a: u64, b: u64, nodes: &mut Vec<Node>) -> u64 {
    let pa = findParent(a, nodes);
    let pb = findParent(b, nodes);
    if pa == pb {
        0
    } else {
        let sa = nodes[pa as usize].size;
        let sb = nodes[pb as usize].size;
        if sa > sb {
            nodes[pb as usize].parent = pa;
            nodes[pa as usize].size = sa + sb;
        } else {
            nodes[pa as usize].parent = pb;
            nodes[pb as usize].size = sa + sb;
        }
        sa * sb
    }
}

fn main() {
    let nm: Vec<u64> = read_vec();
    let n = nm[0];
    let m = nm[1];
    let ab: Vec<Vec<u64>> = read_vec2(m as usize);

    let mut nodes: Vec<Node> = vec![];

    for _ in 0..(n + 1) {
        nodes.push(Node { parent: 0, size: 1 });
    }

    let mut tmp = n * (n - 1) / 2;
    let mut ans: Vec<u64> = vec![n * (n - 1) / 2];

    for i in (0..m as usize).rev() {
        let a = ab[i][0];
        let b = ab[i][1];
        tmp -= union(a, b, &mut nodes);
        ans.push(tmp);
    }

    ans.pop();

    for _ in 0..m {
        println!("{}", ans.pop().unwrap());
    }
}


Measured memory_bytes: 15612
import java.lang.StringBuilder
import java.util.*
import kotlin.collections.ArrayList

val sc = Scanner(System.`in`)
fun nextIntArray() = sc.nextLine().split(" ").map(String::toInt).toTypedArray()

const val INF = 10000000




fun main(args: Array<String>) {

    val N = sc.nextLine().toInt()
    val a = nextIntArray()
    val map = Array(N+1){ArrayList<Int>()}
    val dp = IntArray(N){INF}
    var cnt = 0
    val ans = IntArray(N){0}

    for(i in 0..N-2){
        val u = sc.nextInt()
        val v = sc.nextInt()
        map[u].add(v)
        map[v].add(u)
    }

    val back_idx = IntArray(N+1){-1}
    val back_val = IntArray(N+1){-1}

    val stack = ArrayDeque<Int>(N)
    stack.push(1)
    while(stack.isNotEmpty()){

        var i = stack.pop()

        if(i < 0){
            i = -i
            dp[back_idx[i]] = back_val[i]
            if(back_val[i] == INF) cnt--
            continue
        }

        val s = dp.binarySearch(a[i-1], 0, cnt)
        val idx = if(s < 0) -s-1 else s

        val pre = dp[idx]
        if(pre == INF) cnt++
        dp[idx] = a[i-1]
        ans[i-1] = cnt

        stack.push(-i)
        back_idx[i] = idx
        back_val[i] = pre

        for(j in map[i]){
            if(ans[j-1] == 0) {
                stack.push(j)
            }
        }
    }

    val sb = StringBuilder()
    for(t in ans) sb.append("$t\n")
    println(sb.toString())
}




Measured memory_bytes: 115180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;


int main(){
  int N;
  cin >> N;
  vector<ll> from(N);
  vector<ll> to(N);
  rep(i,N) cin >> from[i];
  rep(i,N) cin >> to[i];
  bool cnr = true;
  rep(i,N){
    if(from[i]!=to[i]) cnr = false;
  }
  if(cnr) { cout << 0 << endl; return 0;}
  ll ans = 0;
  ll okcnt = 0;
  priority_queue<pair<ll,ll>> q;
  rep(i,N) q.push(make_pair(to[i],i));
  while(okcnt!=N){
    pair<ll,ll> now = q.top(); q.pop();
    if(now.first <= 0){ cout << -1 << endl; return 0;}
    if(now.first == from[now.second]) {okcnt++;continue;}
    ll p,m,n;
    p = (now.second+1)%N;
    m = (now.second-1+N)%N;
    n = now.second;
    pair<ll,ll> nxt = make_pair(from[n]+(now.first-from[n])%(to[p]+to[m]),now.second);
    if(now==nxt && now.first != from[n]){ cout << -1 << endl; return 0;}
    to[now.second] -= (to[p]+to[m])*((now.first-from[n])/(to[p]+to[m]));
    q.push(nxt);
    ans+=(now.first-from[n])/(to[p]+to[m]);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

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

  stack<int> S[n];

  rep0(i, q) {
    int query; cin >> query;
    if (query == 0) {
      int t, x; cin >> t >> x;
      S[t].push(x);
    } else if (query == 1) {
      int t; cin >> t;
      if (S[t].size() > 0) cout << S[t].top() << BR;
    } else {
      int t; cin >> t;
      if (S[t].size() > 0) S[t].pop();
    }
  }

  return 0;
}


Measured memory_bytes: 4288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int days = sc.nextInt();
		int numAss= sc.nextInt();
		for(int i = 0 ; i <numAss ;i++) {
			int durationA = sc.nextInt();
			days-=durationA;
		}
		if(days <0) {
			System.out.println("-1");
		}else {
			System.out.println(days);
		}
	}

}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int n;
int k;
int f[M];
int d[M];
int ans = 0;
bool used[M];
vector<int> g[M];

void read() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> f[i];
    --f[i];
  }
}

void dfs(int v) {
  for (int to : g[v]) {
    d[to] = d[v] + 1;
    dfs(to);
  }
}

void udfs(int v) {
  used[v] = true;
  for (int to : g[v])
    if (!used[to]) {
      udfs(to);
    }
}

void kill() {
  if (f[0] != 0) {
    f[0] = 0;
    ++ans;
  }

  for (int i = 1; i < n; ++i)
    g[f[i]].push_back(i);

  dfs(0);

  vector<int> ord;
  for (int i = 1; i < n; ++i)
    ord.push_back(i);

  sort(ord.begin(), ord.end(),
       [](int x, int y) -> bool {
         return d[x] > d[y];
        });

  for (int x : ord)
    if (!used[x]) {
      int y = f[x];
      for (int j = 0; j < k - 1 && y != 0; ++j) {
        x = y, y = f[y];
      }

      if (y == 0)
        break;
      else {
        ++ans;
        udfs(x);
      }
    }

  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 10236
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,C;
  cin  >> A >> B >> C;
  if(A==B)cout << C << endl;
  else if(A==C)cout << B << endl;
  else cout << A << endl;
  return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
a,b,c = N+1,N+1,N+1
dama = 0
count = 0

if Y // N == 10000:
    print(N,0,0)
elif Y // N == 5000:
    print(0,N,0)
elif Y // N == 1000:
    print(0,0,N)
else:
    stop = False
    for i in range(a):
        if stop:
            break
        b -= i
        for j in range(b):
            if stop:
                break
            c -= i+j
            if i+j+c != N:
                pass
            else:
                dama = 10000*i + 5000*j + 1000*c
                if dama == Y:
                    print(i,j,c)
                    count += 1
                    stop = True
                    break
            c = N
        b = N+1
    if count == 0:
        print(-1,-1,-1)

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int at = 0, bt = 0, ct = 0;

    for (int i : p) {
        if (i <= a) at++;
        else if (i <= b) bt++;
        else ct++;
    }

    cout << min({at, bt, ct}) << endl;

}


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

int main() {
 string s; cin >> s;
 vector<char> ans(3);
 for(int i=0;i<=2;i++){
   ans[i]=s[i];
 }
 for(int i=0;i<3;i++){
   cout << ans[i];
 }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string name;
    int n;
    cin>>n;
    cin>>name;
    int i;
    for(i=0;i<name.size();i++)
    {
       cout<<char((name[i]-'A'+n)%26+'A');
    }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  vector<int> xs(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    sum += xs[i];
  }
  
  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int y = sum - xs[i];
    if (y % 10 != 0) {
      UpdateMax(ans, y);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    list<char> A;
    char w;
    string S;
    cin >> S;
    bool flip = 0;
    for(int i = 0; i < S.size(); i++){
        A.push_back(S[i]);
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int b;
        cin >> b;
        if(b == 1){
            flip = !flip;
        }
        if(b == 2){
            int c;
            cin >> c;
            if(flip){
                c = 3 - c;
            }
            if(c == 1){
                cin >> w;
                A.push_front(w);
            }
            else{
                cin >> w;
                A.push_back(w);
            }
        }
        /*if(flip){
            reverse(A.begin(), A.end());
        }
        for(list<char>::iterator it = A.begin(); it != A.end(); it++){
            cout << *it;
        }
        cout << endl;*/
    }
    if(flip){
        reverse(A.begin(), A.end());
    }
    for(list<char>::iterator it = A.begin(); it != A.end(); it++){
        cout << *it;
    }
    cout << endl;
    return 0;
}

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

int main(){
  int H, W;
  
  cin >> H >> W;	//要素数取り込み
  
  /*二次元配列の準備*/
  //vector<vector<char>> A((H+2), vector<char>(W+2));
  char A[H+2][W+2];
  
  /*#の入力*/
  for(int i=0; i<W+2;i++){
   	//A.at[0].at[i] = '#';	//1行目
    //A.at[H+2].at[i] = '#';	//最終行
    A[0][i] = '#';
    A[H+1][i] = '#';
  }
  
  for(int i=1; i<H+1; i++){
    //A.at[i][0] = '#';		//1列目
    //A.at[i][W+2] = '#';		//最終列
    A[i][0] = '#';
    A[i][W+1] = '#';
  }
  
  /*入力の取得*/
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      //cin >> A.at[i+1].at[j+1];
      cin >> A[i][j];
    }
  }
  
  /*出力*/
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
     // cout << A.at[i].at[j];
      cout << A[i][j];
    }
    cout <<endl;
  }
 }
  

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = a[i] - i;
		}
		//メディアン
		Arrays.sort(b);
		long x = b[n / 2];
		
		long res = 0;
		for(int i = 0; i < n; i++) {
			res += Math.max(x - b[i], -x + b[i]); // |a| = max(a, -a)
		}
		out.println(res);
		
		out.close();
	} 

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 27580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String ans = "";
        if ((b - a - 1) % 2 == 1) {
            ans = "Alice";
        } else {
            ans = "Borys";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll n;
    bool flag = true;
    cin>>n;
    vector<int>t(n),x(n),y(n);
    rep(i,n)cin>>t[i]>>x[i]>>y[i];
    if(t[0]<x[0]+y[0])flag = false;
    if(t[0]%2!=(x[0]+y[0])%2)flag = false;
    repi(i,1,n-1){
        if(!flag)break;
        ll diff_x = abs(x[i]-x[i+1]),diff_y = abs(y[i]-y[i+1]),time = abs(t[i]-t[i+1]);
        if(time<diff_x+diff_y)flag = false;
        if(time%2 != (diff_x+diff_y)%2)flag = false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

#----------
N = int(input().strip())
A_list = list(input().strip())
#----------
W_member_sum_0_to_N = [0]*len(A_list)
E_member_sum_N_to_0 = [0]*len(A_list)

cnt=0
for i in range(len(A_list)):
    if A_list[i] == "W":
        cnt += 1
    W_member_sum_0_to_N[i] += cnt

cnt=0
for i in range(len(A_list)-1,-1,-1):
    if A_list[i] == "E":
        cnt += 1
    E_member_sum_N_to_0[i] += cnt
        

count = N
for i_leader in range(len(A_list)):
    if i_leader == 0:
        turn_member = E_member_sum_N_to_0[i_leader+1]
    elif i_leader == len(A_list)-1:
        turn_member = W_member_sum_0_to_N[i_leader-1]
    else:
        turn_member = W_member_sum_0_to_N[i_leader-1] + E_member_sum_N_to_0[i_leader+1]

    if turn_member < count:
        count = turn_member


print(count)


Measured memory_bytes: 29388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string S, T;
    cin >> S >> T;
    int s = S.size()*2;
    S += S;
    rep(i, s) {
        rep(j, s - i) {
            if(S.substr(i,j) == T) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


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

int N;//??°
int W;//?????§???
int v[100], w[100];
int DP[1000][1000] = { 0,0 };

int main()
{
	cin >> N >> W;
	for (int j = 0; j < N ; j++)
	{
		cin >> v[j];
		cin >> w[j];

	}



	for (int i = N - 1; i >= 0; i--)
	{
		for (int j = 0; j<=W; j++)
		{
			if (j < w[i]) {
				DP[i][j] = DP[i + 1][j];//???????????????????????????
			}
			else
			{
				if (DP[i + 1][j] > DP[i + 1][j - w[i]] + v[i])
				{
					DP[i][j] = DP[i + 1][j];
				}
				else
				{
					DP[i][j] =  DP[i + 1][j - w[i]] + v[i];
				}
			}
		}
	}
	cout << DP[0][W] << endl;

	return 0;
}

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

n = int(input())
s = input()

alphabets = "abcdefghijklmnopqrstuvwxyz"

res = 0

for i in range(1, n):

    matches = 0

    s1 = s[:i]
    s2 = s[i:]

    for c in list(alphabets):
        if s1.find(c) != -1 and s2.find(c) != -1:
            matches += 1

    if matches > res: res = matches

print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int N;
    cin >>N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >>A[i]>>B[i];
    ll ans = (B[N-1]-A[N-1]%B[N-1])%B[N-1];
    rep(i,N){
        ans = ans+(B[N-1-i]-(A[N-1-i]+ans)%B[N-1-i])%B[N-1-i];
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; 
#define ll long long  
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define forn(i,n) for(int i = 0; i < int(n); ++i)
#define forni(i,a,b) for(int i=int(a) ; i<=int(b) ; ++i)
#define sz(z) (int)z.size()
#define lb lower_bound
#define ub upper_bound 
#define dbg cout << "yo" << endl  
#define N (ll)5e5+10
#define M (ll)1e6+10 

typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll>> vpll ;
typedef vector<ll> vll ;
typedef vector<char> vch ;
typedef vector<bool> vbl ;

ll lp[M]  ;
void sieve(ll n){
    for(ll i=2 ; i<=n ; i++){
       if(lp[i])continue ;
       for(ll j=i ; j<=n ; j+=i){
           if(!lp[j])lp[j]=i ;
       }
    }
} 

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    
    
   int n ;
   cin >> n ;
   ll sum=1 ;
   sieve(n+1) ;
   for(int i=2 ; i<n ; i++){
       
       ll temp = i ;
       vector<ll>f ;
       while(temp>1){
          int fac = lp[temp] ;
          int cnt = 0 ;
          while(lp[temp]==fac){
              cnt++ ;
              temp = temp/fac ;
          }
          f.pb(cnt+1) ;
       }

       ll ts=1 ;
       for(auto e:f){
        ts*=e ;
       }

       //ts-=1 ;

       sum+=ts ;
   }

   cout << sum ;

    return 0 ;
    
}



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

const int INF = 1001001001;
vector<int> to[2505];
vector<int> rto[2505];
bool reachableF1[2505];
bool reachableTn[2505];
int dist[2505];

void dfs(int i) {
    if (reachableF1[i]) return;
    reachableF1[i] = true;
    for (int t: to[i]) {
        dfs(t);
    }
    return;
}

void rdfs(int i) {
    if (reachableTn[i]) return;
    reachableTn[i] = true;
    for (int t: rto[i]) {
        rdfs(t);
    }
    return;
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<tuple<int, int, int>> edges(m);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; 
        b--;
        c = -(c - p);
        edges[i] = make_tuple(a, b, c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(n-1);
    rep(i, n) dist[i] = INF;
    dist[0] = 0;
    bool update = true;
    int s = 0;
    while (update) {
        update = false;
        rep(i, m) {
            int a, b, c;
            tie(a, b, c) = edges[i];
            if (!reachableTn[a] || !reachableF1[a]) continue;
            if (!reachableTn[b] || !reachableF1[b]) continue;
            if (dist[b] > dist[a] + c) {
                update = true;
                dist[b] = dist[a] + c;
            }
        }
        s++;
        if (s > n) {
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = -dist[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(a <= k){
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }

    if(b <= k){
        b = 0;
    } else {
        b -= k;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int a[212345];
    rep(i, n)
    {
        int z;
        cin >> z;
        a[z]++;
    }
    vector<pair<int, int>> d;
    for (int i = 1; i < 200005; i++)
    {
        if (a[i] > 0)
            d.push_back(make_pair(a[i], i));
    }
    sort(d.begin(), d.end());
    int res = 0;
    for (int i = 0; i < (int)d.size() - k; i++)
    {
        res += d[i].first;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
import java.util.concurrent.TimeUnit;

public class Main {
	
	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	    
	    int N = Integer.parseInt(f.readLine());
	    
	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int[] storage = new int[N];
	    long sum = 0;
	    for(int i = 0; i < N; i++) {
	    	int x = Integer.parseInt(st.nextToken())*2;
	    	if(i % 2 == 0) {
	    		sum += x;
	    	} else {
	    		sum -= x;
	    	}
	    	storage[i] = x;
	    }
	    //System.out.println(Arrays.toString(storage));
	    
	    long[] answers = new long[N];
	    answers[0] = sum / 2;
	    for(int i = 1; i < N; i++) {
	    	answers[i] = (storage[i-1] - answers[i-1]);
	    }
	    
	    System.out.print(answers[0]);
	    for(int i = 1; i < answers.length; i++) {
	    	System.out.print(" " + answers[i]);
	    }
	    System.out.println();
	    
	    
	    out.close();
	    f.close();
	}
	
}

Measured memory_bytes: 49112
main()
{
	long long n,l,r,k,res=0;
	scanf("%lld",&n);
	for(l=1;l<=n;l=r+1)
		k=n/l,r=n/k,res+=(l<=n/k-1&&n/k-1<=r&&n/k*k==n)?(n/k-1):0;
	printf("%lld\n",res);
}

Measured memory_bytes: 1700
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline int toInt(string s){
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T> inline string toString(T x){
    ostringstream sout;
    sout << x;
    return sout.str();
}

int main(void){

    int n, p;
    cin >> n >> p;

    int a[n];
    int odd = 0;
    FOR(i,0,n){
        cin >> a[i];
        if(a[i]%2!=0)odd++;
    }

    ull ans = 0;

    if(odd==0){
        if(p==0)ans = pow(2, n);
        else ans = 0;

    }else ans = pow(2, n-1);

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


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  int x;
  cin >> x;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      if (i*i*i*i*i - j*j*j*j*j == x) {
        cout << i << " " << j;
        rtn 0;
      }
    }
  }
  rtn 0;
}


Measured memory_bytes: 3644
N = int(input())
lst = input().split()

for i in range(N):
   lst[i] = int(lst[i])
lst.sort(reverse=True)

Alice = 0
Bob = 0

for i in range(N // 2):
   Alice += lst[2 * i]
   Bob += lst[(2 * i) + 1]

if N % 2 == 1:
   Alice += lst[-1]

print(Alice - Bob)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

long long n, k, mZero = 0/*(mod k) = k/2*/, mHalf/*(mod k) = k/2*/, ans = 0;

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

	if (k == 2) {
		mZero = n / k;
		ans += mZero * mZero * mZero;

		mHalf = (n + 1) / 2;
		ans += mHalf * mHalf * mHalf;
	}
	else {
		mZero = n / k;
		ans += mZero * mZero * mZero;

		if (k % 2 == 0) {
			mHalf = n / k;
			if (n%k >= k / 2) {
				mHalf++;
			}
			ans += mHalf * mHalf * mHalf;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
	int n,m;
	scanf("%2d%2d",&n,&m);
	bool fi=(1<=n && n<=12);
	bool se=(1<=m && m<=12);
	
	if(fi){
		if(se){
			cout<<"AMBIGUOUS"<<endl;
		}else{
			cout<<"MMYY"<<endl;
		}
	}else{
		if(se){
			cout<<"YYMM"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mul2(long long z)
  {
    long long s=0;
    while(z%2==0){s++; z/=2;}
    return s;
  }
int main(){
  int n,m; cin >>n >>m; long long lmul=1; 
  vector<long long>v(n);
  
  for(int i=0; i<n; i++)
  {
    cin >>v[i]; v[i]/=2;
    long long cnt=mul2(v[0]);
    if(mul2(v[i])!=cnt){cout <<0; return 0;}
    else lmul=lmul*v[i]/__gcd(lmul,v[i]);
  }
cout <<(m/lmul+1)/2;
return 0;}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007


int N, M;
P ab[123456];

signed main(){

	cin >> N >> M;
	for (int i = 0; i < M; i++)
		cin >> ab[i].first >> ab[i].second;

	// b[i]について昇順にsort
	sort(ab, ab + M, [](P&a, P&b){return a.second < b.second; });

	int ans = 0;
	int right = 0;
	for (int i = 0; i < M; i++){
		if (ab[i].first < right) continue;
		right = ab[i].second;
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      int a = int.Parse(Console.ReadLine());
      bool flag = false;
      
      for (int i=0;i<=a;i++)
      {
        if ((n-i)%500==0)
        {
          flag=true;
        }
      }
      if (flag)
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }
    }
}


Measured memory_bytes: 27440
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vbool wr(n, false);
    rep(i, n) {
        int p;
        cin >> p;
        wr[i] = (p == i+1);
    }
    int ans = 0;
    rep(i, n-1) {
        if (wr[i]) {
            ans++;
            wr[i+1] = false;
        } 
    }
    if (wr[n-1]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

typedef long long ll;
#define INF 1e18

const ll MOD=1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll comb(ll n, ll r){
	ll ans=1;
	REP(i,r){
		ans=(ans*(n-i))%MOD;
		ans=ans*modinv(i+1,MOD);
		ans%=MOD;
	}
	return ans;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
	ll n; cin>>n;
	ll a; cin>>a;
	ll b; cin>>b;
	ll ans=modpow(2,n)-1;
	ans=(ans+MOD-comb(n,a))%MOD;
	//cout<<comb(n,a)<<endl;
	ans=(ans+MOD-comb(n,b))%MOD;
	//cout<<comb(n,b)<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.numeric;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  long n, p;
  cin.scan(n, p);

  if (p == 1) {
    writeln(1);
    return;
  }
  if (n == 1) {
    writeln(p);
    return;
  }

  auto prime = (long n) {
    if (n == 1)
      return 1;
    if (n % 2 == 0)
      return 2;
    for (long i = 3; i * i <= n; i += 2) {
      if (n % i == 0) return i;
    }
    return n;
  };

  int[long] m;
  while (p != 1) {
    auto i = prime(p);
    p /= i;
    m[i]++;
  }

  long ret = 1;
  foreach (key, value; m) {
    ret *= key ^^ (value / n);
  }

  writeln(ret);
}


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



int main(){ 
    int n; cin >> n;
    int res = -1;
    rept(i, 1, 50001){
        int num = i*1.08;
        if(num==n)res = i;
    }
    if(res==-1)cout << ":(" << ln;
    else cout << res << ln;
}



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

int main() {
  int N;
  cin >> N;
  int ans = 1, M = 0;
  cin >> M;
  for (int i = 0; i < N - 1; i++) {
    int tmp;
    cin >> tmp;
    if (tmp >= M) ans++;
    M = max(M, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
from collections import deque
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
	b, m, e = map(int, input().split())
	s = a[b:e]
	a = a[:b] + s[m-b:] + s[:m-b] + a[e:]
print(*a)



Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
    int a;
    cin>>a;
    if (a>=30)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

typedef struct _node
{
	struct _node *next;
	int v;
} Node;
void set_node(Node *x, Node *_next, int _v)
{
	x->next = _next;
	x->v = _v;
}

int main(int argc, char const *argv[])
{
	Node p[1024];
	int size;
	int n, m;

	while (scanf("%d %d", &n, &m), n){
		Node *cur, *prev;
		int i;
		for (i = 0; i < n - 1; i++){
			set_node(p + i, p + i + 1, i + 1); 
		}
		set_node(p + n - 1, p, n);
		
		size = n;
		cur = p + n - 1;
		while (size > 1){
			int j;
			for (j = 0; j < m; j++){
				prev = cur;
				cur = cur->next;
			}
			prev->next = cur->next;
			size--;
		}
		printf("%d\n", cur->next->v);
	}

	return (0);
}

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

int main(int argc, char *argv[]) {
  int x;
  std::cin >> x;
  if (x == 1) {
    std::cout << 1 << std::endl;
    return 0;
  }
  int max = 0;
  for (int i = 2; i < sqrt(x); ++i) {
    int j = i;
    while (j <= x) {
      max = std::max (j,max);
      if (j == x) {
        std::cout << j << std::endl;
        return 0;
      }
      j *= i;
    }
  }
  std::cout << max << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int n = c.length;
		boolean swi = false;
		char[] a = new char[n];
		char[] b = new char[n];
		for (int i = 0; i < n; i++, swi = !swi) {
			a[i] = swi ? '1' : '0';
			b[i] = swi ? '0' : '1';
		}
		int countA = 0;
		int countB = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] != a[i])
				countA++;
		}
		for (int i = 0; i < n; i++) {
			if (c[i] != b[i])
				countB++;
		}
		System.out.println(Math.min(countA, countB));

	}

}


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

int main() {
    int n;cin>>n;
    int b[n-1],a[n];
    for (int i=0;i<n-1;i++)
        cin>>b[i];
    a[0]=b[0];
    for (int i=0;i<n-1;i++) {
        a[i]=min(a[i],b[i]);
        a[i+1]=b[i];
    }
    int ans=0;
    for (int i=0;i<n;i++)
        ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k,ans=0;
  cin>>n>>k;
  if(k==0)cout<<n*n<<endl;
  else{
    for(int i=1;i<n;i++){
      if(i>=k)ans+=n-i;
      if(i>k){
	ans+=(i-k)*((n/i)-1);
	ans+=max(0LL,(n-(i*(n/i))+1)-k);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"


int main() {
	while (1) {
		vector<int>ps(8), cs{ 1,4,1,4,1,2,1,2 };
		for (int i = 0; i < 8; ++i) {
			if (!(cin >> ps[i])) {
				return 0;
			}
		}
		int ride_max = -1;
		vector<int>ans;
		for (int off = 0; off < 8; ++off) {
			rotate(cs.begin(), cs.begin() + off, cs.end());
			int canride = 0;
			for (int i = 0; i < 8; ++i) {
				canride += max(0, min(cs[i], ps[i]));
			}
			if (canride > ride_max) {

				ride_max = canride;
				ans = cs;
			}
			else if (canride == ride_max) {
				bool ok = false;
				for (int i = 0; i < 8; ++i) {
					if (ans[i] > cs[i]) {
						ok = true;
						break;
					}
					else if (ans[i] < cs[i]) {
						ok = false;
						break;
					}
					else {
						continue;
					}
				}
				if (ok) {
					ride_max = canride;
					ans = cs;
				}
			}
			rotate(cs.begin(), cs.begin() + 8 - off, cs.end());
		}
		for (int i = 0; i < 8; ++i) {
			cout << ans[i];
			if (i == 7)cout << endl;
			else cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 3156
import java.util.ArrayList;
import java.util.Scanner;

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

    void solve(){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        


        ArrayList<String> list = new ArrayList<String>();
        for(int i =0; i<a.length();i++){
            String b = String.valueOf(a.charAt(i));
            list.add(b);
        }
        

        boolean threefour = false;

        if(list.get(2).equals(list.get(3))){
            threefour = true;
        }

        boolean fivesix = false;

        if(list.get(4).equals(list.get(5))){
            fivesix = true;
        }

        sc.close();

        if(threefour && fivesix){
            System.out.println("Yes");

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




    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,b=0,cnt=0;
  cin >>N;
  vector<int> vec(N);
  
  for(int i=0;i<N; i++){
    cin >> vec.at(i);
    vec.at(i)--;
  }
  for(int j=0; j<N; j++){
    if(vec.at(b)==1){
      cnt++;
      break;
    }
    else{
      b = vec.at(b);
      cnt++;
    }
  }
  if(vec.at(b)==1)
    cout <<cnt <<endl;
  else
    cout <<-1 <<endl;
}


Measured memory_bytes: 640
def main():
    S = input()
    stack = []
    count = 0
    for i in range(len(S)):
        if not stack:
            stack.append(S[i])
        else:
            if stack[-1] != S[i]:
                stack.pop()
                count += 2
            else:
                stack.append(S[i])
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3956
while True:
    m,f,r=map(int,input().split())
    if m==f and f==r and m==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f>=65:
        print("B")
    elif m+f>=50:
        print("C")
    elif m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int f(int a){
  if(a==1) return 2;
  if(a==2||a==3||a==5) return 5;
  if(a==4) return 4;
  if(a==6||a==9) return 6;
  if(a==7) return 3;
  if(a==8) return 7;
}

int g(string s,string t){
  if(s.size()!=t.size()) return s.size()-t.size();
  if(s==t) return 0;

  rep(i,s.size()){
    if(s[i]!=t[i]) return s[i]-t[i];
  }
}

signed main(){
  init();
  int n,m;
  string dp[11000]={};
  bool dpa[11000]={};
  int a[10];
  cin>>n>>m;
  rep(i,m){
    cin>>a[i];
  }
  dpa[0]=true;

  rep(i,n+1){
    string u = dp[i];
    rep(j,m){
      int b = f(a[j]);
      if(!dpa[i]) continue;
      char c = a[j]+'0';
      string s = u+c;
      if(g(dp[i+b],s)<0){
        dp[i+b] = s;
        dpa[i+b] = true;
      }
    }

  }

  cout<<dp[n]<<endl;
}


Measured memory_bytes: 45568