akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
char a[1300];
 
int main(void){
    int i;
 
    fgets(a,1300,stdin);
 
    i = 0;
    while(a[i] != '\0'){
        if(a[i] >= 'A' && a[i] <= 'Z')
            printf("%c",a[i] + 0x20);
        else if(a[i] >= 'a' && a[i] <= 'z')
            printf("%c",a[i] - 0x20);
        else
            printf("%c",a[i]);
        i++;
    }
    return 0;
}


Measured memory_bytes: 2108
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    S = input()
    cont = 0
    ans = 0
    for c in S:
        if c == 'R':
            cont += 1
        else:
            ans = max(ans,cont)
            cont = 0
    print(max(ans,cont))

    
main()

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

int main (){

  int n, a, b;
  cin >> n >> a >> b;
  int sum=0;
  int ketawa;
  for(int i=1; i<=n; i++){
    ketawa = (i%10) + ((i/10)%10) + ((i/100)%10) + ((i/1000)%10) + ((i/10000)%10);
  	if((ketawa >= a) && (ketawa <= b)){
    	sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int correct = 0;
    char past[10], actual[10];
    scanf("%s", past);
    scanf("%s", actual);
    for(int i = 0; i < 3; i++){
        if(past[i] == actual[i]){
            correct += 1;
        }
    }
    printf("%d\n", correct);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n); r(m);
    int ans=n/m;
    if(n%m!=0) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	string s;
	while (cin >> s) {
		VS c(3);
		rep(i, 9)c[i / 3] += s[i];

		int ans = 3;

		rep(i, 3) {
			if (count(all(c[i]), 'o') == 3)ans = 1;
			if (count(all(c[i]), 'x') == 3)ans = 2;
		}

		rep(i, 3) {
			int co = 0, cx = 0;
			rep(j, 3) {
				if (c[j][i] == 'o')co++;
				if (c[j][i] == 'x')cx++;
			}
			if (co == 3)ans = 1;
			if (cx == 3)ans = 2;
		}

		int co1 = 0, cx1 = 0;
		rep(i, 3) {
			if (c[i][i] == 'o')co1++;
			if (c[i][i] == 'x')cx1++;
		}
		if (co1 == 3)ans = 1;
		if (cx1 == 3)ans = 2;

		if (c[0][2] == c[1][1] && c[1][1] == c[2][0]) {
			if (c[0][2] == 'o')ans = 1;
			if (c[0][2] == 'x')ans = 2;
		}

		puts(ans == 1 ? "o" : ans == 2 ? "x" : "d");
	}
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
#define mod 1000000007

using namespace std;
typedef long long ll;
const int N = 1e5 + 2;

void add(ll &x, ll y){
    x += y;
    ll k = x/mod;
    x = x - mod*1ll*k;
}

string s;
ll f[N][4];

int main(){
    ios_base::sync_with_stdio(0);

    cin >> s;
    s = " " + s;
    f[0][0] = 1;
    for(int i = 1; i < (int)s.size(); i++){
        f0(j, 4){
            f[i][j] = f[i - 1][j];
            if(s[i]=='?') f[i][j] = f[i - 1][j]*3;

            add(f[i][j], 0);
            if(j > 0){
                if(s[i]=='?' || j - 1 == s[i] - 'A') add(f[i][j], f[i - 1][j - 1]);
            }
        }
    }
    cout << f[s.size() - 1][3];
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	ll h[n];
	for(int i=0; i<n; i++) cin >> h[i];
	sort(h, h+n, greater<ll>());
	for(int i=0; i<min(n, k); i++) h[i]=0;
	ll ans=0;
	for(int i=0; i<n; i++) ans+=h[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int K;
    cin >> K;

    queue<long long> q;
    FOR(i, 1, 10) q.push(i);

    REP(i, K-1){
        long long x = q.front();
        q.pop();
        if(x%10 != 0) q.push(10*x + x%10 - 1);
        q.push(10*x + x%10);
        if(x%10 != 9) q.push(10*x + x%10 + 1);
    }
    cout << q.front() << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

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

		int X = sc.nextInt();

		int A = sc.nextInt();
		
		int B = sc.nextInt();
		
		if (A >= B){
			
			System.out.println("delicious");

		}else if(B - A >= X + 1){

			System.out.println("dangerous");
		
		}else {

			System.out.println("safe");
		
		}

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N,M; cin >>N >>M;
  vector<int> balls(N, 1);
  vector<bool> red(N, false); red[0] = true;
  rep(qq, M){
    int x,y; cin >>x >>y; x--; y--;
    if (red[x]) red[y] = true;
    if (balls[x] == 1) red[x] = false;
    balls[x]--; balls[y]++;
  }
  int res = 0;
  rep(i, N) if (red[i]) res++;
  cout <<res <<endl;
}


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

#define int long long
#define endl "\n"
#define mod 1000003

using namespace std;

int a[100010];

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

	int n;
	cin >> n;

	for(int i=1;i<=1e3;i++)
	{
		int temp = i*(i+1)/2;

		if(temp == n)
		{
			cout << "Yes\n";
			cout << i+1 << endl;

			temp = i+1;

			vector <int> v[temp];

			int cnt = 1;

			for(int i=0;i<temp;i++)
			{
				for(int j=i+1;j<temp;j++)
					v[i].push_back(cnt), v[j].push_back(cnt), cnt++;
			}

			for(int i=0;i<temp;i++)
			{
				cout << v[i].size() << " ";

				for(int j:v[i])
					cout << j << " ";
				cout << endl;
			}

			return 0;
		}
	}

	cout << "No\n";

	return 0;
}

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

int p[1500000],q[1500000];

int main(){
    while(1){
        int n,m,w[1500],h[1500];
        long lh=0,lw=0,res=0;
        scanf("%d %d",&n,&m);
        if(n==0&&m==0) return 0;
        memset(p,0,sizeof(int)*1500000);
        memset(q,0,sizeof(int)*1500000);
        for(int i=0;i<n;i++) scanf("%d",&h[i]);
        for(int i=0;i<m;i++) scanf("%d",&w[i]);
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                lh+=h[j];
                p[lh-1]++;
            }
            lh=0;
        }
        for(int i=0;i<m;i++){
            for(int j=i;j<m;j++){
                lw+=w[j];
                q[lw-1]++;
            }
            lw=0;
        }
        for(int i=0;i<1500000;i++) res+=p[i]*q[i];
        printf("%ld\n",res);
    }
}

Measured memory_bytes: 12760
#include<bits/stdc++.h>
#define MAXN 200000
#define lowbit(x) ((x)&(-(x)))

using namespace std;
void get(int &v)
{
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return ;
}
int get()
{
	int v;
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return v;
}
set<int>s[3];
int main()
{
	int n,m,i,j;
	get(n);
	get(m);
	while(m--)
	{
		get(i);
		get(j);
		if(i==1)
			s[0].insert(j);
		else if(j==1)
			s[0].insert(i);
		else if(i==n)
			s[1].insert(j);
		else if(j==n)
			s[1].insert(i);
	}
	set_intersection(s[0].begin(),s[0].end(),s[1].begin(),s[1].end(),inserter(s[2], s[2].begin()));
	puts(s[2].size()?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}
//g++ -g cc.cpp -o cc

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{

        ll N;
        cin >> N;
        ll ans = 0;
        ll ans1 = 1;
        for (int i = 1; i <= N; ++i) {
                int tmp = i;
                int cnt = 0;
                while (1) {
                        if (tmp % 2) {
                                break;
                        }
                        tmp /= 2;
                        cnt++;
                }
                if (ans < cnt) {
                        ans = cnt;
                        ans1 = i;
                }
        }
        cout<< ans1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
 
using namespace std;
 
void func145b (){
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (s.substr(0, n / 2) == s.substr(n / 2)) cout << "Yes\n";
	else cout << "No\n";
}
 
 
int main()
{
	func145b();
	return 0;	
}

Measured memory_bytes: 256
//  Be name khoda
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define F first
#define S second
#define MP make_pair

const int MAX = 100+9;
const ll MOD = 1e9+7;

int num[MAX];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int mx = -1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mx = max(mx, x);
		num[x]++;
	}
	if (mx % 2 == 0 && num[mx/2] != 1)
		return cout << "Impossible\n", 0;
	if (mx % 2 == 1 && num[mx/2+1] != 2)
		return cout << "Impossible\n", 0;
	int f = 0;
	for (int i = mx/2 +((mx % 2)?1:0); i <= mx; i++) {
		if (i > mx/2 +((mx % 2)?1:0) && num[i] < 2)
			return cout << "Impossible\n", 0;
		f += num[i];
	}
	if (f != n)
		return cout << "Impossible\n", 0;
	cout << "Possible\n", 0;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=1010;
int n,x,a[N],cnt;

int main(){
	scanf("%d%d",&n,&x);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	rep(i,1,n) if (x>=a[i]) cnt++,x-=a[i];
	if (x && cnt==n) cnt--;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for (i = 0; i <= VMAX; i++) {
    C[i] = 0;
  }

  for (i = 0; i < n; i++) {
    scanf("%hu",&A[i + 1]);
    C[A[i + 1]]++;
  }

  for (i = 1; i <= VMAX; i++) {
    /* code */
    C[i] = C[i] + C[i-1];
  }
  for (j = 1; j <= n; j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for (i = 1; i <= n; i++) {
    if ( i > 1) {
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");


  return 0;
}



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

string S;
size_t cur=0;

int term();
int expression();

int digit(){
	assert(isdigit(S[cur])); 
	int n = S[cur] - '0'; 
	cur++; 
	return n;
}

int number(){
	int n=digit();
	while(cur <S.size() && isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

int factor() {
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int term(){
	int sum = factor();
	while(S[cur] == '*' || S[cur] == '/'){
		char op = S[cur];
		cur += 1;
		int b = factor();
		if( op == '*')
			sum*=b;
		else {
			assert(b);
			sum/=b;
		}
	}
	return sum;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur];
		cur += 1;
		int b = term();
		if( op == '+')
			sum+=b;
		else 
			sum-=b;
	}
	return sum;
}



int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> S;
		cur=0;
		int r;
		r=expression();
		cout << r << endl;
	}
return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
            int count = 1;
            for (int j = i + 1; j < s.size(); j++) {
                if (s.at(j) == 'A' || s.at(j) == 'C' || s.at(j) == 'G' || s.at(j) == 'T') {
                    count++;
                }
                else goto next;
            }
            next:
            ans = max(ans, count);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

bool check(int N){
    multiset<int> S;
    for(int i=0;i<(1<<N);i++){
        int s; cin >> s;
        S.insert(s);
    }
    vector<int> v;
    {
        auto it = S.end();
        --it;
        v.push_back(*it);
        S.erase(it);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<(1<<i);j++){
            auto it = S.lower_bound(v[j]);
            if(it == S.begin()) return false;
            --it;
            v.push_back(*it);
            S.erase(it);
        }
    }
    return true;
}

int main(){
    int N;
    while(cin >> N){
        cout << (check(N) ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define OUTPUT(...) ostream& operator<<(ostream& os, __VA_ARGS__ const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> OUTPUT(vector<T>)
template <class T> OUTPUT(deque<T>)
template <class T> OUTPUT(set<T>)
template <class T> OUTPUT(multiset<T>)
template <class T, class U> OUTPUT(map<T,U>)
#undef OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } my_init;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    vector<int> v(n); cin >> v;
    sort(all(v));
    int cnt = 0;
    rep (i,n) loop (j,i+1,<n-1) {
        int k = lower_bound(all(v), v[i]+v[j])-v.begin();
        cnt += max<int>(0,k-(j+1));
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

def next_permutation a
  return a if a.length < 2

  found_k = -1

  for k in 0...(a.length-1)
    found_k = k if a[k] < a[k+1]
  end

  return a.reverse if found_k == -1

  found_l = -1
  for l in (found_k+1)...(a.length)
    found_l = l if a[found_k] < a[l]
  end

  if found_k < found_l
    a[found_k], a[found_l] = a[found_l], a[found_k]
  end

  a[(found_k+1)..-1] = a[(found_k+1)..-1].reverse
  a
end

#####
alps = ("a".."z").to_a

s = gs

if s == "zyxwvutsrqponmlkjihgfedcba"
  puts -1
elsif s.size != 26
  alps.each do |alp|
    if !(s.include?(alp))
      s = s + alp
      break
    end
  end
  puts s
else
  old_s = s.dup
  next_s = next_permutation(s)
  count = 0
  next_s.each_char do |char|
    #puts s
    #puts next_s
    if char != old_s[count]
      break
    end
    count += 1
  end
  puts next_s[0..count]
end


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

#define endl ("\n")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ (a)*(a)
#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 deb(x) cout<<#x<<" "<<x<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll mod = 1e9L+7;
int n;
vector<ll> inp;
vector<int> dp;

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    /*freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    #ifndef ONLINE_JUDGE
    #endif*/
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,x,t;
        cin>>n>>x>>t;
        
        ll ans = 0;
        ans += n/x;
        ans *= t;
        if(n%x != 0) ans += t;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.Stack;

import javax.lang.model.util.ElementScanner6;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Stack<Character> stack = new Stack<>();
        char garbage[] = new char[2];
        
        while(true)
        {
            String answer="yes";
            String input = sc.nextLine();
            if(input.equals(".")) break;
            char cinput[] = input.toCharArray();

            for(int i=0; i<input.length(); i++)
            {
                if(cinput[i]==')')
                {
                    if(stack.empty()) answer="no";
                    else if(stack.peek()=='(')
                    {
                        stack.push(cinput[i]);
                        garbage[0] = stack.pop();
                        garbage[1] = stack.pop();
                    }
                    else answer="no";
                }
                else if(cinput[i]==']')
                {
                    if(stack.empty()) answer="no";
                    else if(stack.peek()=='[')
                    {
                        stack.push(cinput[i]);
                        garbage[0] = stack.pop();
                        garbage[1] = stack.pop();
                    }
                    else answer="no";
                }
                else if (cinput[i]=='(' || cinput[i]=='[') stack.push(cinput[i]);
            }
            
            if(!stack.empty()) answer="no";
            System.out.println(answer);

            stack.clear();
        }
        sc.close();
    }
}


Measured memory_bytes: 52192
#include<stdio.h>
#define N 100
#define X 0
#define Y 1
#define Z 2

int n,t;
int M[N][N];
int c[N],d[N],f[N];

void dfs1(int);
void dfs(void);

int main(){
  int u,v;
  int i,j,k;
  scanf("%d", &n);

  for(i=0;i<n;i++){
    for(j = 0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0;j < k; j++){
      scanf("%d" , &v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();
  return 0;
}

void dfs1(int u){
  int i;
  c[u] = Y;
  d[u] =++t;
  for(i = 0;i < n;i++){
    if(M[u][i] == 0)continue;
    if(c[i] == X) dfs1(i);

  }
  c[u]=Z;
  f[u] =++t;
}
void dfs(void){
  int i;
  for(i = 0;i < n;i++){
    c[i] = X;
  }
  t= 0;
  for(i = 0; i < n; i++){
    if(c[i] == X)dfs1(i);
  }
  for(i = 0;i < n; i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

Measured memory_bytes: 636
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

//#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	char s[110];
	double Ld;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[100010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


	scanf("%lf",&Ld);
//	scanf_s("%lf",&Ld);


//	scanf("%s",&s);
//	scanf_s("%s",&s,110);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],100010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	printf("%f",Ld*Ld*Ld/27);


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
from collections import deque 

N,M = map(int, input().split())
root = [[] for _ in range(N)]

for _ in range(M):
	a,b = map(int,input().split())
	root[a - 1].append(b)
	root[b - 1].append(a)

q = deque()
q.append(1)
ans = [0 for _ in range(N)]

while len(q) > 0:
	v = q.popleft()
	for ike in root[v - 1]:
		q.append(ike)
		if(ans[ike - 1] == 0):
			ans[ike - 1] = v

	root[v-1].clear()

print('Yes')
for a in ans[1::]:
	print(a)

Measured memory_bytes: 34860
#%%
n, a, b = map(int, input().split())
if abs(a-b) % 2 == 0:
    ans = abs(a-b) // 2
else:
    x = min(a, b)
    y = max(a, b)
    c = (x + y - 1) // 2
    d = (2 * n - a - b + 1) //2
    ans = min(c, d)
print(ans)

Measured memory_bytes: 3060
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines
    }yield if(isPrime(in.toInt)) in else -1

    println(lines.toList.tail.filter(_ != -1).length)
  }

  def isPrime(n: Int): Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)
}

Measured memory_bytes: 103440
def check(a, b, H, L):


	if H[a - 1] <= H[b - 1]:
			L[a - 1] = 0
	if H[b - 1] <= H[a - 1]:
			L[b - 1] = 0
	
n, m = map(int, input().split())
H = list(map(int, input().split()))
L = [i for i in range(1, n + 1)]
count = 0
for _ in range(m):
	a, b = map(int, input().split())
	check(a, b, H, L)

for i in L:
	if i != 0:
		count += 1
print(count) 


Measured memory_bytes: 20132
N,K = map(int, input().split())
memo = (N-1)*(N-2)//2
if K <= memo:
    print((N-1) + memo - K)
    for i in range(2,N+1):
        print(1,i)
    cnt = 0
    i = 2
    j = i + 1
    while cnt < memo-K:
        while j <= N and cnt < memo-K:
            print(i,j)
            j += 1
            cnt += 1
        i += 1
        j = i + 1
else:
    print(-1)

Measured memory_bytes: 3608
n=int(input())
array=list(map(int,input().split()))
ans=0
flag=0
for i in range(len(array)):
    if i+1==array[i]:
        if flag==0:
            ans+=1
            if(i<len(array)-1 and array[i+1]==i+2):
                flag=1
        else:
            flag=0
print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 500;

int c[N],s[N],f[N];

int arrival_time(int st, int n) {
	int ret=0;
	for(int i=st; i<=n-2; i++) {
		if(ret<s[i]) ret=s[i]+c[i];
		else if (ret%f[i]==0) ret+=c[i];
		else ret+=f[i]-ret%f[i]+c[i];
	}
	return ret;
}

int main() {
	int n;cin>>n;
	rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
	rep(i,n-1) cout<<arrival_time(i,n)<<endl;
	cout<<0<<endl;
}


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

int main() {
  int l,r,d;
  int ans=0;
  cin >> l >> r >> d;
  for(int i=l; i<=r; i++){
    if(i%d==0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

    print(((n - 1) * n) // 2 + ((m - 1) * m) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38492
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll x,y;
    cin >>x >> y;
    bool che = false;
    for(int i=0;i<=100;i++){
        ll hon =i*4+(x-i)*2;
        if(x-i<0)continue;
        ll hito = i+(x-i);
        if(hon==y&&hito==x){
            che = true;
        }
    }
    if(che){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}
    



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

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

#define INF 1000000000

typedef unsigned long long ull;

using namespace std;

int main() {
    string s;
    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else
        cout << "ABC" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int n;
vector<P> v[100100];
int k = 0;
int ans[100100];
int flag[100100];
int main(){
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        v[a].push_back(P(b,i));
        v[b].push_back(P(a,i));
    }
    queue<P> que;
    que.push(P(1,0));
    while(!que.empty()){
        P p =que.front();
        k = max(k,(int)v[p.first].size());
        que.pop();
        flag[p.first] = true;
        int i=1;
        for(auto j:v[p.first]){
            if (i == p.second)
            {
                i++;
            }
            if(flag[j.first]){
                continue;
            }
            if(ans[j.second]){
                continue;
            }
            ans[j.second] = i;
            que.push(P(j.first,i));
            i++;
        }
    }
    cout << k << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424
package main

import (
	"fmt"
	"strings"
)

var N, K int
var S string

func main() {
	fmt.Scan(&N, &K, &S)
	//	if N >= K {
	a := strings.Split(S, "")
	var b string

	for i := 0; i < N; i++ {
		if i == K-1 {
			b += strings.ToLower(a[K-1])
		} else {
			b += a[i]
		}
	}
	fmt.Printf("%s\n", b)
} //else {
//		panic("a")
//	}
//}


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

const int inf = 1e9;

void ckmin (int &a, int b) {
	a = min(a, b);
}

signed main () {
	int h, n;
	cin >> h >> n;
	vector < int > a(n), b(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i] >> b[i];
	vector < int > dp(h + 1, inf);
	dp[0] = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 0; j < n; ++j) 
			ckmin(dp[i], dp[max(i - a[j], 0)] + b[j]);
	}
	cout << dp[h] << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int selectionSort(int a[],int n){
	int ans = 0;
	for(int i = 0; i < n;i++){
		int mini = i;
		for(int j = i; j < n;j++){
			if(a[j] < a[mini])
			mini = j;
		}
		if(i != mini)
		swap(a[i],a[mini]),
		ans++; 
		
	}
	return ans;
}
int main(){
   int n,a[110];
   scanf("%d",&n);
   for(int i = 0; i < n;i++)
   scanf("%d",&a[i]);
   int ans = selectionSort(a,n);
   for(int i = 0;i < n;i++)
   printf("%d%c",a[i],i == n-1?'\n':' ');
   printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3204
#ITP1-ITP1_4_C
while True:
  a,op,b = (input().split())
  a = int(a)
  b = int(b)
  if op == "?":
    break
  elif op == "+":
    print(a+b)
  elif op == "-":
    print(a-b)
  elif op == "*":
    print(a*b)
  elif op == "/":
    print(a//b)
  


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

int main() {
    int n,m;
    cin >> n >> m;
    int a[101][101],b[101],c[101] = {};
    for(int i = 0;i < n;i++){
        for(int k = 0;k < m;k++){
            cin >> a[i][k];
        }
    }
    for(int j = 0;j < m;j++){
        cin >> b[j];
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3112
using System;

public class Hello
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int minSum = int.MaxValue;
        for (int i = 1; i <= n / 2; i++)
        {
            int a = i;
            int sum = 0;
            while (a > 0)
            {
                sum += a % 10;
                a /= 10;
            }
            int b = n - i;
            while (b > 0)
            {
                sum += b % 10;
                b /= 10;
            }
            if (sum < minSum)
                minSum = sum;
        }
        Console.WriteLine(minSum);
    }
}

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

const int N = 1e4 + 2;
int n, a[N], b[N];
int32_t main() {
  // ifstream cin("data.in");
   cin >> n;
   for(int i = 0; i < n; ++i) {
      cin >> a[i];
   }
   for(int i = 0; i < n; ++i)
      cin >> b[i];
   int extra = 0;
   for(int i = 0; i < n; ++i) {
      if(a[i] < b[i]) {
         extra += (b[i] - a[i]) / 2;
      }
   }
   for(int i = 0; i < n; ++i) {
      if(a[i] > b[i]) {
         int need = a[i] - b[i];
         if(extra - need < 0) {
            cout << "No";
            return 0;
         }
         extra -= need;
      }
   }
   cout << "Yes";

}


Measured memory_bytes: 384
from collections import defaultdict
d = defaultdict(int)
N = int(input())
a = list(map(int, input().split()))
for x in a:
    d[x] += 1
ans = 0
for k in d:
    if d[k] < k:
        ans += d[k]
    else:
        ans += d[k]-k
print(ans)

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

int main() {
  int N;
  cin>>N;
  vector <int>a(N+1);
  for (int i(1);i<=N;i++) a[i]=i;
  ll ans(1);
  for (int i(2);i<=N;i++){
    int cnt(0);
    int n=a[i];
    if(a[i]==1) continue;
    for (int j(i);j<=N;j++){
      while (true){
        cerr << a[j] <<" "<< n << endl;
        if (a[j]%n==0){
          a[j]=a[j]/n;
          cnt++;
        }
        else break;
      }
    }
    cerr << "ans"<<cnt<<endl;
    ans*=(cnt+1);
    ans%=1000000007;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php
list($n,$m)=explode(" ",trim(fgets(STDIN)));
$tree=new UnionFind($n);
$i=0;
while($i<$m){
  list($a,$b)=explode(" ",trim(fgets(STDIN)));
  --$a;
  --$b;
  $tree->unite($a,$b);
  ++$i;
}
$i=0;
while($i<$n){
  $ans[$i]=$tree->root($i);
  ++$i;
}
echo count(array_count_values($ans))-1;

//hideyuk1さんのをお借りしました
// Union-Find：同じグループに属するかどうかを判定する
class UnionFind
{
    private $par; // par[$i]:$iの親 自分が根の場合は自身のindexとなる
    private $size;
 
    function __construct($n)
    {
        for ($i = 0; $i < $n; $i++) {
            $this->par[$i] = $i; // 最初は全てが根
            $this->size[$i] = 1;
        }
    }
 
    function root($x)
    { // 根を返す
        if ($this->par[$x] === $x) return $x; // 根の場合
        return $this->par[$x] = $this->root($this->par[$x]); // 全ての枝の親を根にしながら再帰処理
    }
 
    function unite($x, $y)
    { // $xと$yの木を併合
        $ix = $this->root($x);
        $iy = $this->root($y);
        if ($ix === $iy) return;
        if ($this->size[$ix] < $this->size[$iy]) list($ix, $iy) = [$iy, $ix];
        $this->size[$ix] += $this->size[$iy];
        $this->par[$iy] = $ix; // $yの根を$xの根に付ける
    }
 
    function isSame($x, $y)
    { // $xと$yの根が同じか
        return $this->root($x) === $this->root($y);
    }
 
    function size($x)
    {
        return $this->size[$this->root($x)];
    }
}

Measured memory_bytes: 30432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.size();
    int now = 0;
    rep(i, n) {
        now += s[i]-'0';
        now %= 9;
    }
    string ans = "No";
    if (now==0) ans = "Yes";
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3716
//
// Compute via multiplicative property (sigma0)
// sigma(p^e) = 1 + e
// sigma(n.m) = sigma(n) sigma(m)  (for gcd(n, m) = 1)
//
const makeDivisor0 = (n) => {
  const a = new Uint8Array(n); // sieve
  const b = new Int32Array(n); // divisor sigma
  a[0] = 0;
  a[1] = 0;
  a.fill(1);
  b.fill(1);

  // Identify prime factor during sieve loop
  for (let p = 2; p < n; p++) {
    // non-prime
    if (a[p] === 0) {
      continue;
    }

    // Traverse n with ν_p(n) = e
    let sigma = 1;
    for (let pe = p; pe < n; pe *= p) {
      sigma++; // sigma = 1 + e

      for (let i = 1, pm = pe; pm < n; i++, pm += pe) {
        // Skip ν_p(n) > e
        if (i % p === 0) {
          continue;
        }
        a[pm] = 0;
        b[pm] *= sigma; // multiplicative by distinct prime factor
      }
    }
  }

  return b;
}

const solve = (n, debug = 0) => {
  const divisor = makeDivisor0(n + 1);
  let c = 0;
  for (let i = 1; i <= n; i++) {
    c += i * divisor[i];
  }
  return c;
};

const main = async (istr, ostr) => {
  const readline = require('readline');
  const it = readline.createInterface({input: istr})[Symbol.asyncIterator]();
  const getLine = async () => (await it.next()).value;
  const getMany = async () => (await getLine()).split(' ');

  const n = Number(await getLine());
  const result = solve(n);
  ostr.write(`${result}\n`);
};

if (require.main === module) {
  main(process.stdin, process.stdout);
}


Measured memory_bytes: 82212
N, H = map(int, input().split())
A = []
B = []

for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

def solver(N, H, A, B):
    x = max(A)
    B.sort()
    B.reverse()

    ans = 0
    for b in B:
        if b < x:
            break
        H -= b
        ans += 1
        if H <= 0:
            return ans
    
    return ans + -(-H//x)

print(solver(N, H, A, B))

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

int main() {
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    if(A > K) {
        cout << K << endl;
    }
    else if(A+B >= K) {
        cout << A << endl;
    }
    else {
        cout << A-(K-A-B) << endl;
    }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll min_cnt = 1e12 + 1;
    for (ll i = 1; i <= sqrt(N); i++)
    {
        if (N % i == 0)
        {
            ll dist = (i - 1) + (N / i - 1);
            if (min_cnt > dist)
            {
                min_cnt = dist;
            }
        }
    }
    cout << min_cnt << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000, mod = 1_000_000_007;

    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }

    long choose(int n, int a)
    {
        if(n - a < a) return choose(n, n - a);
        long fn = 1, fa = 1;
        for(int i = 1; i <= a; i++)
        {
            fn *= n - i + 1;
            fn %= mod;
            fa *= i;
            fa %= mod;
        }

        // System.out.println(fn);
        // System.out.println(fa);

        return fn * pow(fa, mod - 2) % mod;
    }    

    long pow(long a, int pow)
    {
        long res = 1;
        while(pow > 0)
        {
            if(pow % 2 != 0) {
                res *= a;
                res %= mod;
            }
            a = a * a;
            a %= mod;
            pow /= 2;
        }

        return res;
    }

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        new Main().c();
        out.flush();
    }


    void c() throws Exception
    {
        int n = readInt();
        int[][] ary = new int[n][3];
        for(int i = 0; i < n; i++)
        {
            int[] a = toIntArray();
            int pa = a[0], pb = a[1], pc = pb + pa;
            ary[i] = new int[]{pa, pb, pc};
        }

        Arrays.sort(ary, (a, b)->(b[2] - a[2]));

        long sum = 0;
        int pos = 0, dir = 1;
        for(int i = 0; i < n; i++)
        {
            sum += dir * ary[i][pos];
            pos = 1 - pos;
            dir *= -1;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 50772
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    int n; cin>>n;
    vector<ll>h;
    rep(i,n){
        ll b; cin>>b;
        h.push_back(b);
    }
    
    int res = 0;
    int res_tmp = 0;

    for(int i=0; i<n-1; i++){
        if(h[i]>=h[i+1]){
            res_tmp++;
        }
        else{
            res_tmp = 0;
        }
        res = max(res, res_tmp);
    }
    cout << res << ln;
    return 0;
}

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

int main() {
  long K, A, B;
  cin >> K >> A >> B;
  if (K <= A) cout << 1 << endl;
  else if (A <= B) cout << -1 << endl;
  else {
    K -= A;
    long tmp = (K - 1) / (A - B) + 1;
    cout << 1 + tmp * 2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i=sc.nextInt();
		int a[]=new int[i];
		for(int j=0;j<i;j++) {
			a[j]=sc.nextInt();
		}
		Arrays.sort(a);
		long sum=0;
		for(int j=0;j<i;j++) {
			sum+=a[j];
		}
		System.out.println(a[0]+" "+a[i-1]+" "+sum);

	}

}



Measured memory_bytes: 41884
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k;
string s,ss,sss;
vector<lo> v;

inline lo solve(){
	scanf("%lld %lld %lld",&n,&m,&k);
	for(lo i=0;i<=m+5;i++){
		lo at=i*n;
		if((n+at)%m==k){printf("YES\n");return 0;}
	}
	printf("NO\n");
	return 0;
}

int main(void){
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

using namespace std;

using ll = long long;

bool solve(string s) {
  int a[26]={0};
  for(char c:s) {
    a[c-'A']++;
  }
  int r=0;
  for(int i:a){
    if(i==2)
      r++;
  }
  return r==2;
}

int main() {
  string b;
  cin >> b;
  if (solve(b)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256