akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> u(M), v(M);
    vector<vector<int>> edge(3 * N);
    REP(i, M) {
        cin >> u[i];
        cin >> v[i];
        u[i]--;
        v[i]--;
        edge[3 * u[i]].push_back(3 * v[i] + 1);
        edge[3 * u[i] + 1].push_back(3 * v[i] + 2);
        edge[3 * u[i] + 2].push_back(3 * v[i]);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;

    queue<pair<int, int>> que;
    map<int, int> visited;
    que.push(make_pair(3 * S, 0));
    while(!que.empty()) {
        int next = que.front().first;
        int cnt = que.front().second;
        que.pop();
        if(visited[next] == 0) {
            visited[next]++;
            cnt++;
            for(int i = 0; i < edge[next].size(); i++) {
                int tmp = edge[next][i];
                if(visited[tmp] == 0) {
                    if(tmp == 3 * T) {
                        cout << cnt / 3 << endl;
                        return 0;
                    }
                    que.push(make_pair(tmp, cnt));
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 31488
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int find_index(const vector<tuple<int, int, int>> &group, int k) {
    int lower = 0;
    int upper = group.size();
    do {
        int cur = (upper + lower) / 2;
        if (get<0>(group[cur]) <= k) {
            lower = cur;
        } else {
            upper = cur;
        }
    } while (upper - lower > 1);
    return lower;
}

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<tuple<int, int, int>>> group(d);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int a;
            cin >> a;
            group[a % d].push_back(make_tuple(a, i, j));
        }
    }
    for (int i = 0; i < d; ++i) {
        sort(group[i].begin(), group[i].end());
    }
    vector<vector<int>> power1(d), power2(d);
    for (int i = 0; i < d; ++i) {
        power1[i].resize(group[i].size());
        power2[i].resize(group[i].size());
        for (int j = 1; j < group[i].size(); ++j) {
            power1[i][j] = power1[i][j - 1];
            power1[i][j] += abs(get<1>(group[i][j]) - get<1>(group[i][j - 1])) + abs(get<2>(group[i][j]) - get<2>(group[i][j - 1]));
        }
        power2[i].back() = abs(get<1>(group[i].front()) - get<1>(group[i].back())) + abs(get<2>(group[i].front()) - get<2>(group[i].back()));
        for (int j = group[i].size() - 2; j >= 0; --j) {
            power2[i][j] = power2[i][j + 1];
            power2[i][j] += abs(get<1>(group[i][j]) - get<1>(group[i][j + 1])) + abs(get<2>(group[i][j]) - get<2>(group[i][j + 1]));
        }
    }
    int q;
    cin >> q;
    vector<int> ans(q);
    for (int i = 0; i < q; ++i) {
        int a, b;
        cin >> a >> b;
        int g = a % d;
        int k = find_index(group[g], a);
        int l = find_index(group[g], b);

        if (k < l) {
            ans[i] = power1[g][l] - power1[g][k];
        } else if (k > l) {
            ans[i] = power1[g][l] + power2[g][k];
        }
    }
    for (int a : ans) {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 15616
import heapq

n, m=map(int, input().split())
a=[-1*int(n) for n in input().split()]
heapq.heapify(a)

for i in range(m):
  num=-1*(-1*heapq.heappop(a)//2)
  heapq.heappush(a,num)

print(-1*sum(a))

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

int main(void){

  int i,c,cm,ln;
  char s[11];

  scanf("%s",s);

  ln = strlen(s);
  
  for(i = 0,c = 0,cm = 0;i < ln;i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      c++;
    }else{
      if(cm < c){
        cm = c;
      }
      c = 0;
    }
  }

  if(cm < c){
    cm = c;
  }
  
  printf("%d\n",cm);

  return 0;
}

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

int main() {
  int n, m;
  cin>>n>>m;
  map<int, int> cnt;

  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    ++cnt[a];
    ++cnt[b];
  }
  for (auto e: cnt) {
    if (e.second % 2 != 0) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 4352
N = input()
if int(N[-1]) == 2 or int(N[-1]) ==4 or int(N[-1]) ==5 or int(N[-1]) ==7 or int(N[-1]) ==9:
    print("hon")
elif int(N[-1]) == 0 or int(N[-1]) ==1 or int(N[-1]) ==6 or int(N[-1]) ==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9196
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n) cin >> s[i];
  
  int ans = 0;
  rep(i,n) ans += s[i];
  
  if(ans%10 != 0){
    cout << ans;
    return 0;
  }
  
  int min_s = 1 << 30;
  
  rep(i,n){
    if(s[i]%10 != 0){
      chmin(min_s,s[i]);
    }
  }
  
  if(ans-min_s > 0){
    cout << ans - min_s;
  }else{
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double v,s,t;
	cin>>s>>t>>v;
	if(s/v<=t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int out = 0;
  if(s.at(0) == 'S'){
    if(s.at(1) == 'U'){
      out = 7;
    }else{
      out = 1;
    }
  }else if(s.at(0) == 'M'){
    out = 6;
  }else if(s.at(0) == 'W'){
    out = 4;
  }else if(s.at(0) == 'F'){
    out = 2;
  }else if(s.at(0) == 'T'){
    if(s.at(1) == 'U'){
      out = 5;
    }else{
      out = 3;
    }
  }
    cout << out;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	int ans = (n == 1 ? abs(x[0]) : 1000000000);
	if (n == k)
	{
		int l = x[0], r = x[k - 1];
		if (l <= 0 && r <= 0)
			ans = min(ans, abs(min(l, r)));
		else if (0 <= l && 0 <= r)
			ans = min(ans, max(l, r));
		else
			ans = min({ans, abs(l) + abs(r * 2), abs(l * 2) + abs(r)});
	}
	for (int i = 0; i <= n - k; i++)
	{
		int l = x[i], r = x[i + k - 1];
		if (l <= 0 && r <= 0)
			ans = min(ans, abs(min(l, r)));
		else if (0 <= l && 0 <= r)
			ans = min(ans, max(l, r));
		else
			ans = min({ans, abs(l) + abs(r * 2), abs(l * 2) + abs(r)});
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;

ll n, a, b;

int main()
{
    cin >> n >> a >> b;
    if (a % 2 == b % 2) printf("%lld\n", abs(a - b) / 2);
    else {
        ll res = min(a - 1 + b - 1 + 1, n - a + n - b + 1) / 2;
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#include <cmath>
using namespace std;
const unsigned int m = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   	int t;
   	//cin>>t;
   	t=1;
   	while(t--)
   	{
      int n;
      cin>>n;
      int b=n%10;
      if(b==2 || b==4 || b==5 || b==7 || b==9)
        cout<<"hon"<<endl;
      else if(b==3)
      {
          cout<<"bon"<<endl;
      }
      else
        cout<<"pon"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
from math import ceil, log2
N, K = map(int, input().split())

kakuritu = 0
for i in range(1,N+1):
    if K<=i:
        kakuritu += 1/N
    else:
        kaisuu = ceil(log2(K / i))

        kakuritu += 1/N * (1/2)**kaisuu

print(kakuritu)

Measured memory_bytes: 3188
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e5 + 1;
int n , m;
int a[N];
string s;

main(){
	int n;
	cin >> n;
	cout << n * (n + 1) / 2;		
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    r,g,b = LI()
    ans = ["YES","NO"]
    print(ans[((((g<<1)&b)<<1)+((g<<1)^b))&3>0])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38512
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


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


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


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


N = z()
X, Y = [], []
dist = [0]*(N)  # 原点からの距離
for i in range(N):
    x, y = zz()
    x, y = x-y, x+y

    X.append(x)
    Y.append(y)

a = max(X) - min(X)
b = max(Y)-min(Y)
print(max(a, b))


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

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

    //good luck, kittu
    int n; cin>>n;
    string s; cin>>s;
    int x = s.size();
    for(int i = 0; i<x; i++) s[i] = 'A' + (s[i]-'A'+n)%26;
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 892
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(K):
        B = [0] * (N + 1)
        for i in range(N):
            l = max(0,i-A[i])
            r = min(N,i+A[i]+1)
            B[l] += 1
            B[r] -= 1
        for i in range(N):
            B[i+1] += B[i]
        B.pop(-1)
        if A == B:
            break
        A = B

    print(*A)
    

if __name__ == "__main__":
    main()

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

const int N = 200005;

int n, a[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n; n *= 2;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + n + 1);
	
	long long s = 0;
	for (int i = n; i >= 2; --i) s += 1LL * (i - 1) * a[i];
	double ans = (double)s / (n - 1);

	cout << setprecision(11) << fixed << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, c; cin >> n >> c;
    vi sum(200010, 0);
    map<ll, vector<pair<ll, ll>>> prog;
    rep(i, n){
        ll s, t, c;
        cin >> s >> t >> c;
        prog[c].emplace_back(make_pair(s, t));
    }
    for(auto &p: prog){
        sort(all(p.second));
        ll size = p.second.size();
        for(ll i=0; i<size; i++){
            ll s = p.second[i].first;
            ll t = p.second[i].second;
            if(i == 0){
                sum[s*2-1]++;
                sum[t*2+1]--;
            }
            else{
                if(s == p.second[i-1].second){
                    sum[s*2+1]++;
                    sum[t*2+1]--;
                }
                else{
                    sum[s*2-1]++;
                    sum[t*2+1]--;
                }
            }
        }
    }

    ll ans = 0;
    repf(i, 200000){
        sum[i+1] += sum[i];
        chmax(ans, sum[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7388
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	// int t, n, k;
	// cin >> t;
	// while (t--) {
	// 	cin >> n >> k;
	// 	vector<int> arr(2 * n);
	// 	for (int i = 0; i < n; i++) {
	// 		cin >> arr[i];
	// 		arr[i + n] = arr[i];
	// 	}
	// 	for (int i = 1; i < arr.size(); i++)
	// 		arr[i] += arr[i - 1];
	// 	int ans = LLONG_MIN;
	// 	for (int start = 0; start < n; start++) {
	// 		int curr = 0;
	// 		if (start == 0)
	// 			curr = arr[start + k];
	// 		else
	// 			curr = arr[start + k] - arr[start - 1];
	// 		ans = max(ans, curr);
	// 	}
	// 	cout << ans << "\n";
	// }
	int n;
	string s;
	unordered_set<string> st;
	cin >> n;
	while (n--) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 17752
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a + b > n + 1) out.println("-1");
        else if(n > 1L*a*b) out.println("-1");
        else {
          StringBuilder sb = new StringBuilder();
          int[] lengths = new int[b];
          Arrays.fill(lengths, 1);
          lengths[0] = a;
          int count = a+b-1;
          for(int i=1; i<b; i++) {
            while(count < n) {
              lengths[i]++;
              count++;
              if(lengths[i] == a) break;
            }
          }

          int cur = n;
          for(int i=0; i<b; i++) {
            for(int j=cur-lengths[i]+1; j<=cur; j++)
              sb.append(j+" ");
            cur -= lengths[i];

          }
          out.println(sb.toString());
        }
        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }


}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;
    vector<string> words = {"dream", "dreamer", "erase", "eraser" };

    deque<int> q = { 0 };

    while (q.size() != 0) {
        int p = q.front(); q.pop_front();
        vector<int> uniq;
        for (auto& w: words) {
            if (S.substr(p, w.size()) == w) {
                int next_p = p + w.size();
                if (next_p == S.size()) {
                    YES(true);
                    return 0;
                } else {
                    uniq.push_back(next_p);
                }
            }
        }
        sort_uniq(uniq);
        q.insert(q.end(), ALL(uniq));
    }

    YES(false);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int length = sc.nextInt();
        String blank = sc.nextLine();

        for (int i=0;i<length;i++) {
        	String s = sc.nextLine();
        	String[] orders = s.split(" ");
        	String order = orders[0];
        	if ("print".equals(order)) {
        		print(str,Integer.parseInt(orders[1]),Integer.parseInt(orders[2]));
        	} else if ("reverse".equals(order)) {
        		str = reverse(str,Integer.parseInt(orders[1]),Integer.parseInt(orders[2]));
        	} else if ("replace".equals(order)) {
        		str = replace(str,Integer.parseInt(orders[1]),Integer.parseInt(orders[2]),orders[3]);
        	}

        }
        sc.close();
	}

	public static void print (String str,int from, int to)
	{
		System.out.println(str.substring(from,to + 1));
	}

	public static String reverse (String str,int from, int to)
	{
		String[] strArry = str.split("");
		int length = to - from + 1;
		int n = length / 2;
		for (int i=0;i<n;i++) {
			String w = strArry[from];
			strArry[from] = strArry[to];
			strArry[to] = w;
			from++;
			to--;
		}
		return String.join("", strArry);
	}

	public static String replace (String str,int from, int to,String r)
	{
		String[] strArry = str.split("");
		String[] rArry = r.split("");
		int n = 0;
		for (int i=from;i<=to;i++) {
			strArry[i] = rArry[n++];
		}
		return String.join("", strArry);
	}
}


Measured memory_bytes: 37084
#include <iostream>
#include <string>
#include <set>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

int main() {
  int N, count=0;
  cin >> N;
  vector<int>H(N);
  for (int i = 0; i < N; i++) {cin >> H.at(i);}
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    A.at(i) = 0;
    for (int j = 0; j < i; j++) {
      if (H.at(i)<H.at(j)) {
        A.at(i)++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (A.at(i)==0) {
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
import math

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

s = 0
logK = math.log(k)
log2 = math.log(2)
for i in range(n):
    p = i + 1
    prob = 1
    while p < k:
        p *= 2
        prob *= 0.5
    s += prob
print(s / n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll a,b,n;
    cin>>a>>b>>n;
    // ll ans = 0;
    // for(ll i=1;i<=n;i++){
    //     ll ret = (a*i)/b - a*(i/b);
    //     chmax(ans,ret);
    //     cout << i << " " << ret << " " << ans << endl;
    // }
    ll t = min(b-1,n);
    ll ans = (ll)((a*t)/b) - (ll)((t/b)*a);
    cout << ans << endl;
}

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

using namespace std; 
  int main()
  {
    int n;
    cin>>n;
    double a[n];
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    double dp[n+1][n+1];
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        dp[0][i]=dp[0][i-1]*(1-a[i-1]);
    }
     for(i=1;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            dp[i][j]=dp[i][j-1]*(1-a[j-1])+dp[i-1][j-1]*a[j-1];
        }
    }
    double c=0;
    for(i=n;i>=n/2+1;i--)
    {
        c+=dp[i][n];
        
    }
    cout<<setprecision(10)<<c<<endl;

      return 0;
  }

Measured memory_bytes: 74124
#include<bits/stdc++.h>
using namespace std;
int n,m,x,a[101][101],mi=0x3f3f3f3f,b[100001],c[1000001];
void dfs(int dep,int sum)
{
	if(dep==n+1)
	{
		for(int i=1;i<=m;i++)
		{
			if(b[i]<x)
				return;
		}
		mi=min(mi,sum);
		return;
	}
	for(int i=1;i<=m;i++)b[i]+=a[dep][i];
	dfs(dep+1,sum+c[dep]);
	for(int i=1;i<=m;i++)b[i]-=a[dep][i];
	dfs(dep+1,sum);
}
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];	
	}
	dfs(1,0);
	if(mi>=0x3f3f3f3f)cout<<"-1";
	else cout<<mi;
}


Measured memory_bytes: 3644
#include <iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
    int n, cnt;

    while(cin >> n) {
        cnt = 0;
        for(int i=0; i<=9; i++)
            for(int j=0; j<=9; j++)
                for(int k=0; k<=9; k++)
                    for(int l=0; l<=9; l++)
                        if(i + j + k + l == n)
                            cnt++;

      cout << cnt << endl;
    }

    return 0;
}



Measured memory_bytes: 3016
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int powm(int a, int b, const int& m) {
  int c = 1;
  while (b) {
    if (odd(b)) c = (c * a) % m;
    b >>= 1;
    a = (a * a) % m;
  }
  return c;
}
struct modint {
  int v;
  modint(int a = 0)
    : v(((a % MOD) + MOD) % MOD) {
  }
  modint operator+(const modint& b) const {
    return (v + b.v) % MOD;
  }
  modint operator-(const modint& b) const {
    return (v - b.v + MOD) % MOD;
  }
  modint operator*(const modint& b) const {
    return (v * b.v) % MOD;
  }
  modint operator/(const modint& b) const {
    return (v * powm(b.v, MOD - 2, MOD)) % MOD;
  }
};
bool operator==(const modint& a, const modint& b) {
  return a.v == b.v;
}
modint& operator+=(modint& a, const modint& b) {
  return a = a + b;
}
modint& operator-=(modint& a, const modint& b) {
  return a = a - b;
}
modint& operator*=(modint& a, const modint& b) {
  return a = a * b;
}
modint& operator/=(modint& a, const modint& b) {
  return a = a / b;
}

ostream& operator<<(ostream& out, const modint& a) {
  return out << a.v;
}
istream& operator>>(istream& in, modint& a) {
  int v;
  in >> v;
  a = modint(v);
  return in;
}

void solve() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<modint> factorial(h + w);
  factorial[0] = 1;
  loop(i, 1, factorial.size()) factorial[i] = modint(i) * factorial[i - 1];
  auto ncr = [&](const int& n, const int& r) {
    return factorial[n] / (factorial[n - r] * factorial[r]);
  };
  auto ways = [&](const int& c, const int& r) {
    return ncr(c + r, c);
  };
  modint s = 0;
  loop(i, b, w) s += ways(h - a - 1, i) * ways(a - 1, w - 1 - i);
  cout << s << endl;
}


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

using namespace std;
using ll = long long;

template<class M> class SegmentTree {
public:
	using T = typename M::value_type;
private:
	int m;
	int n;
	vector<T> data;

	T rec(int l, int r, int node, int node_l, int node_r) {
		if(node_r <= l || node_l >= r)return M::id;
		if(node_l >= l && node_r <= r)return data[node];
		int mid = (node_l + node_r) / 2;
		return M::op(
			rec(l, r, node * 2, node_l, mid),
			rec(l, r, node * 2 + 1, mid, node_r)
		);
	}

public:
	SegmentTree(const vector<T>& a) {
		m = a.size();
		for(n = 1; n < (int)a.size(); n <<= 1);
		data.resize(n<<1, M::id);
		for(int i = 0; i < (int)a.size(); i++)data[i + n] = a[i];
		for(int i = n - 1; i >= 1; i--) data[i] = M::op(data[i<<1], data[(i<<1) + 1]);
	}
 
	T get(int l, int r) {
		return rec(l, r, 1, 0, n);
	}
 
	void assign(int index, T val) {
		index += n;
		data[index] = val;
		while(index != 1){
			index >>= 1;
			data[index] = M::op(data[index<<1], data[(index<<1) + 1]);
		}
	}
 
	T operator[] (int i){
		return data[i + n];
	}
 
};
 
template<class T> class Gcd {
public:
    using value_type = T;
    static T op(T l, T r) {return __gcd(l, r);}
    static constexpr T id = 0;
};
 
int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	SegmentTree<Gcd<int>> tree(a);
	int nax = 0;
	for(int i = 0; i < n; i++) {
		tree.assign(i, 0);
		nax = max(nax, tree.get(0, n));
		tree.assign(i, a[i]);
	}
	cout << nax << endl;
}

Measured memory_bytes: 4588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */

bool visited[1000000+9];
int main() {
    ll n;
    cin>>n;
    ll sum = 0;
    for(int i=3;i<=n;i+=3)visited[i]=1;
    for(int i=5;i<=n;i+=5)visited[i]=1;
    for(ll i=1;i<=n;i++){
        if(visited[i])continue;
        sum = sum+i;
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 4612
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 200;

int n, m;
int c[10][10];
int a[MaxN + 5][MaxN + 5];
int cnt[15];

void solve(){
	for(int k = 0; k <= 9; k++)
		for(int i = 0; i <= 9; i++)
			for(int j = 0; j <= 9; j++)
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i <= 9; i++)
		for(int j = 0; j <= 9; j++)
			scanf("%d", &c[i][j]);
	solve();
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			scanf("%d", &a[i][j]);
			cnt[a[i][j]]++;
		}
	}
	LL tot = 0LL;
	for(int i = 0; i <= 9; i++) tot = tot + (LL)cnt[i] * c[i][1];
	printf("%lld\n", tot);
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll x, y;
	cin>>x>>y;
	cout<<max(x-y, 0LL)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    int ans=0;
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=(arr[i]*arr[j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
line = gets
line.chomp!
a = line.to_i

line = gets
line.chomp!
b = line.to_i

line = gets
line.chomp!
c = line.to_i

line = gets
line.chomp!
d = line.to_i

line = gets
line.chomp!
e = line.to_i

line = gets
line.chomp!
k = line.to_i

if (e-a <= k)
  print "Yay!"
else
  print ":("
end


Measured memory_bytes: 1788
using System;
using System.Linq;

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            D();

        }

        static void A()
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            Console.WriteLine(6 - A - B);
        }

        static void B()
        {
            var N = int.Parse(Console.ReadLine());
            var ST = Console.ReadLine().Split();

            for (var i = 0; i < N; i++)
            {
                Console.Write(ST[0][i]);
                Console.Write(ST[1][i]);

            }

            Console.WriteLine();
        }

        static void C()
        {
            long[] AB = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            long A = AB[0];
            long B = AB[1];

            var big = Math.Max(A, B);
            var small = Math.Min(A, B);


            var r = big % small;
            var a = small;
            var b = r;
            while (r != 0)
            {
                r = a % b;
                a = b;
                b = r;
            }
            Console.WriteLine(A * B / a);
        }

        static void D()
        {
            var N = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            long current = 1;
            long breakCount = 0;
            for (long i = 0; i < N; i++)
            {
                if(a[i] == current)
                {
                    current++;
                }
                else
                {
                    breakCount++;
                }
            }

            Console.WriteLine(current == 1 ? -1 : breakCount);

        }

    }
}


Measured memory_bytes: 37060
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        public static void Main(string[] args)
        {
			var n = int.Parse(Console.ReadLine());
			var nn = n;
			var sum = 0;
			var len = 1;
			var dig = 0;

			for (int i = n; i >= 10; i /= 10)
			{
				len++;
			}

			for (var i = 0; i < len; i++) {
				dig = n % 10;
                sum = sum + dig;
                n = n / 10;
            }

			if(nn % sum == 0){
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}
    }
}

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


int main() {
  int h, w, k;  cin >> h >> w >> k;
  ll ans = 0;
  vector<vector<char>> v(h, vector<char>(w));
  rep (i, h) rep (j, w) cin >> v[i][j];

  for (int bith=0; bith<(1 << h); ++bith) for (int bitw=0; bitw<(1 << w); ++bitw) {
    vector<vector<char>> z = v;
    int cnt = 0;

    rep(tmp, h) if (bith & (1<<tmp)) rep(i, w) z[tmp][i] = 'r';
    rep(tmp, w) if (bitw & (1<<tmp)) rep(i, h) z[i][tmp] = 'r';

    rep (i, h) rep(j, w) if (z[i][j] == '#') ++cnt;
    
    if (cnt == k) ++ans;
  }
  
  cout << ans << endl;
}

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

int main()
{
	int n;
	cin >> n;
	int flag = 0;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == n) flag = 1;
		}
	}
	if(flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m, v, p;std::cin >> n >> m >> v >> p;
  vll a(n);re(i, n) std::cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -1, r = n+1;
  while(r-l>1){
    ll mid = (l+r)/2;
    if(n-1-mid<=p-1){
      r = mid;
      continue;
    }
    ll t = n - p - mid - max((ll)0, v - p - mid);
    ll s = 0;
    map<ll, ll, greater<ll>> b;
    for(int i=mid+1;i<=n-p;i++) {
      if(b.find(a[i]-a[mid])==b.end()) b.emplace(a[i]-a[mid], 1);
      else (*b.find(a[i]-a[mid])).second++;
      s+=a[i]-a[mid];
    }
    if(s<=t*m&&a[n-p]-a[mid]<=m){
      //std::cout << mid << "ok" << '\n';
      r = mid;
    }else {
      //std::cout << mid << "out" << '\n';
      l = mid;
    }
    /*
    ll c = 0;
    while((*b.begin()).first>0){

    }*/
  }
  std::cout << n - r << '\n';
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

ll DP[20000];

signed main(){
  int N,W;
  cin >> N >> W;
  ll v,w;
  FOR(i,0,N){
    cin >> v >> w;
    REP(i,0,10001){
      if(DP[i] || i == 0)DP[i+w] = max(DP[i+w],DP[i]+v);
    }
  }
  ll ans;
  FOR(i,0,W+1){
    ans = max(DP[i],ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    if(a <= b && b - (a + w) >= 0)
    {
        cout << b - (a + w);
    }
    else if(a > b && a - (b + w) >= 0)
    {
        cout << a - (b + w);
    }
    else
    {
        cout << "0";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         String s=gs();
         int K=gi();
         StringBuilder sb=new StringBuilder();
         String a="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
         for (int i=0; i<s.length()-1;i++) {
             char c=s.charAt(i);
             int kk=f(c);
             if(kk<=K) {
            	 K-=kk;
            	 sb.append('a');
             } else {
            	 sb.append(c);
             }
         }

         char lc=s.charAt(s.length()-1);
         K=K%26;
         lc=a.charAt(a.indexOf(lc)+K);
         sb.append(lc);

         System.out.println(sb);
     }

     public static int f(char c) {
    	 int r=c-97;
    	 return (26-r)%26;
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 40336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, j;
  cin >> N;
  for(int i=0;i<N;i++){
    string M;
    cin >> M;
    if(M=="Y") j++;
  }
  if (j>0) cout << "Four" << endl;
  else cout << "Three" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 100000000
using namespace std;

int N;
string S[50];

string convert(string s) {
  string t = "";
  t += s[0];
  REP(i, 1, s.length()) {
    switch(s[i - 1]) {
      case 'a':; case 'i':; case 'u':; case 'e':; case 'o': t += s[i];
    }
  }
  return t;
}

int main(void) {
  while(cin >> N, N) {
    vector<string> name;
    int len = 0;
    REP(i, 0, N) {
      cin >> S[i];
      name.push_back(convert(S[i]));
      len = max(len, (int) name[i].length());
    }

    sort(name.begin(), name.end());

    int ans = 0;
    REP(i, 0, N - 1) {
      int len = INF;
      REP(j, 0, min(name[i].length(), name[i + 1].length())) {
        if(name[i][j] != name[i + 1][j]) {
          len = j + 1;
          break;
        }
      }
      if(len == INF && name[i].length() != name[i + 1].length()) {
        len = min(name[i].length(), name[i + 1].length()) + 1;
      }
      ans = max(ans, len);
    }

    cout << (ans != INF ? ans : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>
 
using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define ll long long
#define mod  998244353
const int N = 1e5 + 10;
const int M = 2e6 + 1005;
int main()
{
    int n;
    cin>>n;
    ll Sum = 0,num = 0;
    for(int i = 1;i <= n;++i){
        ll a,b;
        cin>>a>>b;
        Sum += a*b;
        num += b;
 
    }
    num = num - 1 + (Sum - 1) /9;
    cout<<num<<endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    ll su = 0;
    vector<int> ar(100001,0);
    rep(i,n){
        int a; cin >> a;
        su += a;
        ar[a]++;
    }
    int q; cin >> q;
    vector<ll> ans(q);
    rep(i,q){
        int a, b; cin >> a >> b;
        ll sa = (b-a) * ar[a];
        ar[b] += ar[a];
        ar[a] = 0;
        su += sa;
        ans[i] = su;
    }
    rep(i,q) cout << ans[i] << endl;
}

Measured memory_bytes: 4572
### ABC112D Partition Diff:

N, M = map(int, input().split())
from math import sqrt

def divisor(num):
    max_num = int(sqrt(num))
    divisor_list = []
    for i in range(1, max_num + 1):
        if num % i == 0:
            divisor_list.append(i)
            divisor_list.append(num//i)
    return divisor_list

div = divisor(M)
div.sort(reverse=True)
ans = None
for g in div:
    if N > M//g:
        continue
    ans = g
    break
print(ans)

Measured memory_bytes: 63952
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <tuple>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using tiii = tuple<int,int,int>;

bool comp(tiii a, tiii b){
    if(std::get<2>(a) < std::get<2>(b)){
        return true;
    }
    return false;
}

bool comp2(tiii a, tiii b){
    if(std::get<0>(a) < std::get<0>(b)){
        return true;
    }   
    return false;
}

int main(){
    ll n,m;
    cin >> n >> m;
    ll p,y;
    vector<int> arr(100000,0);
    vector<tiii> cities;

    rep(i,m){
        cin >> p >> y;
        cities.push_back(std::make_tuple(i+1,p,y));
    }

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

    rep(i,m){
        int y = std::get<1>(cities[i]);
        arr[y]++;
        std::get<2>(cities[i]) = arr[y];
    }

    sort(cities.begin(),cities.end(),comp2);

    rep(i,m){
        printf("%06d%06d\n",std::get<1>(cities[i]) ,std::get<2>(cities[i]));
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W, M;
  cin >> H >> W >> M;
  
  vector<int> hline(H,0);
  vector<int> wline(W,0);
  
  int h, w;
  set<pair<int,int>> target;
  for (int i = 0; i < M; i++) {
    cin >> h >> w;
    hline.at(h-1)++;
    wline.at(w-1)++;
    target.insert(make_pair(h-1,w-1));
  }
  
  int hmax = 0;
  for (int i = 0; i < H; i++) {
    hmax = max(hmax,hline.at(i));
  }
  
  vector<int> hmaxs(0);
  for (int i = 0; i < H; i++) {
    if (hmax == hline.at(i)) {
      hmaxs.push_back(i);
    }
  }
  
  int wmax = 0;
  for (int i = 0; i < W; i++) {
    wmax = max(wmax,wline.at(i));
  }
  
  vector<int> wmaxs(0);
  for (int i = 0; i < W; i++) {
    if (wmax == wline.at(i)) {
      wmaxs.push_back(i);
    }
  }
  
  int dup = 1;
  
  for (int i: hmaxs) {
    for (int j: wmaxs) {
      pair<int,int> p = make_pair(i,j);
      if (target.count(p) == 0) {
        dup = 0;
        goto end;
      }
    }
  }
  end:
  
  cout << hmax+wmax-dup << endl;
  
  return 0;
}

Measured memory_bytes: 23716
n=int(input())
a=list(map(int,input().split()))
ans=0

l=r=s=0
while l<n:
    if s^a[r]==s+a[r]:
        s+=a[r]
        if r!=n-1:
            r+=1
        else:
            break
    else:
        ans+=r-l
        s-=a[l]
        l+=1

ans+=(r-l+1)*(r-l+2)//2

print(ans)


Measured memory_bytes: 32032