akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.printf("%s\n", a < b && b < c ? "Yes" : "No");
	}
}

Measured memory_bytes: 26340
def main() -> None:
    N = int(input())
    B = [int(x) for x in input().split()]
    ans = B[0] + B[-1]
    for i in range(N - 2):
        ans += min(B[i], B[i+1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8996
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int a,b,k;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i%k == 0) {cout << "OK" << endl;return 0;}
    }
    cout << "NG" << endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}
ll n;
ll ans;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n;
	if(n==1){
		cout << "0";
		return 0;
	}
	int lim = (int)sqrt(n);
	int lim2 = 0;
	for (int i = lim; i > 0;i--){
		if(n%i==0&&(n/i)>i+1){
			lim2 = i;
			break;
		}
	}
	for (int i = 1; i < lim2 + 1;i++){
		if(n%i==0)
			ans += (n / i) - 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,K = [int(i) for i in input().split(' ')]

A = np.array([int(i) for i in input().split(' ')])

A.sort()
zero = A[A==0]
minus = A[A<0]
plus = A[A>0]

def index_count(x):
    cnt = 0
    if x >= 0:
        cnt += len(zero) * N
    cnt += np.searchsorted(A,x//plus,side='right').sum()
    cnt += (N - np.searchsorted(A,-(-x//minus),side='left')).sum()
    cnt -= np.count_nonzero(A*A <= x)

    assert cnt % 2 == 0
    return cnt //2


left = -10**18
right = 10**18

while left + 1 < right:
    mid = (left +right) //2
    a = index_count(mid)
    if a >= K:
        right = mid
    else:
        left = mid

print(right)

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

long N, P, i, j, n;

long long pow2(long a, long b) { 
    if (b == 0) {
        return 1;
    } else if (b == 1) {
        return a;
    } else if (b % 2 == 0) { //b偶数
        long long tmp = pow2(a, b / 2);
        return tmp * tmp;
    } else {
        long long tmp = pow2(a, (b-1) / 2);
        return tmp * tmp * a;
    }
}

int main(void) {
    cin >> N >> P;
    if (N == 1) {
        cout << P << endl;
        return 0;
    }
    long ans = 1;
    //Pを素因数分解
    for (i=2; pow2(i, N)<=P; i++) {
        n = 0;
        while (P % i == 0) {
            P /= i;
            n++;
        }
        if (n >= N) {
            ans *= pow2(i, n / N);
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

stack<char>Q;

char ch[200005];

int main()
{
   

    int a,b,c,d,e,x,y,z,l;

    scanf("%s",ch);

    l=strlen(ch);

    while(!Q.empty()) Q.pop();

    for(a=0;a<l;a++)
    {
        if(ch[a]=='S')
        {
            Q.push('S');
        }
        else
        {
            if(Q.empty())
            {
                Q.push('T');
            }
            else
            {
                if(Q.top()=='S')
                {
                    Q.pop();
                }
                else Q.push('T');
            }
        }
    }

    cout<<(int)Q.size()<<endl;


    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = n + n * n + n * n * n;


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27520
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
	ll l, r;
	cin >> l >> r;


	ll sum = inf;
	for (auto i = l; i < r; i++) {
		for (auto j = i+1; j <=r; j++) {
			sum = min(sum, i*j % 2019);
			if (sum==0) break;
		}
		if (sum==0) break;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
def main():
    k,s=map(int, input().split())
    res=0
    for i in range(k+1):
        for j in range(k+1):
            if(s-(i+j)>=0 and s-(i+j)<=k):
                res+=1
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
#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;

int main(void) {
    ll n;
    cin >> n;
    map<string,ll> mp;
    REP(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }

    ll ma = 0;
    for(auto i: mp) chmax(ma, i.second);
    for(auto i: mp) {
        if(i.second == ma) {
            cout << i.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 23808
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

MOD = 10 ** 9 + 7

x_sum = 0
temp = 0
for i in range(n - 1):
    temp = temp + n - 1 - (2 * i)
    x_sum += (x[i + 1] - x[i]) * temp
    x_sum %= MOD

y_sum = 0
temp = 0
for i in range(m - 1):
    temp = temp + m - 1 - (2 * i)
    y_sum += (y[i + 1] - y[i]) * temp
    y_sum %= MOD

print( (x_sum * y_sum) % MOD )


Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <bitset>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 200005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	ll n, m, ans = 0;
	pair <ll, ll> p[N];
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i].ff >> p[i].ss;
	}
	sort(p, p + n);
	for (int i = 0; i < n; ++i)
	{
		ans = ans + min(p[i].ss, m) * p[i].ff;
		m = m - p[i].ss;
		if(m <= 0)
			break;
	}
	cout << ans;
}

Measured memory_bytes: 3328
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    int sum1 = 0;
    rep(i, N) {
        int taste = L + (i + 1) - 1;
        sum1 += taste;
    }

    int minDiff = MOD;
    int ans = 0;
    rep(i, N) {
        int taste = L + (i + 1) - 1;
        int sum2 = sum1 - taste;
        if (abs(sum1 - sum2) < minDiff) {
            minDiff = abs(sum1 - sum2);
            ans = sum2;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


int main() {
    #ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int l, r, d; cin >> l >> r >> d;
    int ct = 0;
    for_(i, l, r+1) ct += (i % d == 0);
    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

ll dp[110][2][110];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    int K;
    cin >> s >> K;
    
    int n = s.size();
    dp[0][0][0] = 1;
    for(int i = 0; i < n; ++i){
        int D = s[i] - '0';
        for(int j = 0; j < 2; ++j){
            for(int k = 0; k < K+5; ++k){
                for(int d = 0; d <= (j? 9: D); ++d){
                    dp[i+1][j||(d<D)][k+(d!=0)] += dp[i][j][k];
                }
            }
        }
    }

    cout << dp[n][0][K] + dp[n][1][K] << endl;


    return 0;
}

Measured memory_bytes: 3792
n, k = [int(e) for e in input().split()]
h = [int(e) for e in input().split()]

import numpy as np

h = np.array(h,dtype=int)
dp = np.zeros(n,dtype=int)

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    l =i-k if i-k >= 0 else 0
    dp[i] = np.min(dp[l:i]+np.abs(h[i]-h[l:i]))


print(dp[-1])

Measured memory_bytes: 17132
s = input()
a = 0
z = 0
for i in range(int(len(s))):
    if s[i] == 'A' and a == 0:
        a = i + 1
    if s[-i] == 'Z' and z == 0 and i != 0:
        z = len(s) - i + 1
print(z - a + 1)


Measured memory_bytes: 3516
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC095C_HalfandHalf();

#if 1
int main()
{
	ABC095C_HalfandHalf();
	fflush(stdout);
	return 0;
}
#endif

static void ABC095C_HalfandHalf()
{
	int A, B, C, X, Y;
	get3int(A, B, C);
	get2int(X, Y);

	//	全部ハーフでそろえるとき
	int count = tp_max(X, Y) * 2;
	int AllHalfV = count * C;

	//	全部 それぞれで買うとき
	int AllEachV = A * X + B * Y;

	//	共通部分をハーフで買って，あまりはそれぞれ買い足すとき
	int halfV = tp_min(X, Y) * 2 * C;
	//	足りない分を単体で買い足す
	int rest;
	if (X > Y) {
		rest = (X - Y) * A;
	}
	else {
		rest = (Y - X) * B;
	}
	int halfEachV = halfV + rest;
	
	printf("%d\n", std::min({ AllHalfV, AllEachV, halfEachV }));

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define Max 1000
using namespace std;
const int N=3005;
string dp[N];
void solve()
{
   string s,t; cin>>s>>t;
   int n=s.size();
   for(int i=0;i<n;i++)dp[i]="";
   for(int i=0;i<t.size();i++)
   {
       for(int j=n-1;j>=0;j--)
       {
           if(s[j]==t[i])
           {
               if(j)dp[j]=dp[j-1]+s[j];
               else dp[j]=s[j];
           }
       }
       for(int j=1;j<n;j++)
           if(dp[j-1].size()>dp[j].size())dp[j]=dp[j-1];
   }
   cout<<dp[n-1];
   return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 12884
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int k=n%10;
  if(k==2||k==4||k==5||k==7||k==9)
    cout<<"hon"<<endl;
  else if(k==0||k==1||k==6||k==8)
    cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3636
nt = gets.chomp.split
n = nt[0].to_i
t = nt[1].to_i

cts = []
n.times do
    ct = gets.chomp.split
    2.times do |i|
        ct[i] = ct[i].to_i
    end
    cts << ct
end

costs = []
n.times do |i|
    if cts[i][1] <= t
        cost = cts[i][0]
        costs << cost
    end
end

puts costs.any? ? costs.min : "TLE"

Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << b * (c / a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<int> A(n), B(n);
    loop (n, i) cin >> A[i];
    loop (n, i) cin >> B[i];

    ll ans = 0;
    while (1) {
        int flg = 0;
        loop (n, i) {
            int a = (i + n - 1) % n, b = (i + 1) % n;
            ll k = (B[i] - A[i]) / (B[a] + B[b]);
            if (k <= 0) continue;
            B[i] -= k * (B[a] + B[b]);
            ans += k;
            flg = 1;
        }
        if (!flg) break;
    }
    loop (n, i) {
        if (A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>


int main(){
   int a[16384], b[512], c, d, i, j, count;
   
   scanf("%d", &c);
   for (i = 0; i < c; i++){
      scanf("%d", &a[i]);
   }
   scanf("%d", &d);
   for(i = 0; i < d; i++){
      scanf("%d", &b[i]);
   }
   count = 0;
   for(i = 0; i < d; i++){
      for(j = 0; j < c; j++){
          if(b[i] == a[j]){
             count++;
             break;
          }
      }
   }
   printf("%d\n", count);
   
        
    
    return 0;
}



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

int main(void) {
	int N,M;
	string blue[100],red[100];
	int record[100] = { 0 };
	cin >> N ;
	for (int i = 0;i < N;i++)
		cin >> blue[i];
	cin >> M;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (blue[j] == blue[i])
				record[j]++;
		}
	}
	for (int i = 0;i < M;i++) {
		cin >> red[i];
		for (int j = 0;j < N;j++) {
			if (blue[j] == red[i])
				record[j]--;
		}
	}
	sort(record,record+N);
	cout << max(0, record[N - 1]) << endl;
	return 0;
}

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

using namespace std;

constexpr int N = 2000 + 10;
constexpr int MOD = 1e9 + 7;

long long dp[N][N], fact[N * N], n, k;

long long mypow (long long a, long long b) {
    return b ? (mypow (a * a % MOD, b >> 1) * (b & 1 ? a : 1)) % MOD : 1;
}

long long ch (long long a, long long b) {
    return (fact[a] * mypow (fact[b] * fact[a - b] % MOD, MOD - 2)) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    if (k == 1) {
        cout << 1 << '\n';
        return 0;
    }
    fact[0] = 1;
    for (int i = 1; i < N * N; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
    for (int i = 0; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            if (i == 0) {
                if (j == 0)
                    dp[i][j] = 1;
                else {
                    dp[i][j] = ch (j * (k - 1) - 1, k - 2) * dp[i][j - 1];
                    dp[i][j] %= MOD;
                }
                continue;
            }
            dp[i][j] = dp[i - 1][j] + ch (i + j * (k - 1) - 1, k - 2) * dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    cout << (dp[n][n] * fact[n]) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 62080
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/
const ll MOD = 1e9 + 7;
ll mod( ll n, ll m = MOD ) { n %= m, n += m, n %= m; return n; }

int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	ll n, k;
	cin >> n >> k;
	vector < ll > v(n + 1);
	vector<ll> sm(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> v[i];
		sm[i] = mod(sm[i - 1] + v[i], k);
	}
	for (ll i = 1; i <= n; i++) {
		sm[i] = mod(sm[i] - i, k);
	}

	map<ll, ll> cnt;
	ll cur = 0;
	ll ans = 0;
	for (ll i = n; i >= 0; i--) {
		ans += cnt[sm[i]];
		cnt[sm[i]]++;
		cur++;
		while (cur >= k) {
			cnt[sm[i + k - 1]]--;
			cur--;
		}
	}
	cout << ans << endl;
}

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

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

	int n, a, b;
	cin >> n;
	cin >> a >> b;
	if (n%2 == 0 && (b-a)%2 == 0){
		cout << "Alice" << "\n";
	}else if (n%2 == 0 && (b-a)%2 == 1){
		cout << "Borys" << "\n";
	}else if (n%2 == 1 && (b-a)%2 == 0){
		cout << "Alice" << "\n";
	}else{
		cout << "Borys" << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int n, chain;
string T[100]; char V;
int main() {
	while (true) {
		for (int i = 0; i < 100; i++) { T[i] = ""; }
		cin >> n;
		if (n == 0) { break; }
		cin >> T[0];
		for (int i = 1; i <= n; i++) {
			V = T[i - 1][0]; chain = 1;
			for (int j = 1; j < T[i - 1].size(); j++) {
				if (T[i - 1][j] == V) {
					chain++;
				}
				else {
					T[i] += to_string(chain);
					T[i] += V;
					V = T[i - 1][j];
					chain = 1;
				}
			}
			T[i] += to_string(chain);
			T[i] += V;
			chain = 1;
		}
		cout << T[n] << endl;
	}
}

Measured memory_bytes: 3264
r, c, n = map(int, input().split())
points = []
xx = [0, r]
yy = [0, c]
def add(x, y):
    if x == 0:
        points.append(r*2+c+c-y)
    elif x == r:
        points.append(r+y)
    elif y == 0:
        points.append(x)
    else:
        points.append(r+c+r-x)
for i in range(n):
    x0, y0, x1, y1 = map(int, input().split())
    if (x0 in xx or y0 in yy) and (x1 in xx or y1 in yy):
        add(x0, y0)
        add(x1, y1)
index = list(range(len(points)))
index.sort(key = lambda a:points[a])
que = []
flag = True
for i in index:
    if que and que[-1]//2 == i//2:
        que.pop()
    else:
        que.append(i)
if que:
    print('NO')
else:
    print('YES')
    

Measured memory_bytes: 88152
import static java.lang.Double.*;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		int n = 0;
		while (  ( n = sc.nextInt() ) != 0 ) {
			sc.nextLine();

			String[] data = sc.nextLine().split(" ");

			double m = 0;
			for (int i = 0; i < n; i++) {
				m += Double.parseDouble(data[i]);
			}
			m = m / n;

			double aa = 0;
			for (int i = 0; i < n; i++) {
				double sm = parseDouble(data[i]) - m;
				aa += sm*sm;
			}
			aa = aa / n;

			double a = Math.sqrt(aa);

			sb.append(a + "\n");
		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 29624
# https://atcoder.jp/contests/abc064/tasks/abc064_c


RES = Hash.new(0)
n = gets.to_i
nums = gets.split.map(&:to_i)

wilds = 0
nums.each do |n|
  if n >= 3200
    wilds += 1
    next
  end
  color = n / 400
  RES[color] += 1
end

# p RES
current_colors = RES.keys.size
puts [[current_colors, wilds > 0 ? 1 : 0].max, current_colors + wilds].join(' ')

Measured memory_bytes: 1788
#include <stdio.h>
int main(void)
{
    int n,m,k,b,c,x;
    scanf("%d",&n);
    int a[n];
    for(m=1;m<n+1;m++)
    {
        scanf("%d\n",&a[m]);
    }
    b=1;
    x=0;
    a[0]=0;
    for(k=1;k<n;k++)
    {
        if(b>0 && b!=2)
        {
            c=b;
            b=a[c];
            a[c]=0;
            x++;
        }
    }
    if(b==2)
    {
        printf("%d",x);
    }
    else
    {
        printf("-1");
    }
}


Measured memory_bytes: 512
//Dice1
#include<iostream>
#include<string>
using namespace std;

class Dice{
	private:
		int men[6];
		int ue,sita,migi,hidari,mae,usiro,ho;
	public:
		void setmen(int n, int i);
		void set();
		void setue(string c);
		void stout();
		void ueout(int t);
		int out(int s);
};

void Dice::setmen(int n, int i){
	men[i] = n;
}

void Dice::set(){
	ue = men[0];
	sita = men[5];
	migi = men[2];
	hidari = men[3];
	mae = men[4];
	usiro = men[1];
}

void Dice::setue(string c){
	for(int i = 0; i < c.size(); i++){
		switch(c[i]){
			case 'W':
				ho = ue;
				ue = migi;
				migi = sita;
				sita = hidari;
				hidari = ho;
				break;
			case 'S':
				ho = ue;
				ue = mae;
				mae = sita;
				sita = usiro;
				usiro = ho;
				break;
			case 'N':
				ho = ue;
				ue = usiro;
				usiro = sita;
				sita = mae;
				mae = ho;
				break;
			case 'E':
				ho = ue;
				ue = hidari;
				hidari = sita;
				sita = migi;
				migi = ho;
				break;
		}
	}
}

void Dice::stout(){
	cout << ue << endl;
}

void Dice::ueout(int t){
	for(int i = 0; i < 6; i++){
		if(men[i] == t){
			switch(i){
				case 0:
					break;
				case 1:
					ho = ue;
					ue = usiro;
					usiro = sita;
					sita = mae;
					mae = ho;
					break;
				case 2:
					ho = ue;
					ue = migi;
					migi = sita;
					sita = hidari;
					hidari = ho;
					break;
				case 3:
					ho = ue;
					ue = hidari;
					hidari = sita;
					sita = migi;
					migi = ho;
					break;
				case 4:
					ho = ue;
					ue = mae;
					mae = sita;
					sita = usiro;
					usiro = ho;
					break;
				case 5:
					ho = ue;
					ue = usiro;
					usiro = sita;
					sita = mae;
					mae = ho;
					ho = ue;
					ue = usiro;
					usiro = sita;
					sita = mae;
					mae = ho;
					break;
			}
			
			break;
		}
	}
			
}


int Dice::out(int s){
	if(s == usiro)
		return migi;
	else if(s == migi)
		return mae;
	else if(s == mae)
		return hidari;
	else if(s == hidari)
		return usiro;
	return 0; 
}

int main()
{
	Dice A;
	string c;
	int n, m, t, s;
	for(int i = 0; i < 6; i++){
		cin >> n;
		A.setmen(n, i);
	}
	A.set();
	
	cin >> m;
	
	for (int i = 0; i < m; i++){
		A.set();
		cin >> t >> s;
		A.ueout(t);
		cout << A.out(s) << endl;
	}
	
	
	//A.setue(c);
	//A.stout();
	return 0;
}


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

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

    if (a >= 13)
        cout << b << endl;
    else if (a >= 6)
        cout << b/2 << endl;
    else
        cout << "0" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    vector<int> town(n + 1);
    vector<bool> visit(n + 1, false);
    for (int i = 1; i <= n; i++)
    {
        int to;
        cin >> to;
        town[i] = to;
    }
    int now = town[1];
    visit[now] = true;
    vector<int> loop;
    visit[1] = true;
    k--;
    while (k != 0)
    {
        now = town[now];

        if (!visit[now])
        {
            visit[now] = true;
        }
        else
        {
            if (find(loop.begin(), loop.end(), now) != loop.end())
            {
                k--;
                break;
            }
            loop.push_back(now);
        }
        k--;
    }
    if (k > 0)
    {
        long long pos = k % loop.size();
        cout << loop[pos];
    }
    else
        cout << now;
}

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

int main() {
  ll n,x,t;
  cin>>n>>x>>t;
  cout<<((n+x-1)/x)*t<<endl;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main()
{
	int i, N, ans[55] = {11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381};
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) printf("%d ", ans[i]);
	printf("%d\n", ans[N-1]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

unsigned long long  int a, b, c;
int main(){
    scanf("%llu%llu%llu",&a,&b,&c);
    if(c < a+b){
      puts("No");
      return 0;
    }
    puts(4*a*b<(c-a-b)*(c-a-b)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 128
#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 n, k;
  cin>>n>>k;
  vector<P> v(n);
  rep(i, n){
    int a, b;
    cin>>a>>b;
    v[i] = P(a, b);
  }
  sort(all(v));
  rep(i, n){
    k -= v[i].snd;
    if(k<=0){
      cout<<v[i].fst<<endl;
      break;
    }
  }
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<': '<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<':';for(int i=0;i<v.size();i++) cerr<<' '<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?'Yes':'No')<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << ' '  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << ' ' ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << ' ' ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int count(string s){
    int ans = 0;
    REP(i, s.size()-2){
        if(s[i]=='A' && s[i+1]=='B')ans++;
    }
    return ans;
}

int main(void)
{
    int n;
    cin >> n;
    int a = 0, b = 0, ab = 0;
    int ans = 0;
    REP(i, n){
        string s;
        cin >> s;
        ans += count(s);
        if(s[0] == 'B' && s[s.size()-1] == 'A') ab++;
        else if(s[0] == 'B') b++;
        else if(s[s.size()-1] == 'A') a++;
    }
    if(a>0&&b>0){
        ans += ab+1;
        a -= 1;
        b -= 1;
    }else if(a>0){
        ans += ab;
        a -= 1;  
    }else if(b>0){
        ans += ab;
        b -= 1;  
    }else{
        ans+=(ab==0)?0:ab-1; 
    }
    ans += min(a,b); 
    pr(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 100000;
const int mod = 1000000007;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
/* global variables */
/* function */
/* main */
int main(){
    ll N, K;
    cin >> N >> K;
    vector<mint> p(100005, 0);
    mint ans = 0;
    for (ll i = K; i >= 1; i--) {
        mint a = K / i;
        p[i] = a.pow(N);
        for (int j = i + i; j <= K; j += i)
            p[i] -= p[j];
        ans += p[i] * i;
    }
    cout << ans.x << '\n';
}


Measured memory_bytes: 4052
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
using namespace std;
// #define endl '\n'
#define br cout<<endl
#define mem(a) memset(a,0,sizeof(a))
const double pi=3.141592653589793238;
#define d(x) cout<<x<<endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define rev(a) reverse(a.begin(),a.end())
const int inf = 100000000000000000;
#define maxn 1000005
#define mod 1000000007
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) x.begin(),x.end()
#define f(i,n) for(int i=1;i<=n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i+=1)
#define fn(i,k,n) for(int i=k;i>=n;i-=1)
void pv(vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<endl;}
void pa(int a[],int n,int p){for (int i = p; i < n+p; ++i){cout<<a[i]<<" ";}cout<<endl;}
int modexp(int x,int y) {
   int res = 1;
   x = x % mod;
   while (y > 0){
       if (y & 1LL)
           res = (res*x) % mod;
       y = y>>1;
       x = (x*x) % mod;  
   }
   return res;
}
int invmod(int a) {
    return modexp(a,mod-2);
}
vector<int> edge[maxn];
void ipgraph(int n,int m) {
    fp(i,1,n) edge[i].clear();
    if(m==0) return;
   fp(i,1,m) {
       int a,b;
       cin>>a>>b;
       edge[a].pb(b);
       edge[b].pb(a);
   } 
}
/*
void dfs(int node,int p)
{
    for(int u : edge[node]) 
    {
        if(u!=p)
        {
            dfs(u,node);
        }
    }
}
*/
///////////////////////////////////////////////////////////////////////////////////
void solve()
{
    int n;
    cin>>n;
    int ans = (modexp(9,n) - modexp(8,n) + mod)%mod;
    ans*=2;
    ans%=mod;
    ans += modexp(8,n);
    ans%=mod;
    ans = (modexp(10,n) - ans + mod)%mod;
    d(ans)
}
int32_t main()
{
   IOS;
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
    #endif
   int t=1;
    //cin>>t;
   fp(i,1,t)
   {
       //cout<<"Case "<<i<<": ";
       solve();
   }
}


Measured memory_bytes: 27076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9
int N;

int main()
{
	cin>>N;



	int ans = (N-2)*180;


	cout << ans << endl;

	return 0;
}

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

int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >>c;
  priority_queue<ll> aa;
  priority_queue<ll> ba;
  priority_queue<ll> ca;
  
  rep(i,0,a) {
    ll val;
    cin >> val;
    aa.push(val);
  }
  rep(i,0,b) {
    ll val;
    cin >> val;
    ba.push(val);
  }
  rep(i,0,c) {
    ll val;
    cin >> val;
    ca.push(val);
  }
  ll ans=0;
  rep(i,0,x){
    ll aav = aa.top();
    ll cav = ca.top();
    if(aav>=cav){
      ans += aav;
      aa.pop();
    }
    else{
      ans += cav;
      ca.pop();
      ca.push(aav);
      aa.pop();
    }
  }
  rep(i,0,y){
    ll bav = ba.top();
    ll cav = ca.top();
    if(bav>cav){
      ans += bav;
      ba.pop();
    }
    else{
      ans += cav;
      ca.pop();
      ca.push(bav);
      ba.pop();
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    string s, t;
    cin >> s >> t;

    int n = sz(s); s = ' ' + s;
    int m = sz(t); t = ' ' + t;

    int ans = maxx;
    for (int i = 1; i <= n - m + 1; i++) {
        int cnt = 0;
        for (int j = 1; j <= m; j++) {
            if (s[i + j - 1] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }

    cout << ans << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define SPACE << " " <<
#define EXCEPTERROR cout << "-1" << endl;
#define rep(k,n)   for(int i=k; i<n;  i++)
#define rep2(k,n)  for(int j=k; j<n;  j++)
#define for(a,b,c) for(ll  i=a; i<b;  i+=c)
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
typedef long long ll;
inline int  divUp(ll a, ll b) {return (a+(b-1)/b);}
inline void chMin(ll a, ll b) {if(a>b) a=b;}
inline void chMax(ll a, ll b) {if(a<b) a=b;}

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(0,s.length(),1){
        if(s[i]+n>0x5a){
            s[i] = s[i]+n-26; 
            continue;
        }
        s[i] += n;
    }
    for(0,s.length(),1) cout << s[i];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  int D = 0, cnt=1, L=0;
  for(int i=0; i<N; i++){
    cin >> L;
    if(D+L <= X) cnt++;
    D = D+L;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toLong() }
    val p = Array (N.toInt()) {
        val l = readLine()!!.split(" ").map { it.toLong() }
        Pair(l[0], l[1])
    }

    p.sortBy {it.first}

    var res = 0L
    var m = M

    for (l in p) {
        if (m <= 0) break

        res += l.first * Math.min(l.second,  m)
        m -= Math.min(l.second, m)
    }

    println(res)
}


Measured memory_bytes: 83624
#include <iostream>
#include<algorithm>
#define MAX 20000000000001
using namespace std;

int main() {
    int V, E, tmp_f, tmp_s ,tmp , k=0;
    cin >> V >> E;
    long long int A[V][V];
    for (int i=0; i<V; i++) {
        for (int j=0; j<V; j++) {
            if (i==j) {
                A[i][j] = 0;
            } else {
                 A[i][j] = MAX;
            }
        }
    }
    for (int i=0; i<E; i++) {
        cin >> tmp_f >> tmp_s;
        cin >> tmp;
        A[tmp_f][tmp_s] = tmp;
    }
    for (int k=0; k<V; k++) {
        for (int i= 0; i<V; i++) {
            if(A[i][k] == MAX) continue;
            for (int j=0; j<V; j++) {
                if(A[k][j] == MAX) continue;
                A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
            }
        }
    }
    for (int i=0; i<V; i++) {
        if (A[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    
    
    for (int i=0; i<V; i++) {
        for (k=0; k<V; k++) {
            if (A[i][k] != MAX) {
                cout << A[i][k];
            } else {
                cout << "INF";
            }
            if (k == V-1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3172
function Main(input) {
    const n = input.split("\n")[0];
    var ans = 0 
    for(var i = 1; i <= n; i++){
        if (n >= i * 100 && n <= i* 105) {
            ans = 1
            break;
        }
    }
    console.log(ans)
    }    
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
  int d, n; cin >> d >> n;
  ll p = pow(100, (double)d);
  ll res;
  while(n > 0) {
    if(n == 100) res += p;
    res += p;
    n--;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
n = int(input())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
ans = 0
rm = 0
for i in range(n) :
    if rm >= a[i] :
        ans += a[i]
        rm = b[i]
    elif rm+b[i] >= a[i]:
        ans += a[i]
        rm = rm+b[i] - a[i]
    else :
        ans += rm + b[i]
        rm = 0
ans += min(rm,a[n])
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001;

string s;
deque<int> oc[26];
bool done[MX];
int good[MX];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    F0R(i,sz(s)) oc[s[i]-'a'].pb(i);
    
    int z = 0;
    F0R(i,26) if (sz(oc[i])&1) z ++;
    if (z > 1) {
        cout << -1;
        exit(0);
    }
    int nex = 0;
    F0R(i,sz(s)) if (!done[i]) {
        if (sz(oc[s[i]-'a']) == 1) {
            good[i] = sz(s)/2;
        } else {
            good[i] = nex;
            good[oc[s[i]-'a'].back()] = sz(s)-1-nex;
            nex ++;
            
            done[oc[s[i]-'a'].back()] = 1;
            oc[s[i]-'a'].pop_front();
            oc[s[i]-'a'].pop_back();
        }
    }
    
    Tree<int> T;
    
    ll ans = 0;
    F0R(i,sz(s)) {
        ans += sz(T)-T.order_of_key(good[i]);
        T.insert(good[i]);
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 10772
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int answer=0;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(s.at(i)==s.at(j)){
        answer++;
      }
    }
  }
  if(answer==8){
    cout<<"Yes"<<endl;
  }
  else if(answer!=8){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int[]V=new int[N];
        int[]C=new int[N];
        int count=0;
        for(int i=0;i<N;i++){
          V[i]=sc.nextInt();
        }
        for(int i=0;i<N;i++){
          C[i]=sc.nextInt();
        }

        for(int i=0;i<N;i++){
          if(V[i]>C[i]){
            count+=V[i]-C[i];
          }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <thread>
#include <cmath>
#include <cstring>
#include <string>
#include <typeinfo>
using namespace std;

vector<float> hoge;

void input(int N){
    int temp;
    for(int i = 0;i<N;i++){
        cin >> temp;
        hoge.push_back(temp);
    }
}

int main(){
    int N;
    double sum =0;
    cin >> N;
    input(N);
    for(int i=0;i<N;i++)sum += 1/hoge.at(i);
    cout << 1/sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

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

    ll ans = INF;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll a = i;
        ll b = n / a;
        ans = min(ans, a + b - 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	string S;
	cin >> S;
	int sum,mi=1000;
	for(int i=0; i<S.size()-2; i++){
		sum=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
		mi=min(mi,abs(sum-753));
	}
	cout << mi << endl;
}


Measured memory_bytes: 256