akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, K, sum[1010][1010][2];

signed main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        int a, b;
        char c;
        cin >> a >> b >> c;
        if(c == 'W'){
            if((a / K + b / K) % 2 == 1){
                sum[a % K][b % K][1]++;
            }
            else{
                sum[a % K][b % K][0]++;
            }
        }
        else {
            if((a / K + b / K) % 2 == 1){
                sum[a % K][b % K][0]++;
            }
            else{
                sum[a % K][b % K][1]++;
            }
        }
    }
    for(int i = 0; i < K; i++){
        for(int j = 0; j < K; j++){
            if(j == 0)continue;
            sum[i][j][0] += sum[i][j - 1][0];
            sum[i][j][1] += sum[i][j - 1][1];
        }
    }
    for(int i = 0; i < K; i++){
        for(int j = 0; j < K; j++){
            if(j == 0)continue;
            sum[j][i][0] += sum[j - 1][i][0];
            sum[j][i][1] += sum[j - 1][i][1];
        }
    }
    int ans = 0;
    for(int i = 0; i < K; i++){
        for(int j = 0; j < K; j++){
            ans = max(ans, sum[i][j][0] * 2 + sum[K - 1][K - 1][0] - sum[K - 1][j][0] - sum[i][K - 1][0] + sum[K - 1][j][1] + sum[i][K - 1][1] - sum[i][j][1] * 2);
            ans = max(ans, sum[i][j][1] * 2 + sum[K - 1][K - 1][1] - sum[K - 1][j][1] - sum[i][K - 1][1] + sum[K - 1][j][0] + sum[i][K - 1][0] - sum[i][j][0] * 2);
        }
    }
    cout << ans << endl;

    return 0;
}

/*



*/


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
bool vis[2020202];
vector<long long>v;
int main()
{
	for(int i=2;i<=1e6+1e5;i++)
	{
		if(!vis[i])
		{
			v.push_back(i);
			for(int j=i+i;j<=1e6+1e5;j+=i)
			{
				vis[j]=true;
			}
		}
	}
	long long n;
	cin>>n;
	if(n==1)
	{
		cout<<1<<endl;
		return 0;
	}
	long long m=n-1,ans=1;
	for(int i=0;i<v.size();i++)
	{
		long long x=v[i],cnt=0;
		while(m%x==0)
		{
			m/=x;
			cnt++;
		}
		ans*=(cnt+1);
	}
	if(m!=1)
	{
		ans*=2;
	}
	ans--;
	long long as=0;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			long long x=i,y=n/i,z1=n,z2=n;
			if(x!=1)
			{
				while(z1%x==0)
				{
					z1/=x;
				}
				if(z1%x==1)
				{
					as++;
				}
			}
			if(y!=1 && x!=y)
			{
				while(z2%y==0)
				{
					z2/=y;
				}
				if(z2%y==1)
				{
					as++;
				}
			}
		}
	}
	cout<<ans+as<<endl;
	return 0;
}

Measured memory_bytes: 2424
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		final int N = 1000000;
		int n = sc.nextInt();
		int q = sc.nextInt();
		int sqrtn = (int)Math.sqrt(N);
		
		int backet[] = new int[sqrtn+1];
		int content[] = new int[N];
		
		for(int qq = 0; qq < q; ++qq){
			int a = sc.nextInt();
			int v = sc.nextInt();
			--a;
			
			content[a] += v;
			int maxi = Integer.MIN_VALUE;
			for(int i = 0; i < sqrtn; ++i){
				maxi = Math.max(maxi, content[sqrtn * (a/sqrtn) + i]);
			}
			backet[a/sqrtn] = maxi;

			int ind = -1;
			maxi = Integer.MIN_VALUE;
			for(int i = 0; i < sqrtn+1; ++i){
				if( maxi < backet[i] ){
					ind = i;
					maxi = backet[i];
				}
			}
			
			for(int i = 0; i < sqrtn; ++i){
				if( maxi == content[sqrtn * ind + i] ) {
					ind = sqrtn * ind + i;
					break;
				}
			}
			
			System.out.println(1+ind + " " + maxi);
		
		}
	}
}

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

int m, n;
int ma[300];
vector<int> g[300];
bool go[300], ba[300];

void iki(int x)
{


	int i;

	if (go[x]) return;
	go[x] = true;				//????????°??????
	if (x == n + 1) return;
	for (i = 1; i <= m; i++)
	{
		int y = x + i;
		if (y <= n + 1)
		{
			y = y + ma[y];
			if (y>0)
			{
				if (y > n + 1) y = n + 1;

				g[y].push_back(x);
				iki(y);
			}
		}

	}
	return;
}

void kae(int x)
{

	int i;
	if (ba[x]) return;
	ba[x] = true;
	if (x == 0) return;
	for (i = 0; i<g[x].size(); i++)
	{
		kae(g[x][i]);
	}
	return;
}

int main()
{
	int i;
	while (cin >> m, m)
	{
		cin >> n;

		//---------------?????????--------------------//
		for (i = 0; i<300; i++)
		{
			g[i].clear();
			ma[i] = 0;
		}
		memset(go, 0, sizeof(go));
		memset(ba, 0, sizeof(ba));


		for (i = 1; i <= n; i++)
		{
			cin >> ma[i];
		}
		ma[0] = ma[n + 1] = 0;

		iki(0);
		kae(n + 1);


		for (i = 0; i <= n + 1; i++)
		{
			if (go[i])
			{
				if (ba[i] == 0)
				{
					cout << "NG\n";
					break;
				}
			}
			if (i == n + 1) cout << "OK\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3144
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
	int h, w, a, b; 
	cin >> h >> w >> a >> b;
	/*
	h行w列

    行 : {a or (w-a)} * h = a(h-i) + (w-a)i
    列 : {b or (h-b)} * w = b(w-j) + (h-b)j
    
    ah + (w-2a)i = bw + (h-2b)j
    
    i = b, j = a
    */

    rep(i, h){
        rep(j, w){
            if((i < b && j < a) || (i >= b && j >= a)){
                cout << 0;
            }else{
                cout << 1;
            }
        }
        cout << endl;
    }
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(){
	int a,b;
	char c;
	while(1){
	cin >> a >> c >> b;
	if 	   (c == '+')cout << a + b << endl;
	else if(c == '-')cout << a - b << endl;
	else if(c == '*')cout << a * b << endl;
	else if(c == '/')cout << a / b << endl;
	else if(c == '?')break;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=1e7+1, oo = 1e9;
const int mod = oo+7;
const ll  OO = 3e18;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int > v;
    while(n){
        if(n%10==1)v.push_back(9);
        else v.push_back(1);
        n/=10;
    }
    reverse(v.begin(),v.end());
    for(auto e:v)cout<<e;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	for(int i=0;i<=25;i++){
		for(int j=0;j<=14;j++){
			if(!(N-4*i-7*j)){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int h, w;
    cin >> h >> w;
    vvi b(h, vi(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if (c == '#') b[i][j] = 1;
        }
    }

    vvi visited(h, vi(w));
    using ii = pair<int, int>;
    queue<ii> que;
    i64 ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (!visited[i][j]) {
                visited[i][j] = 1;
                que.push(ii(i, j));
                i64 black = 0, white = 0;
                int dx[] = {-1, 1, 0, 0};
                int dy[] = {0, 0, -1, 1};
                while (que.size()) {
                    ii t = que.front();
                    que.pop();
                    if (b[t.first][t.second]) {
                        black++;
                    } else {
                        white++;
                    }
                    for (int k = 0; k < 4; k++) {
                        int x = t.first + dx[k];
                        int y = t.second + dy[k];
                        if (0 <= x && x < h && 0 <= y && y < w && !visited[x][y] && b[x][y] != b[t.first][t.second]) {
                            visited[x][y] = 1;
                            que.push(ii(x, y));
                        }
                    }
                }
                ans += black * white;
            }
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define endl "\n"
#define mod 1000000007

vector <ll> ad[200006];
vector <ll> vis(200006,0);

ll ans=0, n, m, k;


void add(ll x, ll y){
    ad[x].push_back(y);
    ad[y].push_back(x);
}

ll dfs(ll node){
    vis[node]=1;
    ++ans;
    for(ll i:ad[node]){
        if(!vis[i])
            dfs(i);
    }
    return ans;
}

void solve(){
    cin>>n;
   ll a;
   ll sum=0,ans=0;
   for(ll i=0;i<n;i++){
    cin>>a;
   if(i){
    ans=(ans+((sum*a)%mod))%mod;
   }
    sum=(sum+a)%mod;
   }
   cout<<ans<<endl;


}

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

Measured memory_bytes: 9428
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s,t;

int main(){
	cin>>n>>s>>t;
	ll res;
	vi a;
	for(int i=0;i<n;i++){
		if(s[i]==t[i]) a.push_back(0);
		else{
			a.push_back(1);
			i++;
		}
	}
	int A=a.size();
	if(a[0]) res=6;
	else res=3;
	for(int i=1;i<A;i++){
		if(a[i-1]&&a[i]) (res*=3)%=mod;
		if(!a[i-1]&&a[i]) (res*=2)%=mod;
		if(!a[i-1]&&!a[i]) (res*=2)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
using   ll=long long;
using   ld=long double;
 
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define int            long long 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define ff              first
#define ss              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323

void solve()
{
	ll n,m;
	
	cin>>n>>m;
	
	if(m==n)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

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

int main(void){
  int N,L;
  string s[110];
  cin >> N >>L;
  for(int i=0;i<N;i++) cin >> s[i];
  sort(s,s+N);
  for(int i=0;i<N;i++) cout << s[i];
  return 0;
}

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

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int x = sx; x < tx; x++) cout << "R";
    for (int y = sy; y < ty; y++) cout << "U";
    for (int x = sx; x < tx; x++) cout << "L";
    for (int y = sy; y < ty; y++) cout << "D";
    cout << "D";
    for (int x = sx; x < tx + 1; x++) cout << "R";
    for (int y = sy - 1; y < ty; y++) cout << "U";
    cout << "LU";
    for (int x = sx - 1; x < tx; x++) cout << "L";
    for (int y = sy; y < ty + 1; y++) cout << "D";
    cout << "R";
    
    return 0;
}


Measured memory_bytes: 256
"""
print a b: strの a 文字目から b 文字目までを出力する。
reverse a b: strの a 文字目から b 文字目までを逆順にする。
replace a b p: st の a 文字目から b 文字目までを p に置き換える
"""
s = str(input())
n_order = int(input())
# print(s)

for _ in range(n_order):
    list_order = [i for i in input().split(" ")]
    order = list_order[0]
    a = int(list_order[1])
    b = int(list_order[2])

    if order == 'print':
        s_a2b = s[a : b + 1]
        print(s_a2b)
    elif order == 'reverse':
        s_a2b = s[a : b + 1]
        s_a2b_rev = s_a2b[::-1]
        s = s[:a] + s_a2b_rev + s[b + 1:]
        # print("->",s)
    elif order == 'replace':
        p = str(list_order[3])
        s = s[:a] + p + s[b + 1:]
        # print("->", s)
    else:
        print("error")
        
    



Measured memory_bytes: 5628
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        Integer A = sc.nextInt();
        Integer B = sc.nextInt();
        Integer C = sc.nextInt();
        Integer K = sc.nextInt();

        int count = K;
        int rst = 0;

        // A 
        rst += Math.min(count, A);
        count = Math.max(0, count - A);

        // B 
        count = Math.max(0, count - B);

        // C 
        rst -= Math.min(count, C);
        count = Math.max(0, count - C);

        System.out.println(rst);
    }
}

Measured memory_bytes: 35752
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    ll N;
    cin >> N;
    ll sum = 0;
    map<ll, ll> m;
    REP (i, N) {
        ll a;
        cin >> a;
        m[a]++;
        sum += a;
    }

    ll Q;
    cin >> Q;
    vector<ll> ans(Q);
    REP (i, Q) {
        ll b, c;
        cin >> b >> c;
        sum += c * m[b] - b * m[b];
        m[c] += m[b];
        m[b] = 0;
        ans[i] = sum;
    }

    REP (i, Q) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int mx=0;
	int mn=999999999;
	int n;
	cin>>n;
	while(n--)
	{
		int a;
		cin>>a;
		mx=max(a,mx);
		mn=min(a,mn);
	}
	cout<<abs(mx-mn)<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(map(int, input().split()))

cb = []
for _ in range(m):
    b,c = map(int, input().split())
    cb.append([c, b])

a.sort()
cb.sort()

now = 0
finish = False
for i in range(m):
    b = cb[m - 1 - i][1]
    c = cb[m - 1 - i][0]
    for j in range(b):
        if now < n and a[now] < c:
            a[now] = c
            now += 1
        else:
            finish = True
            break
    if finish:
        break

print(sum(a))

Measured memory_bytes: 76440
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"
 
//ポップカウントの計算
int pcnt(int x){ 
    return __builtin_popcount(x);  //2進数の1の数を数えす
}

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

int main(){
    ll a;
    cin >> a;
    string b;
    cin >> b;
    ll nb = (ll)changeDoubleToInt(b);
    a *= nb;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;


int color_num;
vector<char> used;
map<pair<int, int>, int> color;
vector<vector<int>> g;

void dfs(int v, int from_color) {
    used[v] = 1;
    int cur_color = 1;
    for (auto to : g[v]) if (!used[to]) {
        if (cur_color == from_color) ++cur_color;
        color[{v, to}] = cur_color;
        color[{to, v}] = cur_color;
        dfs(to, cur_color);
        ++cur_color;
    }
}


int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());
    auto start = clock();


    int n; cin >> n;
    map<int, int> cnt;
    used.assign(n, 0);
    g.assign(n, vector<int>());
    vector<pair<int, int>> edges;
    int maxi = 0;
    for (int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        edges.pb({a - 1, b - 1});
        cnt[a - 1]++;
        cnt[b - 1]++;
        maxi = max(cnt[a - 1], maxi);
        maxi = max(cnt[b - 1], maxi);
        g[a - 1].pb(b - 1);
        g[b - 1].pb(a - 1);
    }
    cout << maxi << endl;
    color_num = maxi;
    dfs(0, -1);
    for (auto c : edges) {
        cout << color[c] << endl;
    }


    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 24052
n, m, l = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

B = []
for i in range(m):
    B.append(list(map(int, input().split())))

C = []
for i in range(n):
    c = []
    for j in range(l):
        b_row = [b[j] for b in B]
        c.append(sum([ a * b for a, b in zip(A[i], b_row)]))
    C.append(c)

for c in C:
    print(" ".join(map(str, c)))


Measured memory_bytes: 6848
# 56

# from collections import deque
import heapq

v, e, r = map(int, input().split())

# g_m = [[float("INF")] * v for _ in range(v)]
g_l = [[] for _ in range(v)]

for i in range(e):
    _s, _t, _d = map(int, input().split())
#     g_m[_s][_t] = _d
    g_l[_s].append([_t,_d])

def djkstra(s):
    ans_l = [float("INF")] * v
    _l = [[0,s]]
    heapq.heapify(_l)
    while len(_l) > 0:
        _c, _v = heapq.heappop(_l)
        if ans_l[_v] < _c:
            continue
        ans_l[_v] = _c
        for _t, _d in g_l[_v]:
            if ans_l[_t] > _c + _d:
                heapq.heappush(_l,[_c + _d, _t])
    return ans_l

ans_l = djkstra(r)
for i in range(v):
    print(str(ans_l[i]).upper())


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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> ws(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ws[i];
	}
	int ans = INT_MAX;
	for (int i = 0; i < n; i++)
	{
		int res1 = 0, res2 = 0;
		for (int j = 0; j < n; j++)
		{
			if (j <= i)
			{
				res1 += ws[j];
			}
			else
			{
				res2 += ws[j];
			}
		}
		ans = min(ans, abs(res1 - res2));
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

using namespace std;

vector<int> G[100000];
vector<int> b[100000];

int dfs(int n){
    int N = G[n].size();
    if(N == 0) return 1;
    int m = 0;

    for(int i = 0; i < N; i++){
        b[n].push_back(dfs(G[n][i]));
    }
    sort(b[n].begin(), b[n].end(), greater<int>());
    for(int i = 0; i < N; i++){
        m = max(m, b[n][i]+i+1);
    }
    return m;
}

int main(){
    int N;
    int a[100000];
    cin >> N;
    for(int i = 1; i < N; i++){
        cin >> a[i];
        a[i]--;
        G[a[i]].push_back(i);
    }
    cout << dfs(0)-1 << endl;
}

Measured memory_bytes: 20992
# include <bits/stdc++.h>
using namespace std;
long long n,n1,k1,k2,n2,ans,a[1005][1005],ans1;
int main()
{
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		n1=i;
		k1=n1%10;
		while (n1>0)
		{
			n2=n1%10;
			n1/=10;
		}
		
		
		a[k1][n2]++;
		//cout<<n2<<" "<<k1<<" "<<a[n2][k1]<<endl;
		//cout<<ans1<<endl;
		ans+=a[n2][k1];
	}
//	cout<<ans1<<endl;
	for (int i=0; i<=9; i++)
	{
		for (int j=0; j<=9; j++)
		{
			ans1+=a[i][j]*a[j][i];
		}
	}
	cout<<ans1<<endl;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long prev{1000};
    unsigned long nowmoney{1000}, nowstock{0}, ans{1000};
    bool increasing{false};
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        if(increasing){
            if(prev > a){
                nowmoney += prev * nowstock;
                nowstock = 0;
                increasing ^= 1;
            }
        }else{
            if(prev < a){
                nowstock += nowmoney / prev;
                nowmoney %= prev;
                increasing ^= 1;
            }
        }
        prev = a;
        ans = max(ans, nowmoney + nowstock * a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef long long ll;

int a, b, c;

int main(){
    scanf("%d%d%d", &a, &b, &c);
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        printf("0\n");
        return 0;
    }
    if(a < b) swap(a, b);
    if(a < c) swap(a, c);
    printf("%lld\n", (ll)b * (ll)c);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long n,i;
    string s;
    cin>>n>>s;
    for(i=0;i<s.size();i++)
    {
        s[i]=s[i]+n;
        if(s[i]>'Z')
        {
            s[i]-=n;
            s[i]-=(26-n);
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3672
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
a,b,c,d = neo()
print(max(max(a,b)*max(c,d),min(a,b)*max(c,d),max(a,b)*min(c,d),min(a,b)*min(c,d)))


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> v(n);
    REP(i, n) v[i] = i + 1;
    vector<int> p(n), q(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];

    int count = 0, p_i, q_i;
    do {
        count++;
        bool f = true;

        for (int i = 0; i < n; i++)
            if (p[i] != v[i]) {
                f = false;
                break;
            }
        if (f) p_i = count;

        f = true;
        for (int i = 0; i < n; i++)
            if (q[i] != v[i]) {
                f = false;
                break;
            }
        if (f) q_i = count;

    } while(next_permutation(v.begin(), v.end()));
    cout << abs(p_i - q_i) << endl;
}


Measured memory_bytes: 256
import math

A,B=map(int,input().split())
ans=-1
cnt=math.floor(A/0.08)
for i in range(cnt,1001):
  X8=math.floor(i*0.08)
  X10=math.floor(i*0.1)
  if X8 == A and X10 == B :
    ans=i
    break
print(ans)

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

	int
main (void)
{
	while (1)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		int rec = h * h + w * w;
		// 縦横MAX
		int max = 150 * 150;

		// answer 
		int ans_h, ans_w;
		// 対角線が等しい時の答えを見つけたフラグ
		bool flag = false;

		// tate
		for (int t = 1; t < 150; t++)
		{
			// wide
			for (int y = 1; y < 150; y++)
			{
#ifdef D
				if (t == 1 && y == 8)
				{
					cout << "when t == 1 && y == 8" << endl;
					cout << "t:" << t << endl;
					cout << "y:" << y << endl;
					cout << y*y + t*t << endl;
				}
#endif
				// height < wide より
				if (t < y)
				{
					// 対角線
					int tai = y * y + t * t;
					// rec より大きいが，max よりは小さい時
					if (rec < tai && tai < max)
					{
#ifdef D
						cout << "t:" << t << endl;
						cout << "y:" << y << endl;
						cout << "rec:" << rec << endl;
						cout << "tai:" << tai << endl;
						cout << "max:" << max << endl;
#endif
						max = tai;
						ans_h = t;
						ans_w = y;
					}
					// rec と等しい時
					else if (rec == tai)
					{
						// 対角線が等しい時は，h < t が必要
						if (h < t)
						{
#ifdef D
							cout << "t:" << t << endl;
							cout << "y:" << y << endl;
							cout << "rec:" << rec << endl;
							cout << "tai:" << tai << endl;
							cout << "max:" << max << endl;
#endif
							max = tai;
							ans_h = t;
							ans_w = y;
							flag = true;
						}
					}
				}
			}
			if (flag)
				break;
		}
		cout << ans_h << " " << ans_w << endl;
	}
	return 0;
}




Measured memory_bytes: 3096
a, b, c = gets.split(" ").map(&:to_i)
k = gets.to_i
cnt = 0
while a >= b
  b *= 2
  cnt += 1
end
while b >= c
  c *= 2
  cnt += 1
end
if cnt <= k
  puts "Yes"
else
  puts "No"
end

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

int main() {
    int n, swapNum = 0, flag = 1, temp;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        v.push_back(temp);
    }
    while (flag) {
        flag = 0;
        for (int j = n-1; j >= 1; j--) {
            if (v[j] < v[j-1]) {
                swap(v[j], v[j-1]);
                flag = 1;
                swapNum++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
            cout << v[i];
            if (i != n-1) cout << " ";
    }
    cout << endl << swapNum << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long;

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

	string ans = "Yes";
	for (int i = 1; i <= S.size(); ++i) {
		if (i % 2 == 0) {
			if (S[i-1] == 'R') {
				ans = "No";
				break;
			}
		}
		else {
			if (S[i-1] == 'L') {
				ans = "No";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int card[4][13];
    for(int i = 0; i < 13; i++){
        card[0][i] = 0;
        card[1][i] = 0;
        card[2][i] = 0;
        card[3][i] = 0;
    }

    for(int i = 0; i < n; i++){
        int num;
        char ch;
        cin >> ch >> num;
        num--;
        if(ch == 'S'){
            card[0][num] = 1;
        }
        else if(ch == 'H'){
            card[1][num] = 1;
        }
        else if(ch == 'C'){
            card[2][num] = 1;
        }
        else if(ch == 'D'){
            card[3][num] = 1;
        }
    }

    char list[4] = {'S', 'H', 'C', 'D'};
    for(int i = 0; i < 4; i++){
        char s = list[i];
        for(int j = 0; j < 13; j++){
            if(card[i][j] == 0){
                cout << s << " " << j+1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3100
# nCk ( O(N) )
N_MAX = 10**6
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


n,m,k = map(int, input().split())
com_init()

ans = 0
for dist in range(1,m):
    comb = (m-dist)*n*n
    other_comb = com(n*m-2,k-2)
    ans += comb*other_comb*dist
    ans %= MOD

for dist in range(1,n):
    comb = (n-dist)*m*m
    other_comb = com(n*m-2,k-2)
    ans += comb*other_comb*dist
    ans %= MOD

print(ans)

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

int main(){
    int n,a,b;
    int sum = 0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i){
        if((i>=1 && i<=9) && (i>=a && i<=b)) sum += i;
        else if(i<=99){
            int c,d;
            c = i % 10;
            d = (i-c) / 10;
            if((c+d)>=a && (c+d)<=b) sum += i;
        }
        else if(i<=999){
            int e,f,g;
            e = i % 10;
            f = ((i-e)/10) % 10;
            g = (i-f*10-e) / 100;
            if((e+f+g)>=a && (e+f+g)<=b) sum += i;
        }
        else if(i<=9999){
            int h,j,k,l;
            h = i % 10;
            j = ((i-h)/10) % 10;
            k = ((i-j*10-h)/100) % 10;
            l = (i-k*100-j*10-h) / 1000;
            if((h+j+k+l)>=a && (h+j+k+l)<=b) sum += i;
        }
        else{
            if(1>=a) sum += 10000;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	char slime[N];
	cin>>slime;
	int count=1;
	
	for(int i=0;i<N-1;i++)
	{
		if(slime[i]!=slime[i+1])
		{
			count++;
		}
	}
	
	cout<<count;
}

Measured memory_bytes: 384
def comb(a, b):
    ans = 1
    for i in range(b):
        ans *= (a - i)
    for i in range(2, b + 1):
        ans //= i
    return ans

def solve_k1(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    ans += 9 * (len_N - 1)
    ans += int(N[0])
    return ans

def solve_k2(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    if len_N < 2:
        return 0
    ans = comb((len_N - 1), 2) * 9 ** 2 + (int(N[0]) - 1) * ((len_N - 1) * 9) + solve_k1(int(N[1:]))
    return ans

def solve_k3(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    if len_N < 3:
        return 0
    ans = comb(len_N - 1, 3) * 9 ** 3 + (int(N[0]) - 1) * comb(len_N - 1, 2) * 9 ** 2 + solve_k2(int(N[1:]))
    return ans

N = int(input())
K = int(input())
ans = 0
if K == 1:
    ans = solve_k1(N)
elif K == 2:
    ans = solve_k2(N)
else:
    ans = solve_k3(N)
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll R, G;

int main() {
	cin >> R >> G;
	cout << 2 * G - R << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li n; cin >>n;
  if(n%2){
    printf("0");
    return 0;
  }
  li s=0; n/=2;
  while(n){
    n/=5;
    s+=n;
  }
  printf("%ld",s);
}

/// confirm df==0 ///


Measured memory_bytes: 256
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// 値入れ替えの関数 wrap
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

int main(void) {

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

	vector<int> L(n + 5), R(n + 5);

	L[1] = a[1];
	for (int i = 2; i <= n; i++) {
		L[i] = GCD(L[i - 1], a[i]);
	}

	R[n] = a[n];
	for (int i = n - 1; i ; i--) {
		R[i] = GCD(R[i + 1], a[i]);
	}

	int ans = L[n];
	ans = max(ans, max(R[2], L[n - 1]));
	for (int i = 2; i <= n-1; i++) {
		int tmp = GCD(L[i - 1], R[i + 1]);
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long X,Y;
	cin>>X>>Y;
	if(Y%2==0){
		if((Y<=X*4)and(Y>=X*2)){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
		
	}else{
		cout<<"No";
	}
	
	
} 

Measured memory_bytes: 3660
#include<stdio.h>


int main(void){
    long long a[100];
    int i,n;
    scanf("%d",&n);
    a[0]=2;
    a[1]=1;
    for(i=2;i<n+1;i++){
        a[i]=a[i-1]+a[i-2];
    }
    
    printf("%lld\n",a[n]);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 200011;
const ll INF = 5e16;
const ll P = 1e9 + 7;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	char s[N];
	ll n, Ans = 1;
	
	tr1::unordered_map <ll, ll> f[N];
	
	inline ll dfs ( ll x, ll y ) {
		if (x > 2 * n) return y == 0;
		if (f[x].count(y)) return f[x][y];
		if (s[x] == 'B') {
			if (y & 1) return f[x][y] = y * dfs(x + 1, y - 1) % P;
			return f[x][y] = dfs(x + 1, y + 1);
		} else {
			if (y & 1) return f[x][y] = dfs(x + 1, y + 1);
			return f[x][y] = y * dfs(x + 1, y - 1) % P;
		}
	}
	
	int main() {
		n = read();
		cin >> s + 1;
		For ( i, 1, n ) Ans = Ans * i % P;
		return wln(Ans * dfs(1, 0) % P), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 47360
import scala.io.StdIn.{readInt, readLine};
object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt;
    val ig = new IntGraph(n);
    (1 to n).foreach { i => readLine.split(" ").drop(2).map(_.toInt).foreach { e => ig.add(i, e)}}
    val ret = ig.dSearch();
    (1 to n).foreach { i => println("%d %d %d".format(i, ret(i)(0), ret(i)(1)))}
  }
}
class IntGraph(n: Int) {
  val size = n + 1;
  val matrix = Array.ofDim[Int](size, size);
  def add(src: Int, dst: Int): Unit = matrix(src)(dst) = 1;

  def dSearch(): Array[Array[Int]] = {
    val status = Array.ofDim[Int](size, 2);
    def _dSearch(stack: List[Int], cost: Int): (List[Int], Int) = {
      stack match {
        case Nil => (stack, cost);
        case x :: rest => {
          status(x)(0) = cost;
            val (newStack, newCost) = (0 until size).foldLeft((rest, cost)) { (ret, i) =>
              if (matrix(x)(i) == 1 && status(i)(0) == 0) _dSearch(i :: ret._1, ret._2 + 1) else (ret._1, ret._2);
            }
          status(x)(1) = newCost + 1;
          (newStack, status(x)(1));
        }
      }
    }
    (1 until size).foldLeft(0) { (cost, i) =>
      if (status(i)(0) == 0) {
        _dSearch(List[Int](i), cost + 1)._2;
      } else {
        cost
      }
    }
    status;
  }
}


Measured memory_bytes: 46404
def main():
    s=list(input())
    k=int(input())
    i=0
    while k>=0 and i<len(s)-1:
        if s[i]!='a' and k>=123-ord(s[i]):
            k-=123-ord(s[i])
            s[i]="a"
        i+=1
    if i==len(s)-1:
        s[-1]=chr(97+(k-(123-ord(s[i])))%26)
    print("".join(s))
if __name__=="__main__":
    main()

Measured memory_bytes: 4156
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

map<ll,ll> M;
map<ll,ll> R;

vector<vector<ll>> edge;
vector<bool> used;
ll num=0;
ll k=-1;

bool dfs(ll w){
    bool ret=false;
    if(w==k){ret=true;}
    used[w]=true;
    for(auto &I:edge[w]){
        if(!used[I]){ret|=dfs(I);}
    }
    return ret;
}


int main(){
    ll n;
    cin>>n;
    vector<ll> A(n),B(n);
    ll x1=0,x2=0;
    for(auto &I:A){cin>>I; x1^=I;}
    for(auto &I:B){cin>>I; x2^=I;}
    vector<ll> a=A,b=B;
    a.push_back(x1);
    b.push_back(x2);
    A.push_back(x1);
    B.push_back(x2);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(a!=b){cout<<-1<<endl; return 0;}
    ll ans=0;
    edge.resize(n);
    used.resize(n,false);
    for(int i=0;i<=n;i++){
        if(A[i]==B[i]){continue;}
        if(M.count(A[i])==0){M[A[i]]=num; num++;}
        if(M.count(B[i])==0){M[B[i]]=num; num++;}
        edge[M[A[i]]].push_back(M[B[i]]);
        ans++;
    }
    if(A[n]!=B[n]){dfs(M[A[n]]); ans--;}
    else if(M.count(A[n])){k=M[A[n]];}
    for(ll i=0;i<num;i++){
        if(!used[i]){
            if(!dfs(i)){ans++;}
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 19776
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n=int(input())
c=0
for i in range(1,n+1,2):
    a=make_divisors(i)
    if len(a)==8:
        c+=1
print(c)

Measured memory_bytes: 3060
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

class BIT:
    def __init__(self, N):
        self.N = N
        self.bit = [0] * (N + 1)
        self.b = 1 << N.bit_length() - 1

    # a - 1の場所にwを追加する
    def add(self, a, w):
        x = a
        while(x <= self.N):
            self.bit[x] += w
            x += x & -x

    # a未満の数字が何個あるか
    def get(self, a):
        ret, x = 0, a - 1
        while(x > 0):
            ret += self.bit[x]
            x -= x & -x
        return ret

    def cum(self, l, r):
        return self.get(r) - self.get(l)

    def lowerbound(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.b
        while k > 0:
            if x + k <= self.N and self.bit[x + k] < w:
                w -= self.bit[x + k]
                x += k
            k //= 2
        return x + 1

N, Q = getNM()
A = getList()
query = [getList() for i in range(Q)]

# 全部1-indexになるので注意
bit = BIT(N + 1)
for i in range(N):
    # [1, 2, 3, 4, 5]の場合
    # 1番目(0 + 1)に１を
    # 2番目(1 + 1)に２を置く
    bit.add(i + 1, A[i])

for a, b, c in query:
    if a == 0:
        bit.add(b + 1, c)
    else:
        # [1, 2, 3, 4, 5]の[0, 3)について聞きたい時
        # bit.get(0 + 1, 3 + 1)
        print(bit.cum(b + 1, c + 1))

Measured memory_bytes: 183220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    else if(b==c)cout<<a<<endl;
    else cout<<b<<endl;
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int per[MAXN];

int a[MAXN], b[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &per[i]);
		a[i] += i * 25000;
		b[i] += (n + 1 - i) * 25000;
		a[per[i]] += i;
		b[per[i]] += i;
	}
	REPN(i, 1, n){
		printf("%d ", a[i]);
	}
	putchar('\n');
	REPN(i, 1, n){
		printf("%d ", b[i]);
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 896
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n; cin>>n;
    if(n%2==0) cout<<n/2;
    else cout<<n/2+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{ long long n,x=0,y,z,i;
cin>>n;
for(i=1;3*i<=n;i++)
{ y=3*i;
if(y%5==0) continue;
x=x+y;}
for(i=1;5*i<=n;i++)
{ 
x=x+5*i;}
z=n*(n+1)/2;
cout<<(z-x);}

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

using namespace std;
#define next _next
#define y1 _y1
#define y2 _y2
#define lowbit(x) (x&(-x))
#define lc ((rt)<<1)
#define rc ((rt)<<1|1)
#define mid  ((l+r)>>1)
#define clr(a, b) memset(a,b,sizeof(a))

#ifdef __LOCAL_DEBUG__
# define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \
    __func__, ##__VA_ARGS__)
#define dg(a) cout <<"\033[94m" <<#a << "\033[0m = "<< a << endl;
#else
#define _debug(...) ((void)0)
#define dg(a)((void)0)
#endif

typedef long long ll;
typedef long double ld;
const ld pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = static_cast<int>(1e6 + 7);

int c(int x) {
    int cnt = 0;
    for (int i = 1; i <= x; i++) {
        if (x % i == 0) cnt++;
    }
//    cout << cnt << endl;
    return cnt == 8;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    while (cin >> n) {
        int ans = 0;
        for (int i = 1; i <= n; i++)
            if (c(i) && (i&1) )ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


X, Y, A, B, C = inpl()
pp = inpl()
qq = inpl()
rr = inpl()

apples = []
apples += [(p, 1) for p in pp]
apples += [(q, 2) for q in qq]
apples += [(r, 3) for r in rr]

apples.sort(reverse=True)

ans = 0
S = X+Y
for a, i in apples:
    if i == 1 and X > 0:
        ans += a
        X -= 1
        S -= 1
    elif i == 2 and Y > 0:
        ans += a
        Y -= 1
        S -= 1
    elif i == 3:
        ans += a
        S -= 1

    if S == 0:
        break

print(ans)


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

long long a, b;

void solve();

int main() {
  cin >> a >> b;
  solve();
  return 0;
}

void solve() {
  for(long long i = 1; i <= a; ++i) {
    long long num = a * i;
    if(num / a + num % a <
       num / b + (num % b) / a + (num % b % a)) {
      cout << num << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
int ch[14];
int calc(char a,char b,char c){
    return abs((a-'0')*100+(b-'0')*10+(c-'0')-753);
}
int LiangJiaJun(){
    string s;
    cin>>s;
    int ans=1000000;
    for(int i=0;i+2<s.size();i++)
            ans=min(ans,calc(s[i],s[i+1],s[i+2]));
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256