akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

    vector<deque<int>> A(N, deque<int>());
    deque<int> matchAvailablePlayers;
    vector<int> daysPassedWhenPlayedMostRecentMatch(N, 0);
    vector<int> desiredOpponentIdx(N, -1);

    for (int i = 0; i < N; ++i) {
        matchAvailablePlayers.emplace_back(i);
        for (int j = 0; j < N - 1; ++j) {
            int a;
            cin >> a;
            A[i].emplace_back(a-1);
        }
    }

    while (!matchAvailablePlayers.empty()){
        int playerIdx = matchAvailablePlayers.front(); matchAvailablePlayers.pop_front();
        auto& matchesOrderForThisPlayer = A[playerIdx];

        if (matchesOrderForThisPlayer.empty()) continue;

        int opponentIdx = matchesOrderForThisPlayer.front(); matchesOrderForThisPlayer.pop_front();

        if (desiredOpponentIdx[opponentIdx] == playerIdx){
            daysPassedWhenPlayedMostRecentMatch[playerIdx] = daysPassedWhenPlayedMostRecentMatch[opponentIdx] = max(daysPassedWhenPlayedMostRecentMatch[playerIdx], daysPassedWhenPlayedMostRecentMatch[opponentIdx]) + 1;
            matchAvailablePlayers.emplace_back(playerIdx);
            matchAvailablePlayers.emplace_back(opponentIdx);
        }else{
            desiredOpponentIdx[playerIdx] = opponentIdx;
        }
    }

    for (auto a : A){
        if (!a.empty()){
            cout << -1;
            return 0;
        }
    }
    cout << *max_element(daysPassedWhenPlayedMostRecentMatch.begin(), daysPassedWhenPlayedMostRecentMatch.end());

    return 0;
}


Measured memory_bytes: 4736
from collections import deque
N = int(input())
Query = deque(map(int,input().split()))
ju = 1
Answer = 0
for i in range(N):
    q = Query.popleft()
    if q == ju:
        ju +=1
    else:
        Answer += 1
if ju == 1:
    Answer = -1
print(Answer)

Measured memory_bytes: 32464
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int x = a ^ b;
    vector<int> even, palette;
    int prev = -1;
    for (int i=0; i<n; i++) {
        int d = 1 << i;
        if (x & d) 
            if (prev < 0) prev = d;
            else {
                palette.push_back(prev);
                palette.push_back(d);
                palette.push_back(d);
                palette.push_back(prev);
                prev = -1;
            }
        else
            even.push_back(d);
    }
    if (prev < 0) {
        cout << "NO" << '\n';
        return 0;
    }
    cout << "YES" << '\n';
    for (auto &e:even) {
        palette.push_back(e);
        palette.push_back(e);
    }
    palette.push_back(prev);
    for (auto p: palette) cerr << p << '\n';
    int len = (1 << n), p = a;
    cout << p << ' ';
    int board[n];
    for (int i=0; i<n; i++) board[i] = 1 << ((i / 2 + 1) * 2);
    for (int i=1; i<len; i++) {
        int d = i & -i,
            log = 0;
        while (!(d & (1 << log))) log++;
        // cerr << 2*log + (i > board[log]) << '\n';
        p ^= palette[2*log + (i > board[log])];
        cout << p << ' ';
    }
    cout << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

// gcd(a, b)
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

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

    ll n,x;cin>>n>>x;
    cout<<3*(n-gcd(n,x))<<endl;
}


Measured memory_bytes: 256
//93A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s= " ";
    vector<int> cnt(3,0);
    cin >> s;
    for (int i=0; i< 3; i++){
        if (s[i] =='a'){
            cnt[0] +=1;
        }else if(s[i]=='b'){
            cnt[1] +=1;
        }else if (s[i]=='c'){
            cnt[2] +=1;
        }
    }
    if(cnt[0]==1 and cnt[1]==1 and cnt[2]==1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()

res = 0
stk = []
for c in s:
    if stk and stk[-1] != c:
        stk.pop()
        res += 2
    else:
        stk.append(c)

print(res)

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

int main() {
    int N;
    string s;
    std::cin >> N;
    map<string, int> mp;
    for(int i = 0; i<N;++i){
        cin >> s;
        mp.insert( make_pair(s,0));
    }

    cout << mp.size();

}


Measured memory_bytes: 19260
#include <cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll x[100005];
int main() {
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, x + m);
	
	ll dif[100005];
	for (int i = 0; i < m-1; i++) {
		dif[i] = x[i + 1] - x[i];
	}
	sort(dif, dif +( m - 1));
	ll sum = 0;
	
	for (int i = 0; i < m - (n - 1)-1; i++) {
		
		sum += dif[i];
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 1792
from collections import Counter

# input
N = int(input())
S = []
s_append = S.append

for i in range(N):
    s = input()
    s_append(s)

# check
s_counter = Counter(S)
max = max(s_counter.values())

printed_items = []
append = printed_items.append
max_s = [s[0] for s in s_counter.items() if s[1] == max]
for i in sorted(max_s):
    print(i)


Measured memory_bytes: 35568
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll h,n;
    cin>>h>>n;
    ll sum=0;
    for(ll i=0;i<n;++i){
        ll x;cin>>x;
        sum+=x;
    }
    if(h<=sum){cout<<"Yes";}
    else{cout<<"No";}

    return (0);
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [INT() for _ in range(N)]

ans = 0
cnt = 0
for x in A:
	if x != 0:
		cnt += x
	else:
		ans += cnt//2
		cnt = 0
ans += cnt//2

print(ans)


Measured memory_bytes: 14472
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m, x; cin >> n >> m >> x;
  int left = 0, right = 0;
  REP(i, m) {
    int a; cin >> a;
    if (a <= x) ++left;
    else ++right;
  }
  cout << min(left, right) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#define ll long long
using namespace std;
const ll N = 1e2 + 5;
ll arr[2][N]; ll n;
bool check(ll dx, ll dy){
	if(dx > 1 || dy >= n){
		return false;
	}
	return true;
}
ll fun(ll dx, ll dy){
	ll ff = -1, ss = -1;
	if(dx == 1 && dy == (n - 1)){
		return arr[dx][dy];
	}
	if(check(dx + 1, dy)){
		ff = fun(dx + 1, dy);
	}
	if(check(dx, dy + 1)){
		ss = fun(dx, dy + 1);
	}
	return arr[dx][dy] + max(ff, ss);
}
int main(){
	cin >> n;
	for(ll i = 0; i < 2; i++){
		for(ll j = 0; j < n; j++){
			cin >> arr[i][j];
		}
	}
	cout << fun(0, 0);
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(s.count(x)){
            s.erase(s.find(x));
        }else{
            s.insert(x);
        }
    }
    cout << SZ(s);
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
int main(void){
	int a=100000;
	int n;
	scanf("%d",&n);
	for (int i = 0; i < n; i++){
	a = (((a+19999) / 20000)*1000) + a;
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 2732
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


int main(void) {
  map<string, ll> mp;
  vector<string> vs;
  string ss;
  cin >> s;
  cin >> n;

  char c = 'a';

  while (1) {
	flag = false;
	FOR(i, 0, s.length()) {
	  if (c == s[i])flag = true;
	}

	if (!flag) {
	  c++;
	  continue;
	}

	FOR(i, 1, 10) {
	  ok = false;
	  FOR(j, 0, s.length() - i + 1) {
		ss = "";
		if (s[j] == c) {
		  FOR(k, j, j + i) {
			ss += s[k];
		  }
		  if (mp[ss] == 0) {
			vs.pb(ss);
			mp[ss]++;
			cnt++;
			ok = true;
		  }
		}
	  }
	  if (!ok) {
		break;
	  }
	}
	if (cnt >= n) break;
	c++;
  }

  sort(ALL(vs));
  cout << vs[n - 1] << endl;

  return 0;
}


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():
    N = int(input())
    A = [int(s) for s in input().split()]

    X = [0]*N
    X[0] = (A[0] + sum(A[2::2]) - sum(A[1::2])) / 2

    for i in range(1,N):
        X[i] = int(A[i-1] - X[i-1])
        
    for i in range(N):

        print(int(2*X[i]),end = ' ') if i != N-1 else print(int(2*X[i]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
program nn
  implicit none
  integer :: N,digi,i
  integer :: alle

  read(*,*) N

  digi=int(log(N*1.0)/log(10.0))+1
  alle=0
!  write(*,*) digi                                                              
  if(mod(digi,2).eq.0) then
     do i=1,digi/2
        alle=alle+9*100**(i-1)
!        write(*,*) alle                                                        
     enddo
  else
    do i=1,digi/2
        alle=alle+9*100**(i-1)
     enddo
     alle=alle+N-(10**(digi-1))+1
  endif

  write(*,'(i0)') int(alle)
end program nn

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m, c);
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int ans = 0, temp;
    for(int i = 0; i < n; i++) {
        int temp2 = c;
        for(int j = 0; j < m; j++) {
            cin >> temp;
            temp2 += temp*b[j];
        }
        if(temp2 > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
 
const int NN = 110;
char str1[NN];
int n;
unsigned long long a, b, c, d, e, ans;
int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%s", str1);
		if (str1[0] == 'M') a++;
		if (str1[0] == 'A') b++;
		if (str1[0] == 'R') c++;
		if (str1[0] == 'C') d++;
		if (str1[0] == 'H') e++;
	}
	ans = a*b*c + a*b*d + a*b*e + a*c*d + a*c*e + a*d*e + b*c*d + b*c*e + b*d*e + c*d*e;
	printf("%llu", ans);

	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long int ll;
bool b[N];

int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);
    int n, ans = 0, tmp;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>tmp;
        if(tmp==i) b[i] = true;
    }

    for(int i=1;i<=n;++i){
        if(b[i]){
            b[i] = b[i+1] = false;
            ans++;
        }
    }

    cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define bg(x) (x).begin()
#define ed(x) (x).end()
#define ar array
#define ll long long int

const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int d, t, s;
        cin >> d >> t >> s;
        int f =  s * t; ;
        if (f >= d) {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
        
    }

    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int s=1;
        for(int i=0;i<3;i++)
            s*=sc.nextInt();
        if(s==175)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

signed main()
{
string s;
cin>>s;
int x=s.size();
int c=0;
for(int i=0;i<x/2;i++)
{
    if(s[i]!=s[x-1-i])
        c++;
}
cout<<c<<endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;
int lis[200010];
int flg[200010];

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, K;
    cin >> N >> K;
    vi A;
    A.resize(N);
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        A[i] = tmp - 1;
    }
    REP(i, N)
    {
        flg[i] = -1;
    }
    int now = 0;
    int idx = 0;

    while (true)
    {
        lis[idx] = now;
        flg[now] = idx;
        idx++;

        now = A[now];
        if (flg[now] != -1)
            break;
    }

    if (K < idx)
    {
        cout << lis[K] + 1 << endl;
    }
    else
    {
        int ii = flg[now];
        K -= ii;
        cout << lis[(K % (idx - ii)) + ii] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 7772
#include<bits/stdc++.h>
using namespace std;
#define N 25
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<<endl
int a[N],p2[N];
vector<pair<int,int>> adj[N];
int main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	cin >> l;
	vector<int> v;
	int val = l;
	while(val) {
		if(val%2) v.push_back(1);
		else v.push_back(0);
		val /= 2;
	}
	p2[0] = 1;
	for(i = 1;i < N;i++) {
		p2[i] = p2[i-1] * 2;
	}
	m = 0;
	for(i = 1;i < v.size();i++) {
		adj[i-1].push_back({i,p2[i-1]});
		adj[i-1].push_back({i,0});
		m += 2;
	}
	n = v.size()-1;
	int curr = (1<<n);
	int rem = l - curr;
	int id = n-1;
	while(rem > 0) {
		// trace(rem);
		for(i = n;i >= 0;i--) {
			if(p2[i] <= rem) {
				// cout << i << " " << p2[i] << endl;
				adj[i].push_back({n,curr});
				curr += p2[i];
				rem -= p2[i];
				m++;
				break;
			}
		}
	}
	// cout << l << endl;
	cout << n+1 << " " << m << endl;
	for(i = 0;i < n;i++) {
		for(auto it : adj[i]) {
			cout << i+1 << " " << it.first+1 << " " << it.second << endl;
		}
	}
}

Measured memory_bytes: 256
from sys import exit
from random import randrange
MOD = 10**9+7
n, k = map(int, input().split())
b = list(map(int, input().split()))
a = []
if n == k:
	ans = 1
	for x in b:
		ans *= x
		ans %= MOD
	print(ans)
	exit()
for x in b:
	if x != 0:
		a.append(x)
if len(a) < k:
	print(0)
	exit()

a.sort(key=lambda x: -abs(x))
#print(a)
ans = 1
minus = 0
for i in range(k):
	ans *= a[i]
	ans %= MOD
	if a[i] < 0:
		minus += 1

if minus%2 == 0:
	print(ans)
	exit()

if len(a) == k:
	if len(a) < n:
		print(0)
		exit()

for i in range(k, len(a)):
	if a[i] < 0:
		minus += 1

if minus == len(a):
	if len(a) < n:
		print(0)
		exit()
	ans = 1
	for i in range(k):
		ans *= a[-i-1]
		ans %= MOD
	print(ans)
	exit()

flg1 = False
for i in range(k-1, -1, -1):
	if a[i] * a[k] < 0:
		p, q = a[i], a[k]
		flg1 = True
		break

flg2 = False
for i in range(k, len(a)):
	if a[k-1] * a[i] < 0:
		r, s = a[k-1], a[i]
		flg2 = True
		break

if flg1 and flg2:
	if abs(q*r) >= abs(p*s):
		ans *= pow(p, MOD-2, MOD)
		ans *= q
		print(ans%MOD)
	else:
		ans *= pow(r, MOD-2, MOD)
		ans *= s
		print(ans%MOD)

elif flg1:
	ans *= pow(p, MOD-2, MOD)
	ans *= q
	print(ans%MOD)

elif flg2:
	ans *= pow(r, MOD-2, MOD)
	ans *= s
	print(ans%MOD)

else:
	print("コーナーケース多すぎん？")

Measured memory_bytes: 126612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n;
   cin >> n;
   vector<ll> vc(n);
   vector<ll> cnt(n);
   for(int i = 0;i < n;i++) {
       cnt[i] = 0;
   }
   for(int i = 0;i < n-1;i++) {
       cin >> vc[i];
       cnt[vc[i]-1]++;
   }
   for(int i = 0;i < n;i++) {
       cout <<cnt[i] << endl;
   }
}

Measured memory_bytes: 6368
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:i64 = read();
    let mut a:Vec<i64> = (0..n+1).map(|_| read()).collect();
    let mut b:Vec<i64> = (0..n).map(|_| read()).collect();

    let mut ans:i64 = 0;
    for i in 0..n {
        let i = i as usize;
        let d:i64 = a[i]-b[i];
        if d >= 0 {
            ans += b[i];
            a[i] = d;
            continue;
        } else {
            b[i] -= a[i];
            ans += a[i];
            a[i] = 0;
        }
        let d:i64 = a[i+1]-b[i];
        if d >= 0 {
            ans += b[i];
            a[i+1] = d;
            continue;
        } else {
            b[i] -= a[i+1];
            ans += a[i+1];
            a[i+1] = 0;
        }
    }

    println!("{}", ans);

    
}

Measured memory_bytes: 6396
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_str():
    return readline().strip()


def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        b = int(b)
        cpr = ((cpr * 2) + b) % (C+1)
        if C-1 != 0:
            cmr = ((cmr * 2) + b) % (C-1)

    ans = []
    for i in range(N):
        t = 1
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
        else:
            x = 0
            t = 0

        while x != 0:
            x = x % bin(x).count('1')
            t += 1

        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_str()
    print(*slv(N, X), sep='\n')


if __name__ == '__main__':
    main()


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

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> v(N+1);//v[i]はi番の人が持っているお菓子の数
	for (int i = 0; i < K ;i++) {
		int d;
		cin >> d;
		vector<int> A(d);
		for (int i = 0; i < d; i++) {
			cin >> A[i];
			v[A[i]]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (v[i] == 0) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
    int h=0,bs=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(a[i]==b[j]){
	  if(i==j) h++;
	  else bs++;
	}
      }
    }
    cout << h << " " << bs << endl; 
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
long long h, w, ch, cw, dh, dw, e, x, y, z;
char f[1002][1002];
int d[1002][1002];
int dx[4];
int dy[4];
#define heapsize 1024*1024*32
long long heap[heapsize];
using namespace std;
void qpush(long long inx) {
	heap[0]++;
	long long now = heap[0];
	long long tempo;
	heap[now] = inx;
	while (now - 1) {
		if (heap[now / 2] <= heap[now])return;//hikaku
		tempo = heap[now / 2];
		heap[now / 2] = heap[now];
		heap[now] = tempo;
		now /= 2;
	}
}
long long qout(void) {
	long long retu = heap[1];
	long long tempo = heap[0];
	long long now = 1;
	long long end;
	while (true) {
		if (now * 2 > tempo) {
			end = now;
			break;
		}
		if (now * 2 == tempo) {
			heap[now] = heap[now * 2];
			end = now * 2;
			break;
		}
		if (heap[now * 2] > heap[now * 2 + 1]) {//hikaku
			heap[now] = heap[now * 2 + 1];
			now = now * 2 + 1;
		}
		else {
			heap[now] = heap[now * 2];
			now = now * 2;
		}
	}
	heap[0] = end - 1;
	qpush(heap[tempo]);
	heap[tempo] = 0;
	heap[0] = tempo - 1;
	return retu;
}
int main() {
	dx[0] = 1;
	dx[1] = -1;
	dy[2] = 1;
	dy[3] = -1;
	scanf("%lld%lld", &h, &w);
	scanf("%lld%lld%lld%lld", &ch, &cw, &dh, &dw);
	for (int i = 1; i <= h; i++) {
		scanf(" %s", f[i] + 1);
		f[i][0] = '#';
		f[i][w + 1] = '#';
		for (int j = 1; j <= w; j++) {
			d[i][j] = 1000000;
		}
	}
	for (int i = 0; i <= w + 1; i++) {
		f[0][i] = '#';
		f[h + 1][i] = '#';
	}
	d[ch][cw] = 0;
	qpush(ch * 2000 + cw);
	e = 1;
	while (e) {
		e--;
		z = qout();
		y = z % 2000;
		z /= 2000;
		x = z % 2000;
		z /= 2000;
		for (int i = 0; i < 4; i++) {
			if (f[x + dx[i]][y + dy[i]] == '.' && d[x + dx[i]][y + dy[i]] > z) {
				qpush(z * 4000000 + (x + dx[i]) * 2000 + y + dy[i]);
				d[x + dx[i]][y + dy[i]] = z;
				e++;
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				if (i != 0 || j != 0) {
					if (1 <= x + i && x + i <= h && 1 <= y + j && y + j <= w) {
						if (f[x + i][y + j] == '.' && d[x + i][y + j] > z + 1) {
							qpush((z + 1) * 4000000 + (x + i) * 2000 + y + j);
							d[x + i][y + j] = z + 1;
							e++;
						}
					}
				}
			}
		}
	}
	if (d[dh][dw] == 1000000)printf("-1\n");
	else printf("%d\n", d[dh][dw]);
}

Measured memory_bytes: 6724
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    int len1,len2,len3;
    len1= a.size();
    len2= b.size();
   (a[len1-1]==b[0] && b[len2-1]==c[0])? cout<<"YES":cout<<"NO";
}

Measured memory_bytes: 3604
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a , b , c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2];
}

Measured memory_bytes: 3640
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);

using ll = int64_t;
using ull = uint64_t;

using namespace std;

bool bfs(const int i, const vector<vector<int>>& G, const vector<ll>& H) {
    vector<bool> used(H.size() + 1);

    if (G[i].empty()) return true;

    ll m{};
    for (int v : G[i]) {
        m = max({m, H[v]});
    }

    return H[i] > m;
}

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

    int n, m;
    cin >> n >> m;

    vector<ll> H(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> H[i];
    }

    vector<vector<int>> G(n + 1, vector<int>());
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int res{};
    for (int i = 1; i <= n; ++i) {
        if (bfs(i, G, H)) {
            ++res;
        }
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 9280
#include<bits/stdc++.h>
using namespace std;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    double l;
    cin >> l;
    printf("%.10lf\n",l*l*l/27);
    return 0;    
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
int main (){
    int x , a ,b , da , db;
    scanf("%d%d%d",&x,&a ,&b);
    da=abs(x-a);
    db=abs(x-b);
    if (da>db )
        printf("B\n");
    else
        printf("A\n");



    return 0;

}


Measured memory_bytes: 128
n, m = map(int, input().split())
l = [0 for _ in range(n)]
for i in range(n):
    l[i] = list(map(int, input().split()))
l_sort = sorted(l)
ans = 0
drink = 0
for j in range(n):
    cnt_lim = l_sort[j][1]
    cnt = 0
    while cnt < cnt_lim:
        ans += l_sort[j][0]
        cnt += 1
        drink += 1
        if drink == m:
            print(ans)
            exit()

Measured memory_bytes: 28556
n, x, y = map(int, input().split())
x -= 1
y -= 1

k = [0 for _ in range(n)]
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j-i, abs(x-i)+1+abs(j-y))
        if dist < n:
            k[dist] += 1
for i in range(1, len(k)):
    print(k[i])


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

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


ab = sorted(ab, key=lambda x: x[1])

weight = 0
for w, d in ab:
    # print(weight, d)
    weight += w
    if weight > d:
        print("No")
        exit()
# print(weight, d)
print("Yes")


Measured memory_bytes: 55264
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	int a[6] = {};
	for (int i = 0; i < 3; i++) {
		cin >> L >> R;
		a[L]++;
		a[R]++;
	}
	if (a[1] > 2 || a[2] > 2 || a[3] > 2 || a[4] > 2) {
		cout << "NO\n";
	}
	else cout << "YES\n";
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    auto st = new LazySegmentTree!(long, long, min, (a,b)=>b, (a,b)=>b, (a,b)=>a, (1L<<31)-1, (1L<<31)-1)(N);

    while (Q--) {
        s = readln.split.map!(to!int);
        int q = s[0];
        int l = s[1];
        int r = s[2];
        if (q == 0) {
            long v = s[3];
            st.update(l, r, v);
        } else {
            st.query(l, r).writeln;
        }
    }
}


class LazySegmentTree(T, L, alias opTT, alias opTL, alias opLL, alias opPrd, L eL, T eT) {
    T[] table;
    L[] lazy_;
    int n;
    int size;

    this(int n) {
        this.n = n;
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        lazy_ = new T[](size);
        table[] = eT;
        lazy_[] = eL;
    }

    void push(int i, int a, int b) {
        if (lazy_[i] == eL) return;
        table[i] = opTL(table[i], opPrd(lazy_[i], b - a + 1));
        if (i * 2 + 1 < size) {
            lazy_[i*2] = opLL(lazy_[i*2], lazy_[i]);
            lazy_[i*2+1] = opLL(lazy_[i*2+1], lazy_[i]);
        }
        lazy_[i] = eL;
    }

    T query(int l, int r) {
        if (l > r) return eT;
        return query(l, r, 1, 0, n-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) return eT;
        push(i, a, b);
        if (l <= a && b <= r) {
            return table[i];
        } else {
            return opTT(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }

    void update(int l, int r, L val) {
        if (l > r) return;
        update(l, r, 1, 0, n-1, val);
    }

    void update(int l, int r, int i, int a, int b, L val) {
        if (b < l || r < a) {
            push(i, a, b);
        } else if (l <= a && b <= r) {
            lazy_[i] = opLL(lazy_[i], val);
            push(i, a, b);
        } else {
            push(i, a, b);
            update(l, r, i*2, a, (a+b)/2, val);
            update(l, r, i*2+1, (a+b)/2+1, b, val);
            table[i] = opTT(table[i*2], table[i*2+1]);
        }
    }
}



Measured memory_bytes: 7428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

// 根が1
template<typename Monoid>
struct segtree {
    using T = typename Monoid::T;
    int n;
    vector<T> dat;

    segtree(int n_) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n*2, Monoid::id());
    }
    void build(vector<T> v) {
        REP(i, v.size()) dat[i+n] = v[i];
        for(int i=n-1; i>0; --i) dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
    }

    T query(int a, int b) {
        if(a >= b) return Monoid::id();
        T l = Monoid::id(), r = Monoid::id();
        for(a+=n, b+=n; a<b; a>>=1, b>>=1) {
            if(a&1) l = Monoid::op(l, dat[a++]);
            if(b&1) r = Monoid::op(dat[--b], r);
        }
        return Monoid::op(l, r);
    }
    void update(int i, T v) {
        i += n;
        dat[i] = v;
        while(i >>= 1) {
            dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
        }
    }

    friend ostream &operator <<(ostream& out,const segtree<Monoid>& seg){
        out << "---------------------" << endl;
        int cnt = 1;
        for(int i=1; i<=seg.n; i*=2) {
            REP(j, i) {
                out << seg.dat[cnt] << " ";
                cnt++;
            }
            out << endl;
        }
        out << "---------------------" << endl;
        return out;
    }
};

template<typename Tp>
struct min_monoid {
    using T = Tp;
    static constexpr Tp id() { return INF; }
    static Tp op(const Tp &a, const Tp &b) { return min(a, b); }
};
template<typename Tp>
struct max_monoid {
    using T = Tp;
    static constexpr Tp id() { return -INF; }
    static Tp op(const Tp &a, const Tp &b) { return max(a, b); }
};

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i], a[i]--;

    // vl[i] = (a[j]<a[i] であるi未満の最大のj)
    vector<ll> vl(n);
    {
        segtree<max_monoid<ll>> seg(n);
        seg.build(vector<ll>(n, -1));
        REP(i, n) {
            vl[i] = seg.query(0, a[i]+1);
            seg.update(a[i], i);
        }
    }
    
    // vr[i] = (a[j]<a[i] であるiより大きい最小のj)
    vector<ll> vr(n);
    {
        segtree<min_monoid<ll>> seg(n);
        seg.build(vector<ll>(n, n));
        for(ll i=n-1; i>=0; --i) {
            vr[i] = seg.query(0, a[i]+1);
            seg.update(a[i], i);
        }
    }

    ll ans = 0;
    REP(i, n) ans += (i-vl[i]) * (vr[i]-i) * (a[i]+1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int a;
  scanf("%d", &a);
  cout << a + a*a + a*a*a << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int a, b;cin>>a>>b;
  int x = 1, ans = 0;
  while(x < b){
    x += a-1;ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    vec<int, 2> dp = make_v(N + 1, N + 1, 0);
    for (int i = N - 1; i >= 0; i--) {
      for (int j = 0; j < N; j++) {
        if (S[i] != S[j]) {
          dp[i][j] = 0;
        } else {
          dp[i][j] = dp[i + 1][j + 1] + 1;
        }
      }
    }
    int res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        chmax(res, min(j - i, dp[i][j]));
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 98176
#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;
typedef long long LL;
LL read()
{
    char c=getchar();LL f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m,top;
LL a[maxn],s[maxn];
LL ans[maxn],val[maxn];
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++) a[i]=read();
	a[m=0]=n;
	for(int i=0;a[i];i++)
	{
		while(m && a[i]<=a[m-1]) m--;
		a[m++]=a[i];
	}
	val[m-1]=1;
	for(int i=m-1;i>=0;i--)
	{
		LL x=a[i];
		while(1)
		{
			LL pos=upper_bound(a,a+i,x)-a-1;
			if(pos<0) break;
			val[pos]+=val[i]*(x/a[pos]);
			x%=a[pos];
		}
		if(x) ans[x]+=val[i];
	}
	for(int i=n;i;i--) ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<vector<char>> s(n);
  char tmp;
  REP(i, n) {
    s[i].resize(n);
    REP(j, n) {
      cin >> s[i][j];
    }
  }

  bool sym = true;
  int count = 0;

  vector<vector<char>> t(n);
  REP(i, n) t[i].resize(n);
  
  
  REP(k, n) {
    REP(i, n) {
      REP(j, n) {
        t[i][j] = s[(i+k)%n][j];
      }
    }

    REP(i, n) {
      FOR(j, i+1, n) {
        if(t[i][j] != t[j][i]) {
          sym = false;
          break;
        }
      }
      if(!sym) break;
    }
    
    if(sym) {
      count += n;
    }

    sym = true;
  }

  cout << count << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
	int h,w;
	int i,j,k;
	int di[]={-1,0,0,1};
	int dj[]={0,-1,1,0};
	int ni,nj;
	int f1,f2;
	string buf;
	vector<string> s;
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>buf;
		s.push_back(buf);
	}
	f1=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(s[i][j]=='#'){
				f2=0;
				for(k=0;k<4;k++){
					ni=i+di[k];
					nj=j+dj[k];
					if(ni>=0 && ni<h && nj>=0 && nj<w && s[ni][nj]=='#'){
						f2=1;
					}
				}
				if(f2==0){
					f1=1;
				}
			}
		}
	}
	if(f1==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

int a, b, c;
long long k;

int main(){
	cin >> a >> b >> c >> k;
	k %= 2;
	if (k == 1)
		cout << b - a << '\n';
	else
		cout << a - b << '\n';
	return 0;
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    a, b, x = map(int, input().split())

    print(b//x-(a-1)//x)


resolve()

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

int main() {
  int n, ans = 0;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i < n - 1; i++) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
        (p[i + 1] < p[i] && p[i] < p[i - 1])) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
program main
  implicit none
  integer :: a(5),k
  integer :: distance
  integer :: i,j
  do i = 1,5
     read(*,*) a(i)
  end do
  read(*,*) k
  do i = 1,4
     do j=i+1,5
        distance = a(j)-a(i)
        if ( k >= distance) then
           cycle
        else
           write(*,'(a)')':('
           stop
        end if
     end do
  end do
  write(*,'(a)')'Yay!'
  stop
contains
  
end program main


Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    ll N,A,B; cin >> N >> A >> B;
    if(N==1){
        if(A==B) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    if(A<=B) cout << (N-2)*(B-A)+1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
using namespace std;

int H, W, sum;
vector<vector<char> > v(100, vector<char>(100));
int DX[4] = {1, 0, -1, 0};
int DY[4] = {0, 1, 0, -1};

void dfs(int n, int m) {
    char key = v[n][m];
    v[n][m] = 0;
    for(int i = 0; i < 4; ++i) {
        int dx = DX[i];
        int dy = DY[i];
        if(m + dx >= 0 && m + dx < W && n + dy >= 0 && n + dy < H && v[n + dy][m + dx] == key ) {
            dfs(n + dy, m + dx);
        }
    }
}

int main() {
    while(true) {
        sum = 0;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        REP(i, H) {
            REP(j, W) {
                cin >> v[i][j];
            }
        }
        REP(i, H) {
            REP(j, W) {
                if(v[i][j] != 0) {
                    ++sum;
                    dfs(i, j);
                }
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3552
#include<iostream>
#include <algorithm>
using namespace std;
int N_MAX = 2000;
int main()
{
  int n,m;
  cin >> n >> m;
  int da[N_MAX];
  int li[N_MAX];
  int k,t;
  int res=0;
  for(int i=0;i<n;i++){
    cin >> k;
    fill(li,li+m,0);
    for(int j=0;j<k;j++){
      cin >> t;
      li[t-1]=1;
    }
    for(int j=0;j<m;j++)
      if(li[j]==0) da[j]=1;
  }
  for(int j=0;j<m;j++)
    if(da[j]==0) res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
C = Hash.new{|h, k| h[k] = 0}
N.times{
  C[gets.chomp.unpack('c*').sort.pack('c*')] += 1
}

ans = 0
C.each{|k, v|
  ans += ((v * (v - 1)) / 2) 
}

puts ans


Measured memory_bytes: 19196
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int cnt = 0;
    rep(i, s.size()/2) {
        if(s[i] != s[s.size()-i-1]) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
    int k;
    cin >> k;
    vector<ll> a;
    for(int i=1; i<10; i++) a.push_back(i);
    while(1){
        if(k<=a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(a,old);
        for(ll x:old){
            for(int i=-1; i<=1; i++){
                int d = x%10+i;
                if(d<0 || d>9) continue;
                a.push_back(x*10+d);
                //cout << x*10+i << endl;
            }
        }
    }
}

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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

void solveTest(){
	
}

int main(){
	fastio();
	//input();

	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}*/

	ll a,b,c;
	cin>>a>>b>>c;
	ll cnt=0;
	while(a%2==0&&b%2==0&&c%2==0){
		if(a==b&&b==c){
			cout<<-1<<endl;
			return 0;
		}
		cnt++;
		ll x,y,z;
		x = b/2+c/2;
		y = a/2+c/2;
		z = a/2+b/2;
		a=x;b=y;c=z;		
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256