akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll sum = c - a - b;
  if(sum > 0 && sum * sum > 4 * a * b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  ll A;
  string B;
  cin >> A >> B;
  int C = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
  cout << ll(A*C/100) << endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define fo(i, u, v) for(int i = u; i <= v; ++i)
#define fob(i, u, v) for(int i = u; i >= v; --i)
#define fi first
#define se second
#define si size()
#define pb push_back

using namespace std;
typedef double db;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll N = 1e6+7;
const ll inf = ll(1e18);
const ll  MOD = 1e9+7;
const string name = "template";
template <class T> int getbit(T x, int y) {return x >> (y-1) & 1;}
template <class T> T sqr(T x) {return x*x;}
template <class T> void read_int(T &rs) {
    char c;
    int sign = 1;
    for(c = getchar(); c < '0' || c > '9'; c = getchar())
        if(c == '-') sign *= -1;
    rs = (c - '0');
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        rs = rs*10 + (c - '0');
    rs *= sign;
}

ll n, a, b;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((name + ".inp").c_str(), "r", stdin);
    //freopen((name + ".out").c_str(), "w", stdout);
    cin>>n>>a>>b;
    if(abs(a - b) % 2 == 0) cout<<"Alice";
    else cout<<"Borys";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int A,B,C,D,P;
  cin >>A>>B>>C>>D>>P;

  int x,y;
  x = P*A;
  if(P<=C) y=B;
  else y=B+(P-C)*D;

  if(y>x) cout << x << endl;
  else cout << y << endl;
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    vector <int > H ( N );
    for ( int i = 0; i < N ; ++ i )
	{
        cin >> H [ i ];
    }
    int ans = 0;
    for ( int i = 0; i < N ; ++ i )
	{
        bool is_candidate = true ;
        for ( int j = 0; j < i ; ++ j )
		{
            if(H[j]>H[i]){
		    
                is_candidate = false ;
                break ;
            }
        }
        if ( is_candidate )
		{
            ++ ans ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    bool ok = 1;
    string S,T;
    cin >> S >> T;
    reverse(ALL(S));
    if(S == T){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }
}

Measured memory_bytes: 3576
H, W = map(int, input().split())
c = [[0]*10 for i in range(10)]
for i in range(10):
    a = list(map(int, input().split()))
    for j in range(10):
        c[i][j] = a[j]

A = [[0]*W for i in range(H)]

for i in range(H):
    a = list(map(int, input().split()))
    for j in range(W):
        A[i][j] = a[j]

for k in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if i != j:
                    c[i][j] = min(c[i][j], c[i][k]+c[k][j])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1 and A[i][j] != 1:
            ans += c[A[i][j]][1]
print(ans)

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 &&B==5 && C==5)){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();
	int cntMax=N/2;
	if(N % 2 == 1) {
	    cntMax += 1;
	}
	if(cntMax>=K) {
	    System.out.println("YES");
	}else {
	    System.out.println("NO");
	}
    }
}

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

int n, a, b;

int main(){
    scanf("%d%d%d", &n, &a, &b);
    if(1LL * a * b < n || a + b - 1 > n){ puts("-1"); return 0; }
    for(int i = 0, c = n - a, d = 1; i < a; i++){
        for(int j = min(b - 1, c); j >= 0; j--) printf("%d ", d + j);
        d += min(b - 1, c) + 1;
        c = max(0, c - (b - 1));
    }
}

Measured memory_bytes: 2176
N,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
w1 = A[0][0]
C = {0:[],1:[],2:[],3:[]}
for i in range(N):
    w,v = A[i]
    C[w-w1].append(v)
C[0] = sorted(C[0],reverse=True)
C[1] = sorted(C[1],reverse=True)
C[2] = sorted(C[2],reverse=True)
C[3] = sorted(C[3],reverse=True)
n0 = len(C[0])
n1 = len(C[1])
n2 = len(C[2])
n3 = len(C[3])
vmax = 0
for a0 in range(n0+1):
    for a1 in range(n1+1):
        for a2 in range(n2+1):
            for a3 in range(n3+1):
                if a0*w1+a1*(w1+1)+a2*(w1+2)+a3*(w1+3)<=W:
                    v = sum(C[0][:a0])+sum(C[1][:a1])+sum(C[2][:a2])+sum(C[3][:a3])
                    vmax = max(vmax,v)
print(vmax)

Measured memory_bytes: 77284
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;

int main(void) {
	int N, X, D = 0, ans = 0;

	cin >> N >> X;
	vint L(N);
	for (int i = 0; i < N; i++)cin >> L[i];
	for (int i = 0; i < N; i++) {
		if (D <= X)ans++;
		D += L[i];

	}
	if (D <= X)ans++;
	cout << ans << endl;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const ll MX = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++){
        if (A[i] == 0){
            cout << 0 << "\n";
            return 0;
        }
    }
    ll ans = 1;
    ll i = 0;
    while (MX/ans >= A[i]){
        ans *= A[i];
        i++;
        if (i==N) break;
    }
    if (i<N) cout << -1 << "\n";
    else cout << ans << "\n";
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<vector<int>> d = vector<vector<int>>(4*k+1, vector<int>(4*k+1, 0));
  for(int i=0;i<n;++i){
    int x,y;
    char c;
    cin>>x>>y>>c;
    if(c=='B'){
      x += k;
    }
    x = x%(2*k);
    y = y%(2*k);
    d[max(y-k+1,0)][max(x-k+1,0)] += 1;
    d[y+1][x+1] += 1;
    d[y+1][max(x-k+1,0)] += -1;
    d[max(y-k+1,0)][x+1] += -1;

    int xs = (x+k)%(4*k);
    int ys = (y+k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x+2*k)%(4*k);
    ys = (y+2*k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x+3*k)%(4*k);
    ys = (y+3*k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x)%(4*k);
    ys = (y+2*k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x+2*k)%(4*k);
    ys = (y)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x+k)%(4*k);
    ys = (y+3*k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;

    xs = (x+3*k)%(4*k);
    ys = (y+k)%(4*k);
    d[max(ys-k+1,0)][max(xs-k+1,0)] += 1;
    d[ys+1][xs+1] += 1;
    d[ys+1][max(xs-k+1,0)] += -1;
    d[max(ys-k+1,0)][xs+1] += -1;
  }

  for(int hi=0;hi<4*k;++hi){
    for(int wi=0;wi<4*k;++wi){
      d[hi][wi+1] += d[hi][wi];
    }
  }
  for(int hi=0;hi<4*k;++hi){
    for(int wi=0;wi<4*k;++wi){
      d[hi+1][wi] += d[hi][wi];
    }
  }

  int res = 0;
  for(int hi=0;hi<4*k;++hi){
    for(int wi=0;wi<4*k;++wi){
      res = max(res, d[hi][wi]);
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 62976
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

#define M 1046527
#define NIL (-1)

vector<string> H(M);
//文字から数値に変換
int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T')return 4;
	else return 0;
}

//文字列から数値を変換してkeyを生成する
ll getKey(string str) {
	ll sum = 0, p = 1;
	for(int i=0;i<str.size();i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(string str) {
	ll key, i, h;
	key = getKey(str);	//文字列を数値に変換
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str)return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}
int insert(string str) {
	ll key, i, h;
	key = getKey(str);	//文字列を数値に変換
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (H[h]==str) return 1;
		else if (H[h].size() == 0) {
			H[h] = str;
			return 0;
		}
	}
	return 0;
}
int main(void) {
	int n;
	string com, str;
	for(int i=0;i<M;i++) H[i][0] = '\0';
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> com >> str;
		if (com[0] == 'i')
			insert(str);
		else {
			if (find(str)) {
				cout << "yes" << endl;
			}
			else
				cout << "no" << endl;
		}
	}
	return 0;
}




Measured memory_bytes: 27448
#include<iostream>
using namespace std;
int t[]={500,100,50,10,5,1};
int main(){
  while(1){
    int n,ans=0;
    cin>>n;
    if(n==0)break;
    n=1000-n;
    for(int i=0;i<6;i++)ans+=n/t[i],n%=t[i];
    cout<<ans<<endl;
  }
  return 0;
}

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

static const int MAX_N = 50000;
static const int MAX_M = 20;
static const int INF = (1 << 30);

int main(void) {
    int n, m;
    int C[MAX_M+1];
    int T[MAX_N+1];

    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> C[i];
    }
    T[0] = 0;
    for (int i = 1; i <= n; i++) {
        T[i] = INF;
    }

    for (int i = 1; i <= m; i++) {
        for (int j = C[i]; j <= n; j++) {
            T[j] = min(T[j], T[j - C[i]] + 1);
        }
    }

    cout << T[n] << endl;

    return 0;
}

Measured memory_bytes: 1356
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())


"""
"""

#solution:

#input
def resolve():
    A=sorted(list(pin()))
    B=[a%2 for a in A]
    ans=0
    odd=[]
    even=[]
    for i in range(len(B)):
        if B[i]==0:odd.append(i)
        else:even.append(i)
    if len(odd)==1:
        for x in even:
            A[x]+=1
        ans+=1
    elif len(even)==1:
        for y in odd:
            A[y]+=1
        ans+=1
    ans+=(A[2]*2-A[1]-A[0])//2
    print(ans)
    return 0
    #print(["No","Yes"][cond])
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 5 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2 6 3"""
        output = """5"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """31 41 5"""
        output = """23"""
        self.assertIO(input, output)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 83800
from collections import deque

S = input()
Q = int(input())
ARR = []

for i in range(Q):
    arr = input().split(" ")
    ARR.append(arr)


def calculate(s,q,arr):
    s = deque(list(s))

    kk = 0
    for ar in arr:
        if int(ar[0]) == 1:
            kk = kk + 1
        if int(ar[0]) == 2:
            if int(ar[1]) == 1:
                if kk % 2 == 0:
                    s.appendleft(ar[2])
                else:
                    s.append(ar[2])
            else:
                if kk % 2 == 0:
                    s.append(ar[2])
                else:
                    s.appendleft(ar[2])

    if kk % 2 == 1:
        s.reverse()

    print("".join(list(s)))

calculate(S,Q,ARR)

Measured memory_bytes: 44644
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,K = map(int, input().split())
L = [tuple(map(int, input().split())) for i in range(N)]
L.sort()

ans = 10**20

for lx in range(N):
    for rx in range(lx+1,N+1):
        L2 = L[lx:rx]
        L2 = sorted(L2, key=lambda x:x[1])
        for ly in range(len(L2)):
            L3 = L2[ly:ly+K]
            if len(L3) >= K:
                ans = min(ans, (L[rx-1][0]-L[lx][0])*(L3[-1][1]-L3[0][1]))

print(ans)

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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  
  vector<int> choko(n);
  for (int i = 0; i < n; i++) {
    cin >> choko.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; ; j++) {
      if (j * choko.at(i) + 1 <= d) {
        count++;
      }
      else {
        break;
      }
    }
  }
  cout << x + count << endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

rgb :: [Char] -> Int
rgb s = go 0 0 0 s
    where go :: Int -> Int -> Int -> [Char] -> Int
          go r g b []     = r*g*b
          go r g b (x:xs) 
              | x == 'R'  = go (r+1) g b xs
              | x == 'G'  = go r (g+1) b xs
              | x == 'B'  = go r g (b+1) xs
              | otherwise = undefined

main :: IO ()
main = do
    n <- readLn
    s <- VU.unfoldrN n BS.uncons <$> BS.getLine
    print $ rgb (VU.toList s) - length [ () | i <- [0..n-3], j <- [1..(n-i-1)`div`2], s VU.! i /= s VU.! (i+j), s VU.! (i+j) /= s VU.! (i+2*j), s VU.! i /= s VU.! (i+2*j)]

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int 
#define endl '\n'
ll mod=1e9+7;


int main()
{
   FASTio;
    int n,i,j;
    cin>>n;
    string s;
    cin>>s;
    int r=0,w=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
            w++;
        if(s[i]=='R')
            r++;
    }
    int temp=0;
    for(i=0;i<r;i++)
    {
       if(s[i]=='W')
            temp++;
    }
    
    cout<<temp<<"\n";
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    if(N == 2){
        cout << 1 << endl;
        return 0;
    }
    ll count = 0;
    queue<ll> yak;
    for (int i = 2; i <= sqrt(N); ++i) {
        ll tmpN = N;
        while(tmpN % i == 0){
            tmpN = tmpN / i;
        }
        if(tmpN % i == 1){
            //cout << i << endl;
            count++;
        }
    }
    for (int i = 1; i < sqrt(N-1); ++i) {
        if((N - 1) % i == 0){
            ll B = (N -1)/i;
            //cout << B << endl;
            count++;
        }
    }
    cout << count + 1 << endl;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e17;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)
// vector<int> v;
// int ans=0;
// void brute(int pos)
// {
//     if(pos==n)
//     {
//         int te=0;
//         for(int k=0;k<q;k++)
//         {
//             if(v[b[i]-1]-v[a[i]-1]==c[])
//         }
//     }
//     for(int i=0;i<=10;i++)
//     {
//         v.push_back(i);
//         brute(pos+1);
//         v.pop_back(i);
//     }
// }
int32_t main()
{
    IOS
 

    int a,b,n;
    cin>>a>>b>>n;
    int maxi=min(b-1,n);
    cout<<(a*maxi)/b;

}       


Measured memory_bytes: 3636
import numpy as np
import sys


def validation(c, a, b):
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                return False
    print('Yes')
    sys.exit()
    return True


c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = np.array([c_1, c_2, c_3])
for i in range(101):
    a = []
    b = []
    a.append(i)
    b.append(c[0][0] - a[0])
    b.append(c[0][1] - a[0])
    b.append(c[0][2] - a[0])
    a.append(c[1][0] - b[0])
    a.append(c[2][0] - b[0])
    validation(c, a, b)
print('No')

Measured memory_bytes: 12500
# -*- coding: utf-8 -*-
# import time
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


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


def read_int_n():
    return list(map(int, buff_readline().split()))

gpw = None


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            tmp = (tmp*base + s[i]) % mod
            h[i+1] = tmp

        global gpw
        if gpw is None:
            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod
            gpw = pw
        else:
            self.pw = gpw

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def slv(N, A, B):
    L = max(max(A), max(B)).bit_length()
    ah = []
    bh = []
    bnh = []
    for i in range(L):
        ta = []
        tb = []
        tbn = []
        for a, b in zip(A, B):
            ta.append(a >> i & 1)
            tb.append(b >> i & 1)
            tbn.append(tb[-1] ^ 1)
        ah.append(RH(ta, 641, 10**9+7))
        bh.append(RH(tb, 641, 10**9+7))
        bnh.append(RH(tbn, 641, 10**9+7))

    x = [0] * N
    for i in range(L):
        for k in range(N):
            l = ah[i].calc(k, N)
            r = ah[i].calc(0, k)
            if x[k] is None:
                continue
            if l == bnh[i].calc(0, N-k) and r == bnh[i].calc(N-k, N):
                x[k] += 1 << i
            elif l == bh[i].calc(0, N-k) and r == bh[i].calc(N-k, N):
                pass
            else:
                x[k] = None

    ans = []
    for k, xx in enumerate(x):
        if xx is not None:
            ans.append('%d %d' % (k, xx))

    return ans


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    print(*slv(N, A, B), sep='\n')



if __name__ == '__main__':
    main()


Measured memory_bytes: 277572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,a; cin>>n>>a;
    vector<ll> x(n);
    rep(i,n) {cin>>x[i]; x[i]-=a;}
    vector<vector<ll>> dp(n+1,vector<ll>(6000,0));
    rep(i,n){
        rep(j,5200){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j+x[i]]+=dp[i][j];
        }
        dp[i+1][x[i]+2600]++;
    }
    cout<<dp[n][2600]<<endl;
}

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

using namespace std;

int N;
map <int, int> cnt;

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

    long long ans = 0;
    for(int i = 1; i <= N; i++) {
        int x;
        cin >> x;
        ans += cnt[x - i];
        cnt[-i - x]++;
    }

    cout << ans << "\n";
    return 0;
}


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

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

	cout << (int)(a / b) << " " << a % b << " " << fixed << setprecision(5) << (double)a / b << endl;

	return 0;
}

Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			Scanner scan = new Scanner(System.in);
			int a = scan.nextInt();
			int b = scan.nextInt();
			if (a %2 == 0 || b%2 == 0) {
				System.out.println("No");
				return;
			} else {
				System.out.println("Yes");
				return;
			}
	}
}


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

const int MAX = 100;

int main() {
	int H, W;
	int N;
	int grid[MAX][MAX] = { {0} };
	int x = 0;
	int y = 0;
	int add_x = 1;

	cin >> H >> W;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			grid[y][x] = i;
			x += add_x;
			if (x < 0) {
				add_x = 1;
				x = 0;
				y++;
			}
			if (x >= W) {
				add_x = -1;
				x = W - 1;
				y++;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << grid[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll val[2100];
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  ll ten = 1;
  ll res = 0;
  ll n = 0;
  val[0] = 1;
  for(int i = s.length() - 1;i >= 0;i--){
    n = (((s[i] - '0') * ten) % 2019 + n) % 2019;
    res += val[n];
    val[n]++;
    ten = ten * 10 % 2019;
  }

  cout << res << endl;
}


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

int N, A, B, C, L[8] = {}, INF = 1000000000;

int DFS(int sum, int a, int b, int c) {
	if (sum == N) {
		if (a > 0 && b > 0 && c > 0) return abs(A - a) + abs(B - b) + abs(C - c) - 30;
		else return INF;
	}
	int ret1 = DFS(sum + 1, a, b, c);
	int ret2 = DFS(sum + 1, a + L[sum], b, c) + 10;
	int ret3 = DFS(sum + 1, a, b + L[sum], c) + 10;
	int ret4 = DFS(sum + 1, a, b, c + L[sum]) + 10;
	return min(min(ret1, ret2), min(ret3, ret4));
}

int main() {
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	cout << DFS(0, 0, 0, 0);
}

Measured memory_bytes: 256
import sys

def main(n):
    ans = []
    ans.append(list(range(1,10)))
    count = len(ans[0])

    if n < 10:
        return n

    while True:
        ans.append([])
        for i in ans[-2]:
            if int(str(i)[-1]) != 0:
                ans[-1].append(int(str(i) + str(int(str(i)[-1])-1)))
                count += 1
                if count == n:
                    return ans[-1][-1]
            ans[-1].append(int(str(i) + str(i)[-1]))
            count += 1
            if count == n:
                return ans[-1][-1]
            if int(str(i)[-1]) != 9:
                ans[-1].append(int(str(i) + str(int(str(i)[-1])+1)))
                count += 1
                if count == n:
                    return ans[-1][-1]

K = int(input())
print(main(K))


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

int main(){
	int N;
	cin >> N;
	
	vector<int> d(N);
	rep(i,N){
		cin >> d[i];
	}
	
	sort(d.begin(),d.end());
	
	cout << d[(N-1)/2 + 1] - d[(N-1)/2] << endl;
	
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int train = n * a;
    int taxi = b;
    
    System.out.println(Math.min(train, taxi));
  }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool ans[101];

int main(void){
	int i,j,n;
	for(i=1; i<10; ++i){
		for(j=1; j<10; ++j){
			ans[i*j] = true;
		}
	}
	cin >> n;
	cout << ((ans[n])?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

//const ll mod = ;
//const ld error = ;
const ld PI = acosl(-1);

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

struct print{
    print(){cerr<<"LINE "<<__LINE__<<" >> ";}
    ~print(){cerr<<endl;}
    template<class c> print& operator,(c i){
        cerr<<boolalpha<<i; return *this;}
};
#define dbg(x) " [" , #x ": " , (x) , "] "
#define tham getchar()

mt19937_64 rng((unsigned)chrono::system_clock::now().time_since_epoch().count());
//inline ll MOD(ll x, ll m = mod){
//    ll y = x % m;
//    return (y >= 0) ? y: y+m;
//}

//const int inf = ;
//const ll infl = ;
const int nmax = 1e5+5;
///===========================================  template  =======================================================

ll input[nmax];

int main(){
    FASTIO;

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

    ll l = 2, r = 2;
    for(int i = n-1; i>=0; i--){
        l = input[i] * ((l-1)/input[i] + 1);
        r = input[i] * (r/input[i]);

        if(l > r){
            cout<<-1<<endl;
            return 0;
        }

        r += input[i]-1;
    }

    cout<<l<<" "<<r<<endl;

    return 0;
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,T;
  cin>>N>>T;
  vector<int> c(N);
  vector<int> t(N);
  for(int i=0;i<N;i++){
    cin>>c.at(i)>>t.at(i);
  }
  int cost=10000;
  for(int i=0;i<N;i++){
    if(t.at(i)<=T){
      if(c.at(i)<cost){
        cost=c.at(i);
      }
    }
  }
  if(cost!=10000) cout<<cost<<endl;
  else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

diff = abs(b - a)

per = v - w

if per <= 0:
    print("NO")
    sys.exit()

if per * t >= diff:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 61688
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr int maxA = 1e6;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	sort(a.begin(), a.end());
	if (a[0] == 1) {
		if (N > 1 && a[1] == 1) {
			cout << "0\n";
		} else {
			cout << "1\n";
		}
		return 0;
	}

	vector<bool> memo(maxA + 10, false);
	vector<int> cnt(maxA + 10, 0);
	for (int i = 0; i < N; ++i) {
		cnt[a[i]] += 1;
		if (memo[a[i]]) { continue; }
		memo[a[i]] = true;

		for (int j = 2; ; ++j) {
			if (a[i] * j > maxA) { break; }
			cnt[a[i] * j] += 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (cnt[a[i]] == 1) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8004
#include <stdio.h>

int main()
{
 int n;
 
  scanf("%d",&n);
  
  int rest=n%10;
  
  if(rest==0||rest==1||rest==6||rest==8)
  {
    printf("pon\n");
  }
  else if(rest==3)
  {
    printf("bon\n");
  }
  else
  {
    printf("hon\n");
  }
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

bool circuit(vvi &to) {
    int in[26] = {}, ou[26] = {};
    for (int i=0; i<(int)to.size(); ++i) {
        for (int j: to[i]) {
            in[i] ++;
            ou[j] ++;
        }
    }
    for (int i=0; i<26; ++i) {
        if (in[i] != ou[i]) return false;
    }
    return true;
}

bool connected(vvi &to) {
    int s = 0;
    while (to[s].empty()) s ++;
    bool used[26] = {};
    stack<int> st;
    st.push(s);
    while ( ! st.empty()) {
        int t = st.top();
        st.pop();
        if (used[t]) continue;
        used[t] = true;
        for (int u: to[t]) st.push(u);
    }
    for (int i=0; i<(int)to.size(); ++i) {
        for (int j: to[i]) {
            if ( ! used[i] || ! used[j]) return false;
        }
    }
    return true;
}

int main() {
    int N;
    while (cin >> N, N) {
        vvi to(26);
        string s;
        for (int i=0; i<N; ++i) {
            cin >> s;
            to[s[0]-'a'].push_back(s.back()-'a');
        }
        if (circuit(to) && connected(to)) {
            cout << "OK\n";
        } else {
            cout << "NG\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3020
use std::io::*;
use std::str::FromStr;
use std::cmp;

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

fn main () {
    let n: u64 = read();
    let k: u64 = read();
    let num: u64 = n % k;
    println!("{}", cmp::min(num, k - num));
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a),q(b),r(c);
  rep(i,a)cin >> p[i]; 
  rep(i,b)cin >> q[i]; 
  rep(i,c)cin >> r[i]; 

  vector<P> v;
  rep(i,a)v.emplace_back(p[i],1);
  rep(i,b)v.emplace_back(q[i],2);
  rep(i,c)v.emplace_back(r[i],3);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  ll ans = 0;
  int z = 0;
  for (P p : v) {
    if (x + y <= z) break;
    if((p.second==1&&x==0)||(p.second==2&&y==0))continue;

    ans += p.first;
    if(p.second==1) --x;
    else if(p.second==2) --y;
    else ++z;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int tmp;
    for(int i=0;i<n;i++){
        cin >>tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    double val=v[0];
    for(auto itr = v.begin()+1; itr != v.end(); ++itr ){
        val = (*itr+val)/2;
    }

    cout << val;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n, inc;
  scanf("%d%d", &n, &inc);
  int last;
  scanf("%d", &last);
  int r = 0;
  for(int i = 1; i < n; i++) {
    int curr;
    scanf("%d", &curr);
    if(curr - last > inc) {
      r += inc;
    }
    else {
      r += curr - last;
    }
    last = curr;
  }
  printf("%d\n", r + inc);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, i, s;
  s = 0;
  int a[20], b[20], c[20];
  cin >> n;
  for(i = 0; i <= n-1; i++){
    cin >> a[i];
  }
  for(i = 0; i <= n-1; i++){
    cin >> b[i];
  }
  for(i = 0; i <= n-2; i++){
    cin >> c[i];
  }
  for(i = 0; i <= n-1; i++){
    s+=b[a[i]-1];
    //cout << s << endl;
    if((a[i+1]-a[i]==1) && (i >= 0)){
      s+=c[a[i]-1];
      //cout << s << endl;
    }
  }
  cout << s;
}

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

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


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

int main(){
   long long a,b,c,d;
   cin>>a>>b>>c>>d;
  long long c1=c;
  long long d1=d;
   long long sum=0;
   long long x=c*d;
   long long r=d%c;
   while(r!=0){
    d = c;
    c = r;
    r = d % c;
  }
  long long y=x/c;

   
   sum=b-(a-1)-(b/c1+b/d1-b/y-((a-1)/c1+(a-1)/d1-(a-1)/y));
   cout<<sum<<endl;
}



Measured memory_bytes: 256
/*
T M Hridoy KUET CSE 15
*/
#include<bits/stdc++.h>

using namespace std;

#define print printf("==================\n");
typedef    long long ll;
typedef pair<ll,ll   > payar;
typedef   unsigned long long ull;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define readf                freopen("in.txt", "r", stdin);
#define writef               freopen("out.txt", "w", stdout);

priority_queue<int, vector<int>,  greater<int> > pq; ///accending
vector< pair<int,payar  > > vpp;
vector< pair<int,  pair<int,payar  > > > own;
vector < payar >  vp;
#define pi acos(-1.0);
#define EPS 1e-9
#define  mod   1000000007
#define  mod2  998244353
#define all(x) x.begin(),x.end()
#define endl "\n"
const int N=2e5+5;


int a[N];
const int M = 998244353;

ll fn(ll n)
{
    return ( n*(n-1) ) >>1;
}
int main()
{
    IOS;
    ll t ;
    cin>>t;
    int ara[t];
    for(int i = 0 ; i<t ;i++){
        cin>>ara[i];
        a[ara[i]]++;
    }
    ll ans=0;
    for(int i = 1 ; i<=t ;i++){
       ans+=fn(a[i]);
    }
    for(int i = 1 ; i<=t ;i++){
       cout<<ans-fn(a[ara[i-1]])+fn(a[ara[i-1]]-1)<<endl;
    }



    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int N = (int)s.size();
    for (int i = 0; i <= N-2; i++) {
        if (s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for (int i = 0; i <= N-3; i++) {
        if (s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long t = 1L;
        for (int i = 1; i <= n; i++) {
            t *= i;
            t %= (Math.pow(10, 9) + 7);
        }
        System.out.println((int)(t % (Math.pow(10, 9) + 7)));
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
     char S[200001];
     char T[200001];
     int i;
     int w=0;

    scanf("%s", &S);
    scanf("%s", &T);
    for(i = 0;i<strlen(S);i++){
        if(S[i]!=T[i]){
            w+=1;
        }
    }
    
    printf("%d",w);
    return 0;
} 

Measured memory_bytes: 2124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (sS.Contains("9")) { sOut = "Yes"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
//https://atcoder.jp/contests/diverta2019/tasks/diverta2019_c
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int freqAB( string T )
{
    size_t pos{};
    int cnt{};
    for( int i = 0; i < (int)T.size(); ++i )
    {
        pos = T.find("AB", pos);
        if( pos != string::npos )
        {
            pos += 1;
            cnt++;
        }
    }
    return cnt;
}
bool isBA(string S)
{
    return S.front() == 'B' && S.back() == 'A';
}
bool isXX(string S)
{
    return S.front() != 'B' && S.back() != 'A';
}

bool isOnlyBA( vector<string> &S )
{
    // Sにbxxx, xxxaが含まれていたら，return false
    for( int i = 0; i < (int)S.size(); ++i )
    {
        // bxxx, xxxaならraturn false
        if(!(isBA(S[i]) || isXX(S[i])))return 0;
    }
    return 1;
}
int countXA( vector<string> &S )
{
    int a{};
    for( int i = 0; i < (int)S.size(); ++i )
    {
        if( S[i].back() == 'A' ) a++;
    }
    return a;
}
int countBX( vector<string> &S )
{
    int b{};
    for( int i = 0; i < (int)S.size(); ++i )
    {
        if( S[i].front() == 'B' ) b++;
    }
    return b;
}
int main()
{
    int N;
    cin >> N;
    vector<string> S( N );
    for( auto &x : S )
    {
        cin >> x;
    }
    int res{};
    for( int i = 0; i < N; ++i )
    {
        res += freqAB( S[i] );
    }
    /*cerr << "innerAB:"<< res << endl;
    cerr << "XA:" << countXA(S) << endl;
    cerr << "BX:" << countBX(S) << endl;
    cerr << "isOnlyBA:" << isOnlyBA(S) << endl;*/
    cout << ( isOnlyBA( S ) ? ( countXA ( S ) == 0 && countBX( S ) == 0 ? res + min( countBX( S ), countXA( S ) ) : res + min( countBX( S ), countXA( S ) ) - 1) : res + min( countBX( S ), countXA( S ) ) ) << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
//using Tu = tuple<ll, ll, ll>;
const ll INF = 1LL<<61LL;
const ll MOD = 1e9+7;



using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N+1);
  vector<ll> b(N+1);
  for(int i=0;i<N;i++){
    ll p;
    cin >> p;
    p--;
    a[p] += i+1;
    b[p+1] -= i+1;
  }
  for(int i=1;i<N;i++){
    a[i] += a[i-1];
    b[i] += b[i-1];
  }
  for(int i=0;i<N;i++){
    cout << a[i] + 500000000 + i;
    if(i == N-1)
      cout << endl;
    else
      cout << " ";
  }
  for(int i=0;i<N;i++){
    cout << b[i] + 500000000 + N - 1 - i;
    if(i == N-1)
      cout << endl;
    else
      cout << " ";
  }
}
/*
  3 1 2 4
  a 1 4 5 9
  b 5 3 0 -1
    5 6 7 8
 */


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int H, N;

const int MAX_H = 10000;
const int MAX_N = 1000;
const int MAX_A = 10000;
const int MAX_B = 10000;

int A[MAX_N], B[MAX_N];

long long dp[MAX_N + 2][MAX_H + 1];

void input() { 
    cin >> H >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
}

void initialize() {
    for(int i = 0; i <= N+1; i++) {
        for(int j = 1; j <= H; j++) {
            dp[i][j] = 100000001;
        }
    }
}

int main() {
    input();
    initialize();

    for(int i = 0; i < N; i++) {
        for(int j = 1; j <= H; j++) {
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i]);
        }
    }
    cout << dp[N][H] << endl;

    return 0;
}

Measured memory_bytes: 81916