akhauriyash/Code-Regression huggingface dataset:
// 解き直し.
// https://atcoder.jp/contests/abc179/editorial/115
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
LL a[101010]; // 数列を保存.

int main(){
    
    // 1. 入力情報.
    LL N, X, M;
    scanf("%lld %lld %lld", &N, &X, &M);
    
    // 2. 数列を計算(繰り返しを確認するまで).
    set<LL> s;
    LL cur = X;
    int idx = 0;
    rep(i, 101010){
        // 繰り返しかを判定.
        if(!s.count(cur)){
            a[i] = cur;
            s.insert(cur);
            idx = i;
        }else{
            break;
        }
        
        // 次項計算.
        cur *= cur;
        cur %= M;
    }
    
    // 3. 数列を分割.
    LL bSum = 0, cSum = 0; // 合計.
    vector<LL> b; // 繰り返し始まるまで.
    vector<LL> c; // 繰り返し部分.
    bool f = false; // 繰り返し部分開始フラグ.
    rep(i, idx + 1){
        if(cur == a[i]) f = true;
        if(f) c.pb(a[i]), cSum += a[i];
        else  b.pb(a[i]), bSum += a[i];
    }
    
    // 4. N項目までの和を計算.
    LL ans = 0, bl = (LL)b.size(), cl = (LL)c.size();
    if(N <= bl + cl){
        rep(i, (int)N) ans += a[i];
    }else{
        LL q = (N - bl) / cl, r = (N - bl) % cl;
        ans += bSum;
        ans += cSum * q;
        rep(i, (int)r) ans += c[i];
    }
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 6612
A,B = map(int,input().split(" "))
S = input()

for i in range(A+B+1):
	if i == A:
		if S[i] != '-':
			print("No")
			exit(0)

	else:
		if not (S[i].isdigit()):
			print("No")
			exit(0)

print("Yes")




Measured memory_bytes: 2940
#include<iostream>

int r,g,b,n;

long long res;

int main(){

    std::cin>>r>>g>>b>>n;

    for(int i=0;i<=n/r;i++){
        for(int j=0;j<=(n-i*r)/g;j++){
            if((n-i*r-j*g)%b==0)res++;
        }
    }

    std::cout<<res<<std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if ((N%10 == (N/10)%10) && ((N/10)%10 == (N/100)%10) || (N/1000 == (N/100)%10) && ((N/10)%10 == (N/100)%10)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }   
}


Measured memory_bytes: 35860
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;

    vector<long> dp(13, 0);
    dp[0] = 1;

    const long mod = 1000000007;
    int mul = 1;
    rrep(i, S.length() - 1, 0)
    {
        vector<long> nextDp(13, 0);

        const char c = S[i];
        if (c == '?')
        {
            rep(k, 0, 10)
            {
                rep(j, 0, 13)
                {
                    nextDp[(k * mul + j) % 13] += dp[j];
                    nextDp[(k * mul + j) % 13] %= mod;
                }
            }
        }
        else
        {
            int k = S[i] - '0';
            rep(j, 0, 13)
            {
                nextDp[(k * mul + j) % 13] += dp[j];
                nextDp[(k * mul + j) % 13] %= mod;
            }
        }

        mul *= 10;
        mul %= 13;

        dp = move(nextDp);
    }

    cout << dp[5] << endl;
}


Measured memory_bytes: 512
def main():
    n = int(input())
    a = list(map(int,input().split()))

    #lst = [0 for i in range(n*3)]
    ans_lst = [0 for i in range(max(a)+4)]
    """
    for i in range(n):
        lst[3*i] = a[i]
        lst[3*i+1] = a[i]+1
        lst[3*i+2] = a[i]+2
    """

    for i in a:
        ans_lst[i] += 1
        ans_lst[i+1] += 1
        ans_lst[i-1] += 1

    """
    ans = -1
    for i in set(lst):
        ans = max(lst.count(i),ans)
    """

    print(max(ans_lst))


if __name__ == "__main__":
        main()


Measured memory_bytes: 56004
#include<stdio.h>
int main(void)
{
	long long c=0;
	int a,i,j,n,array[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&array[i]);
		c+=array[i];
	}
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(array[j]<array[j-1]){
				a=array[j];
				array[j]=array[j-1];
				array[j-1]=a;
			}
		}
	}
	printf("%d %d %lld\n",array[0],array[n-1],c);
	return 0;
}

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

using namespace std;

bool match_ab[4001];
bool match_ac[4001];
bool match_bc[4001];

bool match(string a, string b, int offset) {
    for (int i = 0; i + offset < a.size() && i < b.size(); i++) {
        if (a[i + offset] == '?' || b[i] == '?') continue;
        if (a[i + offset] != b[i]) return false;
    }
    return true;
}

int calc_sub(string a, string b, string c) {
    for (int i = 0; i < 4001; i++) {
        match_ab[i] = true;
        match_ac[i] = true;
        match_bc[i] = true;
    }
    for (int i = 0; i < a.size(); i++) {
        match_ab[i] = match(a, b, i);
        match_ac[i] = match(a, c, i);
    }
    for (int i = 0; i < b.size(); i++) {
        match_bc[i] = match(b, c, i);
    }

    int ans = 6000;
    for (int i = 0; i < a.size() + 1; i++) {
        for (int j = i; j < a.size() + b.size() + 1; j++) {
            if (ans <= max((int)a.size(), max(i + (int)b.size(), j + (int)c.size()))) break;
            if (match_ab[i] & match_ac[j] & match_bc[j - i]) {
                ans = max((int)a.size(), max(i + (int)b.size(), j + (int)c.size()));
                break;
            }
        }
    }
    return ans;
}

int calc(string a, string b, string c) {
    int ans = a.size() + b.size() + c.size();
    ans = min(ans, calc_sub(a, b, c));
    ans = min(ans, calc_sub(a, c, b));
    ans = min(ans, calc_sub(b, a, c));
    ans = min(ans, calc_sub(b, c, a));
    ans = min(ans, calc_sub(c, a, b));
    ans = min(ans, calc_sub(c, b, a));
    return ans;
}

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

Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;33
    for(int ok=1;ok<=t;ok++)
    {
    	ll x;
    	cin>>x;
        for(ll i=1;i<=1000;i++)
        {
               
             for(ll j=-1000;j<=1000;j++)
             {
                   if(i*i*i*i*i-j*j*j*j*j==x)
                   {
                   	  cout<<i<<" "<<j<<endl;
                   	  return 0;
                   }
             }
    	}
    }
      return 0;
}

Measured memory_bytes: 3652
s = input()
t = input()

if len(t) > len(s):
    print("UNRESTORABLE")
    exit()

s = s[::-1]
t = t[::-1]
for i in range(len(s)-len(t)+1):
    k = 0
    while True:
        if k == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans[::-1].replace("?","a",len(ans)))
            exit()
        if t[k] == s[i+k] or s[i+k] == "?":
            k += 1
        else:
            break
print("UNRESTORABLE")

Measured memory_bytes: 9072
"""MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWO:,'..'xXWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .:kOo.,kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .lNWWo..lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MNOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMMMMWKxoloxKWNc  .:xxd;  ,dxxxkXMXkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMM
MKc''''''''''''''''.  ..'''''.   .''''.  .''MMMWx..,:. .xXo''.  .''.  ..'';kMk;'''''.  .'.''.  .''''''.  ..''.   .''MM
MWNXNNNNNNNNNNNNNNNO' ;KNNNNNKo. cKNNNd. lXNMMMK; ,0Wx. :NWXXl .dNNO' ;KNNNWMWNNNNNXc .kNNNNx. cXNNNNNO' ;KNN0; 'ONNMM
MMMMMMMMMMMMMMMMMWM0' :NMMMMWMX: .OMWWx. oWMMMMWx. ';. .dNMWWo .xMM0' :NWWMMMMMMMMWWl .OMMMWk. lWWMMWM0' ;XMMX: ,KMMMM
MMMMMMWMWkccccccccc;. :NMWNNNKd. :XMMWx. oWMMMWKo. .',. .,ldx; .dMM0' :NMMMMMMMNNWMWl .OMMMWk. lWMMMMM0' ;XMMX: ,0MMMM
MMWXKNWMWxcc,. .;cc;. :XMk,''..'lKWMMWx. oWMNx:. .lONNKxl.     .xMM0' :NMMMMMM0:,oKO' ,KMMMMk. lWWNkoc,. .;::;. ,KMMMM
MMXc.lXMMWWWNd..xWM0' :NM0;  ;kXWMMMWNl  oWMK:.;xXWWMWXx:. ,c' .dMM0' :NMMMMMMKc. ...;kWMMMMk. lWWc .:;. .clc:. ,KMMMM
MWWx. lXMWMMMK, lWM0' :NMMNx'.,ldxxoc'   oWMWNKNWWWN0o' .:kNWo .dMM0' :NMMMMMMMNO;  ,OWWWMMMk. lWM' lXx. lNMMX: ,KMMMM
MMMWk'.,xKNX0c..kWM0' :NMMMMNkl;,'',:l:  oWMMMMMWMWO' 'l0WMWWo .xMM0' :NMMMMMMMMMNd. .oXWMMMk. lWMd.....;0WMMX: ,KMMMM
MMMMWKo'...'..:kWMM0' :NMMMMMMMWWNNWWWx. oWMMMMMMMMWOxXWMWMWWo .xMM0' :NMMMMMMMMMMMKl. ,kNMMk. lWMWKkxx0NMWMMX: ,KMMMM
MMMMMMMN0kxk0XNWMMWKl;xNMMMMMMMMMMMMWM0c;kWMMMMMMMMMMMWWMMMMWk;:OMMXl,dNMMMMMMMMMMMMWO; .dNM0c;kWWMMMMMMMMMMMNd,oXMMMM
MMMMMMMMWWMWMMMMMMMMMWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMWWMMWMMMMMMMMMMMMMMNkxKWMMWWMMMMMMMMMMMMMMWMMWMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"""


#				 Author: Udit "luctivud" Gupta @ https://www.linkedin.com/in/udit-gupta-1b7863135/					 #


import math;   		from collections import *
import sys;   		from functools import reduce
import time;   		from itertools import groupby

# sys.setrecursionlimit(10**6)

def input()         : return sys.stdin.readline()
def get_ints()      : return map(int, input().strip().split())
def get_list()      : return list(get_ints())
def get_string()    : return list(input().strip().split())
def printxsp(*args) : return print(*args, end="")
def printsp(*args)  : return print(*args, end=" ")


DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] 
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\
              (+1, +1), (+1, +0), (+1, -1), (+0, +1)]



# MAIN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# for _test_ in range(int(input())): 
s = input()
g = groupby(s)
ans = 0
for ke, val in g:
	if ke == 'R':
		ans = max(ans, len(list(val)))
print(ans)






Measured memory_bytes: 9508
#include <stdio.h>

int main(void) {
  char input[20];
  char token[2] = "ox";
  while(scanf("%s", input) != EOF) {
    for (int i = 0; i < 2; i++) {
      if (input[0] == token[i] && input[1] == token[i] && input[2] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[3] == token[i] && input[4] == token[i] && input[5] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[6] == token[i] && input[7] == token[i] && input[8] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[0] == token[i] && input[3] == token[i] && input[6] == token[i]) {        printf("%c\n", token[i]);
        break;
      }
      else if (input[1] == token[i] && input[4] == token[i] && input[7] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[2] == token[i] && input[5] == token[i] && input[8] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[0] == token[i] && input[4] == token[i] && input[8] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (input[2] == token[i] && input[4] == token[i] && input[6] == token[i]) {
        printf("%c\n", token[i]);
        break;
      }
      else if (i == 1) printf("d\n");
    }
  }
  return 0;
}


Measured memory_bytes: 1924
#include <bits/stdc++.h>
#define N 100010
#define INF 1e18
using namespace std;
long long n,k,x[N],v[N],a[N]={},b[N]={},c[N]={},d[N]={};
long long vtl=0,vtr=0,ans=-INF,i;
int main(){
	cin>>n>>k;
	for(i=0;i<n;i++)cin>>x[i]>>v[i];
	for(i=0;i<n;i++){
		vtl+=v[i];
		vtr+=v[n-i-1];
		a[i+1]=max(a[i],vtl-x[i]);
		b[i+1]=max(b[i],vtl-x[i]*2);
		c[n-i-1]=max(c[n-i],vtr-(k-x[n-i-1]));
		d[n-i-1]=max(d[n-i],vtr-(k-x[n-i-1])*2);
	}
	for(i=0;i<=n;i++)ans=max(ans,max(a[i]+d[i],b[i]+c[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

	public class Main {

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

			int N = sc.nextInt();
			int A[] = new int[N+2];
			int ASum = 0;
			int B[] = new int[N+1];

			int i = 0;

			for(i=1; i<N; i++) {
				B[i] =  sc.nextInt();
			}
			// Scannerクラスのインスタンスをクローズ
			sc.close();

			A[1] = B[1];
			A[N] = B[N-1];
			for(i=2; i<N; i++) {
				A[i] = Math.min(B[i-1], B[i]);
			}

			for(i=1; i<N+1; i++) {
				ASum += A[i];
			}

			System.out.println(ASum);

    	}
    }

Measured memory_bytes: 35904
S = input()

for i in range(len(S)-1):
  if S[i] == S[i+1]:
    print(i+1, i+2)
    exit(0)
  elif i+2 < len(S) and S[i] == S[i+2]:
    print(i+1, i+3)
    exit(0)
    
print(-1, -1)

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

using namespace std;

int n,k;
typedef long long ll;

int main(){

	while(cin>>n>>k&&(n|k)){
		int i;
		ll sum=0;
		ll mul=1;
		ll base;
		for(i=1;;i++){
			sum+=i*9*mul;
			if(n<=sum){
				// iÔÚÌ][ÌnÂÚ
				n-=(sum-i*9*mul);
				// 0-base
				n--;
				break;
			}
			mul*=10;
		}
		// iÌ][ÉposNª¶Ý
		// iÌ][Ì½ÔÚÌê©
		ll a=n/i;
		// iÌ][Ì½ÔÚÌêÌ½ÂÚÌ©
		ll b=n%i;
		// nÌªÇÌÌvfÉÈÁÄ¢é©
		ll curNum=mul+a;
		string res;
		// rÌªð«µÄ¨­
		if(b!=0){
			ll tmp=curNum;
			// ºÊ©ç©Ä¢­
			while(tmp){
				int a=tmp%10;
				res+=(a+'0');
				tmp/=10;
			}
			reverse(res.begin(),res.end());
			res=res.substr(b);
			curNum++;
		}
		//  ÆÍÐ½·ç«·
		while(1){
			if(res.size()>=k){
				res=res.substr(0,k);
				break;
			}
			ll tmp=curNum;
			string ss;
			while(tmp){
				int a=tmp%10;
				ss+=(a+'0');
				tmp/=10;
			}
			reverse(ss.begin(),ss.end());
			res+=ss;
			curNum++;
		}
		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> checked(N,0);
    int d;
    int tmp;
    for(int i = 0; i < K; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> tmp; tmp--;
            if(checked.at(tmp) == 0){
                checked.at(tmp)++;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(checked.at(i) == 0) ans++;
    }
    printf("%d\n", ans);
    
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

void insertionSort(vector<int> &A, int n, int g, int &cnt) {
    for (int i=g; i<n; ++i) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            cnt ++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int> &A, int n) {
    int cnt = 0;
    vector<int> G;

    G.push_back(1);
    for (int h=4; (h<50&h<n)||h<=n/9; h=h*3+1) {
        G.push_back(h);
    }
    int m = G.size();

    cout << m << endl;

    for (int i=m-1; i>=0; --i) {
        cout << (i==m-1 ? "" : " ") << G[i];
        insertionSort(A, n, G[i], cnt);
    }
    cout << endl;

    cout << cnt << endl;

    for (int i=0; i<n; ++i) {
        cout << A[i] << endl;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i=0; i<n; ++i) {
        cin >> A[i];
    }
    shellSort(A, n);
    return 0;
}

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

int main()
{
    int N;
    int M;
    cin >> N >> M;
    unsigned int flags = 0;
    for (int i = 0; i < M; ++i) flags += (1 << i);

    int KN;
    for (int j = 0; j < N; ++j)
    {
        cin >> KN;
        int flagsN = 0;
        int ANKN;
        for (int k = 0; k < KN; ++k)
        {
            cin >> ANKN;
            ANKN--;
            flagsN += (1 << ANKN);
        }
        flags = flags & flagsN;
    }
    int res = 0;
    for (int l = 0; l < M; ++l) if(flags & (1 << l)) res++;
    cout << res << endl;
    
    return 0;
}


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

int main() {
    int a, b, tmp;
    while(1) {
        cin >> a >> b;
        if (a==0 && b==0) break;
        if (a<=b) {
            cout << a << " " << b << endl;
        } else {
            cout << b << " " << a << endl;
        }
    }
}


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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='+'){
			ans++;
		}
		else{
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


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

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint &operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

lint n, m, k;

int main() {
    cin >> n >> m >> k;
    cumulative_sum a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    a.build();
    b.build();
    // aを何冊読むか
    lint ans = 0;
    for (int i = 0; i <= n; i++) {
        auto sum_a = a.query(0, i);
        lint rem = k - sum_a;
        if (rem < 0) {
            continue;
        }
        lint num_b = upper_bound(b.sum.begin(), b.sum.end(), rem) - b.sum.begin();
        chmax(ans, num_b + i - 1);
    }
    cout << ans << endl;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     string s,t;
     cin >> s;
     cin >> t;
     int cnt=0;
     int n =s.size();
     for(int i=0;i<n;i++){
      if(s[i]!=t[i])cnt++;
     }
     cout << cnt;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3948
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	map<ll, ll> D;
	for (int i = 0; i < N;i++) {
		ll d; cin >> d;
		D[d]++;
	}
	ll M; cin >> M;
	vector<ll> T(M);
	bool f = false;
	for (int i = 0; i < M;i++) {
		cin >> T[i];
		D[T[i]]--;
		if (D[T[i]] < 0) f = true;
	}
	if (f) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

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

int main()
{
	string s, t;

	cin >> s >> t;

	for (int i = 0; i < (int)(s.size() - t.size() + 1); i++) {
		bool f = true;
		for(int j = 0; j < (int) t.size(); j++)
			if (s[i + j] != t[j]) {
				f = false;
				break;
			}

	if (f == true)
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 3220
import java.io.*;
import java.util.*;

 
public class Main{
	class Pair{
		long val;
		int cnt;
		public Pair(int val){
			this.val = val;
			this.cnt = 1;
		}
	}
	
	int N;
	int[] A;
	public void solve(){
		N = nextInt();
		A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = nextInt();
		}
		
		TreeMap<Integer, Pair> val = new TreeMap<>((a, b) -> Integer.compare(b, a));
		long ans = 0;
		long cur = 0;
		for(int i = 0; i < N; i++){
			Pair p = new Pair(A[i]);
			Iterator<Map.Entry<Integer, Pair>> ite = val.entrySet().iterator();
			while(ite.hasNext()){
				Pair pp = ite.next().getValue();
				if(pp.val > p.val){
					ite.remove();
					p.cnt += pp.cnt;
					cur -= pp.val * pp.cnt;
					cur += p.val * pp.cnt;
				}else{
					break;
				}
			}
			cur += p.val;
			ans += cur;
			val.put((int)p.val, p);
		}
		out.println(ans);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 36512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	int a, b;
	cin >> a >> b;

	long long int ans = 0;

	if( a < b && a < 0 && b < 0 ){
		ans = b - a;
	}else if( a < b && a < 0 && b >= 0 ){
		ans = b - a;
		if( b - (-1 * a) >= 0 ){
			long long int tmp = b - (-1 * a) + 1;
			ans = min( ans, tmp );
		}else if( abs(a) > abs(b) ){
			long long int tmp = abs(a) - abs(b) + 1;
			ans = min( ans, tmp );
		}
	}else if( a < b && a >= 0 && b >= 0 ){
		ans = b - a;
	}else if( a > b && a < 0 && b < 0 ){
		ans = a - b;
		ans += 2;
	}else if( a > b && a >= 0 && b < 0 ){
		ans = abs(a + b);
		ans += 1;
	}else if( a > b && a >= 0 && b >= 0 ){
		ans = a - b;
		ans += 2;
		if( b == 0 ) ans -= 1;
	}


	cout << ans << endl;


	return 0;

}


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

int main(){
  int N;
  string S,T;
  cin>>N>>S>>T;
  
  string res;
  for(int i=0;i<N;i++){
    res+=S[i];
    res+=T[i];
  }
  
  cout<<res<<endl;
}

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

std::vector <int> A;
std::vector <pair<int, int>> BC;
int N;

int rwt(int b, int c, int j) {
	for (int i = j; i < j + b; ++i) {
		if (i > N)break;
		if (A[i] < c)A[i] = c;
		else break;
	}
	return j + b;
}

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

int main()
{
	int M, j;
	long long int t = 0;
	cin >> N >> M;
	A.resize(N);
	BC.resize(M);

	for (int i = 0; i < N; ++i)cin >> A[i];
	for (int i = 0; i < M; ++i)cin >> BC[i].first >> BC[i].second;
	std::sort(A.begin(), A.end());
	std::sort(BC.begin(),BC.end(),sbs);

	j = 0;
	for (int i = 0; i < M; ++i) {
		j = rwt(BC[i].first, BC[i].second, j);
		if (j > N)break;
	}

	for (int i = 0; i < N; ++i)t += A[i];
	cout << t << "\n";
	return 0;
}

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

typedef long long ll;
using namespace std;

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

    int m = max({a, b, c});
    int x;
    if ((3 * m) % 2 == (a + b + c) % 2) x = m;
    else x = m + 1;
    cout << (3 * x - (a + b + c)) / 2;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        if(a<b && b<c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}



Measured memory_bytes: 26084
#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  int num = 0;
  for(int i=0;i<n;i++){
    int x;cin>>x;
    int b = abs(x-k);
    if(x>b) num+=b*2;
    else num+=x*2;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int sum=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			sum=1;
		}
		if(a[i]=='F'&&sum==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100
ll x,y,ans=0;

int main(){
	cin>>x>>y;
	if(abs(y)<abs(x)){
		if(x>0){
			ans++;
			x*=-1;
		}
	}else if(abs(y)>abs(x)){
		if(x<0){
			ans++;
			x*=-1;
		}
	}
	ans+=abs(abs(y)-abs(x));
	x+=abs(abs(y)-abs(x));
	if(x!=y)ans++;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;

ll trade(ll &n, vector<ll > &a, vector<ll > &b) {
    vector<ll> dp(n+1, -1LL);
    dp[0] = n;
    ll acorn = n;
    for(int i=0;i<3;++i) {
        if(a[i] >= b[i]) continue;
        for(int j=0;j<=n-a[i];++j) {
            if(dp[j] != -1) {
                dp[j+a[i]] = max(dp[j+a[i]], dp[j] + b[i]-a[i]);
                acorn = max(acorn, dp[j+a[i]]);
            }
        }
    }
    return acorn;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(3), b(3);
    for(int i=0;i<3;++i){
        cin >> a[i];
    }
    for(int i=0;i<3;++i){
        cin >> b[i];
    }

    ll  acorn = trade(n, a, b);
    acorn = trade(acorn, b, a);

    cout << acorn << endl;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
ll i ,j;
while(q--)
{
    ll n,m,k,l,r,a,b,c=0,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n >> k;
    n = n%k;
    cout << min(abs(n-k),n);


}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%tmod;}
    else{return (b*((temp*temp)%tmod))%tmod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 256
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort()

n = 0
for i in range(N):
  if n + ab[i][1] < K:
    n += ab[i][1]
  else:
    print(ab[i][0])
    break

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

using namespace std;
const int N=100005;
const long long mod=1000000007;

long long n,k;
vector<int> v[N];
long long res;

void dfs(int a,int p=-1)
{
    long long num=k-2;
    if(p==-1) num++;
    for(int to:v[a])
    {
        if(to==p) continue;
        res*=num;
        res%=mod;
        num--;
        dfs(to,a);
    }
}

int main()
{
    cin >> n >> k;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    res=k;
    dfs(1);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 

int solve(){
    int n,s=0,q,b,c;
    cin>>n;
    int a[n];
    map<int,int> m;
    rep(i,0,n){
        cin>>a[i];
        m[a[i]]++;
        s+=a[i];
    }
    cin>>q;
    rep(i,0,q){
        cin>>b>>c;
        s=s-m[b]*b;
        s=s+m[b]*c;
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<"\n";
    }
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
//    return 0;
} 


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

int main(){
  int n,c;
  int a=0,b=0;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(a<s[i]){
      a = s[i];
      c=i;
    }
  }
  
  for(int k=0;k<n;k++){
    if(k==c) continue;
    else b=max(b,s[k]);
  }
  
  for(int j=0;j<n;j++){
    if(j!=c) cout<<a<<endl;
    else cout<<b<<endl;
  }
  return 0;
}
    
  
  
  


Measured memory_bytes: 2432
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int mxN= 200010;
int t[mxN], ans[mxN];
int main()
{
    //vok();
    ll n;
    IN n;
      OUT ((n/500)*1000)+(((n%500)/5)*5)<<endl
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;


int main() {

	cout << fixed << setprecision(10);

	double a, b, x;
	cin >> a >> b >> x;

	double ar = x / a;

	double ans;


	if (ar > a*b / 2.0) {
		double len = (a*b - ar)*2.0 / a;
		ans = atan(len/a)*180.0/M_PI;
	}

	else {
		double len = ar * 2 / b;
		ans = atan(b/len)*180.0/M_PI;
	}

	cout << ans;


	system("PAUSE");

}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  string s;
  unsigned long long int k;
  cin >> s; 
  cin >> k;
  for(int i=0;i<s.length();i++){
    if(s[i]=='1' && i<k-1){continue;}
    else if(s[i]=='1' && i==k-1){
      cout << '1' << endl;
      return 0;
    }
    else {
      cout << s[i] << endl;
      return 0;
    }
  }
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    long long S=0, tmp=N;
    while(tmp>0){
        S += (tmp%10);
        tmp/=10;
    }
    cout << (N%S==0 ? YES : NO) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

typedef pair<int, int> obj;

int main(){
  int N, W, weight, value;
  char ch;
  int case_num = 1;

  while(1){
    cin >> W;
    if(W == 0) break;
    cin >> N;

    //printf("W = %d N = %d\n", W, N);

    vector<obj> obj_list;
    int dp[1010];
    memset(dp, -1, sizeof(dp));
    
    for(int i = 0; i < N; i++){
      cin >> value >> ch >> weight;
      obj_list.push_back(obj(value, weight));
      //printf("value = %d weight = %d\n", value, weight);
    }

    dp[0] = 0;

    for(int i = 0; i < N; i++){
      obj o = obj_list[i];

      for(int j = W; j >= 0; j--){
        if(dp[j] != -1){
          dp[j] = max(dp[j], dp[j]);
          if(j + o.second <= W){
            dp[j+o.second] = max(dp[j+o.second], dp[j] + o.first);
          }
        }
      }
    }
    int answer = 0;
    int answer_weight = 0;

    for(int i = 0; i <= W; i++){
      if(answer < dp[i]){
        answer = dp[i];
        answer_weight = i;
      }
    }

    cout << "Case " << case_num << ":" << endl;
    cout << answer << endl;
    cout << answer_weight << endl;

    case_num++;
  }

  return 0;
}

Measured memory_bytes: 1216
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

count = 0
(a[0] - 1).times do |n|
  if n == 0 then
    if b[n] > a[1] then
      count += b[n] - a[1]
      b[n] = a[1]
    end
  end

  if b[n] + b[n+1] > a[1] then
    t = b[n] + b[n+1] - a[1]
    b[n+1] -= t
    count += t
  end
end

p count



Measured memory_bytes: 8588
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll a,b,n;cin>>a>>b>>n;
        ll ans;
        if(n>=(b-1)){
            ans=a-(a/b);
            if(a%b){
                ans--;
            }
        }
        else{
            ans=(a*n)/b;
        }
        cout<<ans<<endl;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();

		int[] arr = input(n);
		long[][][] dp = new long[n][n][2];

		for(int slide = 0 ; slide< n ;slide++ ) {
			for(int row = 0 ; row < n - slide ; row++) {
				int col = row + slide ;
				if(row==col) {
					dp[row][col][0]=arr[row];
					dp[row][col][1]=0;
					continue;
				}
				
				if(dp[row+1][col][1]+arr[row] > dp[row][col-1][1]+arr[col]) {
					dp[row][col][0]=dp[row+1][col][1]+arr[row] ;
					dp[row][col][1]=dp[row+1][col][0] ;	
				}else {
					dp[row][col][0]=dp[row][col-1][1]+arr[col] ;
					dp[row][col][1]=dp[row][col-1][0] ;					
				}
			}
		}
		long ans  = dp[0][n-1][0]-dp[0][n-1][1];
		System.out.println(ans);
	}

	public static int[] input(int n) throws Exception {

		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static int[][] input(int n, int m) throws Exception {

		int[][] arr = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				arr[i][j] = sc.nextInt();
			}
		}
		return arr;
	}

}


Measured memory_bytes: 356244
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int S;
  cin >> S;

  bool yymm = false, mmyy = false;
  if(0 < S / 100 && S / 100 <= 12) {
      mmyy = true;
  }

  S %= 100;

  if(0 < S && S <= 12) {
      yymm = true;
  }

  if(mmyy && yymm) {
      cout << "AMBIGUOUS" << endl;
      return 0;
  }

  if(yymm) cout << "YYMM" << endl;
  else if(mmyy) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main(void)
{
  int a,b,c,max;
  scanf("%d%d%d",&a,&b,&c);
  if(a>=b && a>=c)
    max=a;
  else if(b>=a && b>=c)
    max=b;
  else
    max=c;
  if(a+b+c-max==max)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n; cin >> n;
  map<string,priority_queue<int>> r;
  map<pair<string,int>,int> t;
  rep(i,n){
    string s; int d; cin >> s >>d;
    r[s].push(d);
    t[{s,d}] =i;
  }
  for(pair<string, priority_queue<int>> i:r){
    while(SIZE(i.S)>0){
      int d = i.S.top();
      i.S.pop();
      cout << t[{i.F, d}] +1 << endl;
    }
  }
  return 0;
}


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

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    # 過去にすでに同じ数字への加算があったら飛ばす
    if divisible_list[a[i]] > 2:
        continue
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)

Measured memory_bytes: 32232