akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string grid[h];
    rep(i,h) cin >> grid[i];
    vector<ll> letter(26,0);
    rep(i,h){
        rep(j,w){
            letter[grid[i][j]-'a']++;
        }
    }
    bool ok = 1;
    if (h%2 == 0 && w%2 == 0){
        rep(i,26) if (letter[i]%4) ok = 0;
    }
    else if (h%2 && w%2){
        int odd = 0,even = 0;
        rep(i,26){
            if (letter[i]%4 && letter[i]%2 == 0) even++;
            if (letter[i]%2){
                odd++;
                if ((letter[i]-1)%4) even++;
            }
        }
        if (odd != 1 || even > h/2+w/2 ) ok = 0;
    }
    else if(h%2){
        int even = 0;
        rep(i,26){
            if (letter[i]%4 && letter[i]%2 == 0) even++;
            if (letter[i]%2) ok = 0;
        }
        if (even > w/2) ok = 0;
    }
    else{
        int even = 0;
        rep(i,26){
            if (letter[i]%4 && letter[i]%2 == 0) even++;
            if (letter[i]%2) ok = 0;
        }
        if (even > h/2) ok = 0;
    }
    Yes(ok);
}


Measured memory_bytes: 256
//
//  main.cpp
//  Mitusi_2019_D
//
//  Created by Joe Mori on 2020/06/29.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<string>
int main() {
    // insert code here..;
    int n,ans=0;
    std::string str;
    std::cin>>n>>str;
    int count=0;
    for(int j=0;j<10;j++){
        for(int k=0;k<10;k++){
            for(int l=0;l<10;l++){
                for(int i=0;i<n;i++){
//                    std::cout<<"i:"<<str[i]-'0'<<" j:"<<j<<" k:"<<k<<" l:"<<l<<std::endl;
                   // std::cout<<j*100+k*10+l<<std::endl;
                    if(str[i]-'0'==j&&count==0){
                        count++;
                        continue;
                    }
                    if(str[i]-'0'==k&&count==1){
                        count++;
                        continue;
                    }
                    if(str[i]-'0'==l&&count==2){
                        count++;
                    }
                    if(count==3){
                        ans++;
                        count=0;
                        break;
                    }
                    if(i==n-1||(i==n-2&&count==1)||(i==n-3&&count==0)){
                        count=0;
                        break;
                    }
                }
//                std::cout<<"ans:"<<ans<<std::endl;
            }
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  int a[9], n, b;
  bool c[9];
  string res = "No";
  for(int i=0; i<9; i++){
    cin >> a[i];
    c[i] = false;
  }
  cin >> n;
  for(int j=0; j<n; j++){
    cin >> b;
    for(int i=0; i<9; i++){
      if(a[i] == b){
        c[i] = true;
        break;
      }
    }
  }
  if( c[0]&c[1]&c[2] || c[3]&c[4]&c[5] || c[6]&c[7]&c[8] ) res = "Yes";
  if( c[0]&c[3]&c[6] || c[1]&c[4]&c[7] || c[2]&c[5]&c[8] ) res = "Yes";
  if( c[0]&c[4]&c[8] || c[2]&c[4]&c[6] ) res = "Yes";
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll x,n;
	cin>>x>>n;
	vector<ll> vec;
	ll xx;
	if(n==0)
	{
	   cout<<x<<"\n";	
	}
	else
	{
	  for(int i=0;i<n;i++)
   	  {
		  cin>>xx;
		  vec.push_back(xx);
	  }
	  sort(vec.begin(),vec.end());
	  ll mini =INT_MAX;
	  ll num;
	  for(int i=-110;i<110;i++)
	   {
	    	if(find(vec.begin(),vec.end(),i) == vec.end())
	    	{
	    		ll dif = abs(i-x);
	    		if(dif<mini)
	    		{
	    			num = i;
	    			mini = dif;
	    		}
	    	}
	   }
	   cout<<num<<"\n";
	}
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  int color[8] = {};
  int a = 0;
  for(int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if(tmp <= 399){
      color[0] = 1;
    }else if(tmp <= 799){
      color[1] = 1;
    }else if(tmp <= 1199){
      color[2] = 1;
    }else if(tmp <= 1599){
      color[3] = 1;
    }else if(tmp <= 1999){
      color[4] = 1;
    }else if(tmp <= 2399){
      color[5] = 1;
    }else if(tmp <= 2799){
      color[6] = 1;
    }else if(tmp <= 3199){
      color[7] = 1;
    }else {
      a++;
    }
  }
  int cnt = 0;
  for(int i = 0; i < 8; i++){
    cnt += color[i];
  }
  cout << max(cnt, 1) << " " << cnt + a << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int L = in.nextInt();
    int R = in.nextInt();
    int d = in.nextInt();

    int count = 0;
    for (int i = L; i <= R; i++) {
      if (i % d == 0) count++;
    }
    System.out.println(count);
  }

  public static int gcd(int a, int b) {
        if (b == 0) return a;
    return gcd(b, a % b);

  }

  public static long gcd(long a, long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
  }
}

Measured memory_bytes: 27112
from collections import defaultdict
n, m = map(int, input().split())
a = list(map(lambda x: x%m, (map(int, input().split()))))

d = defaultdict(int)

s = 0

for i in range(n):
        s += a[i]
        s %= m
        d[s] += 1

ans = d[0]
for k in d.keys():
    ans += d[k]*(d[k]-1)//2

print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    ll ans = 1;
    REP(i, 40) {
        if ((n >> i) & 1)
            ans = (ans * m) % MOD;
        m = (m * m) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys


def solve(C: str):
    a = "abcdefghijklmnopqrstuvwxyz"
    for i in range(len(a)):
        if a[i] == C:
            print(a[i+1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = int(input())

if int(int(N / 1.08) * 1.08) == N:
        print(int(N / 1.08))
elif int(int(N / 1.08 + 1)* 1.08) == N:
        print(int(N / 1.08 + 1))
else:
        print(":(")

Measured memory_bytes: 38384
N=int(input())
max1=0
second_max=0
ind=[]
for i in range(N):
  t=int(input())
  if second_max < t:
    if max1<t:
        second_max=max1
        max1=t
        ind.clear()
        ind.append(i)
    elif max1==t:
        second_max=max1
        ind.append(i)
    else:
        second_max=t
if len(ind)==1:
    for i in range(N):
      if i == ind[0]:
        print(second_max)
      else:
          print(max1)
else:
    for i in range(N):
          print(max1)


Measured memory_bytes: 4540
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// BinaryIndexedTree(Fenwick-Tree); フェニック木
// ：BIT<long long> bit(xx)で初期化、bit.sum(n)で0~n番目までの累積和を計算
template<typename T> class BIT {
private:
    const long long n; vector<T> bit;
public:
    BIT(long long size) : n(size+1), bit(n, 0){}
    BIT(const vector<T>& v) : n((long long)v.size()+1), bit(n, 0){ for(long long i = 0; i < n-1; i++) add(i,v[i]); }
    T sum(long long i){ i++; T s = 0; while(i > 0){ s += bit[i], i -= i & -i; } return s; }
    void add(long long i, T x){ i++; while(i < n) bit[i] += x, i += i & -i; }
    void print(){ for(long long i = 0; i < n-1; i++) cout << sum(i)-sum(i-1) << (i != n-2 ? " " : "\n"); }
    void print_sum(){ for(long long i = 0; i < n; i++) cout << sum(i-1) << (i != n-1 ? " " : "\n"); }
};

int main(){
    Init();
    ll n, q;
    cin >> n >> q;
    vi c(n);
    rep(i, n){
        cin >> c[i];
        c[i]--;
    }

    // クエリの先読み
    vector<pair<pair<ll, ll>, ll>> rli(q);
    rep(i, q){
        ll l, r;
        cin >> l >> r;
        l--; r--;
        rli[i] = make_pair(make_pair(r, l), i);
    }

    // クエリを昇順に処理
    sort(all(rli));
    vi ans(q, 0);
    
    // 最も右にある玉を1、それ以外を0
    BIT<long long> bit(n);
    // 最も右のある位置を管理
    vi pos(n, -1);

    // クエリの答えは、(r-l+1)個から重複している個数を減算したもの（重複していないものを足し合わせたもの）    
    ll cur = 0;
    rep(i, q){
        ll l = rli[i].first.second;
        ll r = rli[i].first.first;
        ll Idx = rli[i].second;
        for(; cur <= r; cur++){
            // すでに存在している場合
            if(pos[c[cur]] != -1) bit.add(pos[c[cur]], -1);
            bit.add(cur, 1);
            pos[c[cur]] = cur;
        }
        // 区間和の計算
        ans[Idx] = bit.sum(r) - bit.sum(l-1);
    }
    for(auto &num: ans) cout << num << endl;
}

Measured memory_bytes: 31136
import java.util.Scanner;

//https://onlinejudge.u-aizu.ac.jp/problems/1147
public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	final int DAY_OF_MILLENNIUM = 196470;
	final int DAY_OF_SPECIAL_YEAR = 200;
	final int DAY_OF_NORMAL_YEAR = 195;
	final int DAY_OF_SMALL_DAY = 19;
	final int DAY_OF_BIG_MONTH = 20;

	int n = sc.nextInt();
	for (int i = 0; i < n; i++) {
	  int year = sc.nextInt();
	  int month = sc.nextInt();
	  int date = sc.nextInt();

	  int specialYear = (year - 1) / 3;
	  int normalYear = year - 1 - specialYear;
	  int result = specialYear * DAY_OF_SPECIAL_YEAR;
	  result += normalYear * DAY_OF_NORMAL_YEAR;

	  if (year % 3 == 0) {
		result += (month - 1) * DAY_OF_BIG_MONTH;
	  } else {
		int monthOfResult = (month - 1) / 2;
		int dayOfResult = month - 1 - monthOfResult;
		result += monthOfResult * DAY_OF_SMALL_DAY;
		result += dayOfResult * DAY_OF_BIG_MONTH;
	  }
	  result += date - 1;
	  result = DAY_OF_MILLENNIUM - result;
	  System.out.println(result);
	}
  }
}


Measured memory_bytes: 26268
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());

    for (int i = 0; i < n; i++) {
      String s = br.readLine();
      double a = Math.pow(Double.parseDouble(s.split(" ")[0]),2);
      double b = Math.pow(Double.parseDouble(s.split(" ")[1]),2);
      double c = Math.pow(Double.parseDouble(s.split(" ")[2]),2);

      if( a + b == c ){
        System.out.println("YES");
      } else if ( a + c == b) {
        System.out.println("YES");
      } else if ( b + c == a) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
  }
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n;
  cin>> n;
  while(n--){
    int cnt=0;
    string s;
    map<int,char> m;
    cin>> s;
    for(int i=0;i<s.size();i++){
      if(isalpha(s[i])) m[cnt]=s[i];
      else if(s[i]=='<') cnt--;
      else if(s[i]=='>') cnt++;
    }

    for(map<int,char>::iterator it=m.begin();it!=m.end();it++){
      cout<< (*it).second;
    }

    cout<< endl;
  }
}

Measured memory_bytes: 1204
n,k=map(int,input().split())
arr=[0 for i in range(n)]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for b in a:
        arr[b-1]+=1
cnt=0
for i in range(n):
    if arr[i]==0:
        cnt+=1
print(cnt)
   

Measured memory_bytes: 9188
n = int(input())
cards = []
for i in range(n):
    ins = input().split()
    suit = ins[0]
    num = ins[1]
    cards.append([suit, num])

for suit in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        if len([card for card in cards if card[0] == suit and card[1] == str(i)]) == 0:
            print(" ".join([suit, str(i)]))

Measured memory_bytes: 7684
#include<stdio.h>
int main()
{

    int n,m;
    scanf("%d %d",&n,&m);

    if(n>=1 && n<=100)
    {
        if(m>=0 && m<=n)
        {
            if(m==n)
            {
                printf("Yes");
            }
            else
                printf("No");
        }
    }

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;

template<typename T>
std::map<T,T> prime_factor(T n){
  std::map<T,T> res;
  for (T i=2;i*i<=n;i++){
    while( n%i == 0){
      ++res[i];
      n/=i;
    }
  }
  if (n!=1) res[n] = 1;
  return res;

}

template<typename T >
T modpow(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(long long N){
    map<ll,ll> factors;
    for (ll i=2;i<=N;i++){
        map<ll,ll> a = prime_factor(i);
        for (auto const& obj : a){
            ll k = obj.first;
            ll v = obj.second;
            factors[k]+=v;
        }

    }
    
    if (N == 1){
        printf("1\n");
    }else{
        ll ret = 1;
        for (auto const& obj : factors){
            ll k = obj.first;
            ll v = obj.second;
            ret*= v+1;
            ret %=MOD;
        }
        printf("%lld\n",ret%MOD);
    }


}

// Generated by 1.1.6 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<bits/stdc++.h>
using namespace std;
#define int long long
int pw[22];
int s = -1e8;
signed main(){
	pw[0] = 1;
	string v;
	for(int i = 1 ; i <=10 ; ++i) pw[i] = pw[i - 1] * 10;
	for(int i = 10 ; i >= 0 ; --i)
	{
		int check = pw[i];
		cout << "? " << check << "\n";
		fflush(stdout);
		cin >> v;
		if(v == "Y") 
		{
			s = i;
			break;
		}
	}
	if(s == 10)
	{
		for(int i = 10 ; i >= 0 ; --i)
		{
			int check = pw[i] - 1;
			if(i == 0) check = 1;
			cout << "? " << check << "\n";
			fflush(stdout);
			cin >> v;
			if(v == "N") 
			{
				s = i;
				break;
			}
		}
	}
	int l = pw[s + 1] , r = pw[s + 2] - 1;
	while(l < r)
	{
		int mid = l + r >> 1;
		cout << "? " << mid << "\n";
		fflush(stdout);
		cin >> v;
		if(v == "Y") r = mid;
		else l = mid + 1; 
	}
	if(l / 10 != 0) cout << "! " << l / 10;
	else cout << "! 1";
	fflush(stdout);
	
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
//freopen("","r",stdin);
//freopen("","w",stdout);
int main(){
    fast;
    int n;
    ll ans = 1;
    cin >> n;
    vector<int> x(n),y(n),cmp;

    for(auto &i : x)cin >> i;
    for(auto &i : y)cin >> i;
    int idi = -1,idf = -1;
    fore(i,0,n)
        cmp.pb(i + 1);
    int cnt = 1;
    do{ 
            
            bool flag = 1;
            fore(i,0,n){
                if(x[i] != cmp[i]){
                    flag = 0;
                    break;
                }
            }
            if(flag)
                idi = cnt;


            flag = 1;
            fore(i,0,n){
                if(y[i] != cmp[i]){
                    flag = 0;
                    break;
                }
            }
            if(flag)
                idf = cnt;
        
            if(idf != -1 && idi != -1)
                break;
            cnt++;
    }while(next_permutation(all(cmp)));
    cout << abs(idf - idi) << '\n';
    return 0;

}

Measured memory_bytes: 256
n = int(input())
R = [int(input()) for i in range(n)]
res = -10e9
for i in range(n):
    if i == 0:
        minv = R[i]
    else:
        if res < R[i] - minv:
            res = R[i] - minv
        if R[i] < minv:
            minv = R[i]
print(res)



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

using namespace std;

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

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }


int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> C(256);
  for (int i = 0; i < S.size(); i++) {
    C[S[i]]++;
  }
  mint ans = 1;
  for (int i = 0; i < 256; i++) {
    ans *= C[i] + 1;
  }
  ans -= 1;
  cout << ans.n << endl;
}

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

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    s = ' ' +  s; // 文字列を1オリジンで考える
    vector<int> dp(++n); // sの先頭からi文字目(1<=i<=n)までに含まれるACの数を記録する配列
    rep(i, n) {
        if (i == 0 || i == 1) dp[i] == 0;
        else if (s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
        // cout << dp[i] << " ";
    }
    cout << endl;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        // int cnt = 0;
        // for (int i = l; i <= r - 1; i++) {
        //     if (s[i] == 'A' && s[i+1] == 'C') cnt++;
        // }
        // cout << cnt << endl;
        cout << dp[r] - dp[l] << endl;
    }
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll x, c = 100, s = 0;
  cin >> x;
  while (c < x) {
    ld v = c;
    v *= 1.01;
    c = v;
    s++;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M, Q;
        public int[,] MP;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
                Q = line[2];
            }

            MP = new int[N + 1, N + 1];

            for (int m = 0; m < M; m++)
            {
                var line = Input.ReadIntArray();
                int p = line[0] - 1;
                int q = line[1] - 1;
                MP[0, q] += 1;
                MP[p + 1, q] -= 1;
                // MP[0, p] += 1;
                // MP[0, q + 1] -= 1;
                // MP[q + 1, p] -= 1;
                // MP[q + 1, q + 1] += 1;
            }

            // imos
            for (int y = 0; y <= N; y++)
            for (int x = 0; x <= N; x++)
            {
                if(x > 0)
                    MP[y, x] += MP[y, x - 1];
            }

            for (int y = 0; y <= N; y++)
            for (int x = 0; x <= N; x++)
            {
                if(y > 0)
                MP[y, x] += MP[y - 1, x];
            }

            for (int query = 0; query < Q; query++)
            {
                var line = Input.ReadIntArray();
                int p = line[0] - 1;
                int q = line[1] - 1;
                Console.WriteLine(MP[p, q]);
            }
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 18672
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

ll len[100000];
int N, L;
vector<int> res;
int ok_min;


int main(void){
	ok_min = -1;
	cin >> N >> L;
	REP(i, N){
		int a;
		cin >> a;
		len[i] = a;
	}
	REP(i, N-1){
		if(len[i] + len[i+1] >= L){
			ok_min = i;
			break;
		}
	}
	if(ok_min == -1){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;

	REP(i, ok_min){
		cout << i+1 << endl;
	}
	for(int i = N-1;ok_min+1 < i;i--){
		cout << i << endl;
	}
	cout << ok_min+1 << endl;
	return 0;
}


Measured memory_bytes: 1536
import           Control.Monad.Writer

main = do
  getLine
  a <- fmap readWords getLine
  b <- fmap readWords getLine
  print $ solve $ Cities a b
  where
    readWords :: (Read a) => String -> [a]
    readWords = map read . words

solve :: Cities -> Int
solve cities = getSum killResult
  where
    (_, killResult) = runWriter $ killThemAll cities

type MonsterCount = Int

type SavePower = Int

type KillResult = Sum Int

data Cities =
  Cities
    { monsterCounts :: [MonsterCount]
    , saverPowers   :: [SavePower]
    }

killThemAll :: Cities -> Writer KillResult ()
killThemAll Cities {saverPowers = []} = writer ((), Sum 0)
killThemAll cities = do
  cities1 <- firstSaverSaveFirstCity cities
  cities2 <- firstSaverSaveSecondCity cities1
  killThemAll $ restCities cities2
  where
    firstSaverSaveFirstCity :: Cities -> Writer KillResult Cities
    firstSaverSaveFirstCity Cities {monsterCounts = m:ms, saverPowers = s:ss} =
      writer (Cities (mAfter : ms) (sAfter : ss), killCount)
      where
        (mAfter, sAfter, killCount) = kill m s
    firstSaverSaveSecondCity :: Cities -> Writer KillResult Cities
    firstSaverSaveSecondCity Cities { monsterCounts = m1:m2:ms
                                    , saverPowers = s:ss
                                    } =
      writer (Cities (m1 : m2After : ms) (sAfter : ss), killCount)
      where
        (m2After, sAfter, killCount) = kill m2 s
    kill :: MonsterCount -> SavePower -> (MonsterCount, SavePower, KillResult)
    kill monsterCount savePower =
      (monsterCount - killCount, savePower - killCount, Sum killCount)
      where
        killCount = min monsterCount savePower
    restCities :: Cities -> Cities
    restCities Cities {monsterCounts = m:ms, saverPowers = s:ss} = Cities ms ss


Measured memory_bytes: 97916
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;


int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a * c,max(a * d,max(b * c,b * d))) << endl;
}




Measured memory_bytes: 3192
#include <iostream>
#include <string>

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;

  int A, B;
  cin >> A >> B;

  string U;
  cin >> U;

  if (U==S) {
    A--;
  } else {
    B--;
  }

  cout << A << " " << B << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int n,m,ans = 0;
    cin>>n>>m;
    vector<bool>l(n,true);
    vector<int>h(n),a(m),b(m);
    rep(i,n)cin>>h[i];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        if(h[a[i]] == h[b[i]]){
            l[b[i]] = false;
            l[a[i]] = false;
        }
        else if(h[a[i]] > h[b[i]]){
            if(l[b[i]]){
                l[b[i]] = false;
            }
        }
        else {
            if(l[a[i]]){
                l[a[i]] = false;
            }
        }
    }
    rep(i,n)if(l[i])ans++;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4504
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
//------------------------------------------------------------
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int maxCount =0;
		int ans = 1;
		sc.close();

		for (int i=1 ; i <= N ; i++) {
			int count = 0;
			int currentNumber = i;
			while (true) {
				if(currentNumber % 2 ==0) {
					count++;
					currentNumber /= 2;
				} else {
					break;
				}
			}
			if (count > maxCount) {
				maxCount = count;
				ans = i;
			}
		}
		System.out.println(ans);


//------------------------------------------------------------
	}
}


Measured memory_bytes: 21844
H,W = map(int,input().split())

s = []
l = [[0] * W for i in range(H)]
r = [[0] * W for i in range(H)]
u = [[0] * W for i in range(H)]
d= [[0] * W for i in range(H)]
  
for i in range(H):
    tmp =list(input())
    s.append(tmp)

for y in range(H):
  for x in range(W):
    if s[y][x] == "#":
      continue
    elif x == 0:
      l[y][x] = 1
    else:
      l[y][x] = l[y][x-1] + 1

for y in range(H):
  for x in range(W-1, -1, -1):
    if s[y][x] == "#":
      continue
    elif x == W - 1:
      r[y][x] = 1
    else:
      r[y][x] = r[y][x+1] + 1
      
for y in range(H):
  for x in range(W):
    if s[y][x] == "#":
      continue
    elif y == 0:
      u[y][x] = 1
    else:
      u[y][x] = u[y-1][x] + 1
      
for y in range(H-1, -1, -1):
  for x in range(W):
    if s[y][x] == "#":
      continue
    elif y == H - 1:
      d[y][x] = 1
    else:
      d[y][x] = d[y+1][x] + 1

ans = 0
for x in range(H):
  for y in range(W):
    if ans < l[x][y] + r[x][y] + u[x][y] + d[x][y] - 3:
      ans = l[x][y] + r[x][y] + u[x][y] + d[x][y] - 3
      
print(ans)

Measured memory_bytes: 359716
#include <cstdio>

using namespace std;
char a[20] , b[20] , c[20];
int main()
{
	while(~scanf("%s%s%s" , a , b , c)){
		printf("%c%c%c\n" , a[0] - 32 , b[0] - 32 , c[0] - 32);
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    cout << ( ((S[0] == S[1] && S[2] == S[3] && S[0] != S[3]) || (S[0] == S[2] && S[1] == S[3] && S[0] != S[3]) || (S[0] == S[3] && S[1] == S[2] && S[0] != S[2])) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    double avg = A.sum();
    auto I = iota(N).array();
    bool less(Tuple!(long, long) a, Tuple!(long, long) b)
    {
        return abs(a[0] * N - avg) < abs(b[0] * N - avg);
    }

    zip(A, I).sort!(less, SwapStrategy.stable)();
    writeln(I[0]);
}


Measured memory_bytes: 256
#include "stdio.h"
int main(int argc, char const *argv[])
{
	long n;
	while(~scanf("%ld",&n))
	{
		int i,j;
		for(i=1;i<=3500;i++)
		{
			int f=0;
			for(j=1;j<=3500;j++)
			{
				long w1,w2;
				w1=n*i*j;
				w2=4*i*j-n*(i+j);
				if(w1>0&&w2>0&&w1%w2==0)
				{
					f=1;
					printf("%d %d %ld\n",i,j,w1/w2);
					break;
				}
			}
			if(f)
				break;
        }
    }
    return 0;
}


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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int res = 0;
  for(int i = 0; i <= a; i++){
  	for(int j = 0; j <= b; j++){
    	for(int k = 0; k <= c; k++){
        	if(x == (500 * i + 100 * j + 50 * k)){
            	res++;
            }
        }
    }
  }
  cout << res << endl;
}


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

void bfs(vector<vector<int> > &g,int n,vector<int> &parent)
{
  vector<bool> vis(n+1,0);
  vis[1]=1;
  queue<int> q;
  q.push(1);
  while(!q.empty())
  {
    int x=q.front();
    q.pop();
    for(auto &i:g[x])
    {
      if(!vis[i])
      {
        parent[i]=x;
        vis[i]=1;
        q.push(i);
      }
    }
  }
}


int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  int n,m;
  cin>>n>>m;

  vector<vector<int> > g(n+1);

  for(int i=0;i<m;i++)
  {
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  vector<int> parent(n+1,0);

  bfs(g,n,parent);

  bool flag=1;


  for(int i=2;i<=n;i++)
  {
    if(parent[i]==i)
    {
      flag=0;
      break;
    }
  }

  if(flag){


    cout<<"Yes"<<endl;

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

}


else
{
  cout<<"No"<<endl;
}

  return 0;
}

Measured memory_bytes: 10160
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long

int main(){
        string str;
        cin >> str;
        int w;
        cin >> w;
        int l=str.size();
        string ans;
        int k;
        if(l%w==0) {
                k=l/w;
        }else{
                k=l/w+1;
        }
        for(int i=0; i<k; i++) {
                ans+=str[i*w];
        }
        cout << ans << endl;

        return 0;
}


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

int main() {
 int n,a,b; cin >> n;
 bool ans=0;
  for(double i=1;i<10;i++){
    for(double j=1;j<10;j++){
      if(n/j==i)ans=1;
    }
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

if(a<b)swap(a,b);

while(b > 0)
{
r = a % b;
a = b;
b = r;
}

cout << a <<endl;

return 0;
}


Measured memory_bytes: 3068
#include <cstdio>

int main()
{
    int N, K;

    scanf("%d%d", &N, &K);

    int C = 0;
    for (int i = 0; i < N; ++i)
    {
        int H;
        scanf("%d", &H);

        if (H >= K) {
            ++C;
        }
    }

    printf("%d\n", C);
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

vl path;
vector<vi> gr;
int padre[100];
int depth[100];
map<pi, int> mapa;
int pos = 0;

void dfs(int nodo, int p){
	padre[nodo] = p;
	for(int x : gr[nodo]){
		if(x == p)
			continue;
		mapa[{x, nodo}] = pos++;
		depth[x] = depth[nodo]+1;
		dfs(x, nodo);
	}
}

int main(){
	int n;
	si(n);
	gr.resize(n);
	for(int i = 1; i < n; i++){
		int a, b;
		sii(a, b);
		a--;
		b--;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	depth[0] = 0;
	dfs(0, -1);
	int m;
	si(m);
	for(int i = 0; i < m; i++){
		int a, b;
		sii(a, b);
		a--;
		b--;
		ll tmp = 0;
		while(depth[a] > min(depth[a], depth[b])){
			tmp |= (1LL<<mapa[{a, padre[a]}]);
			a = padre[a];
		}
		while(depth[b] > min(depth[a], depth[b])){
			tmp |= (1LL<<mapa[{b, padre[b]}]);
			b = padre[b];
		}
		while(a != b){
			tmp |= (1LL<<mapa[{b, padre[b]}]);
			b = padre[b];
			tmp |= (1LL<<mapa[{a, padre[a]}]);
			a = padre[a];
		}
		path.push_back(tmp);
		//cout << bitset<10>(tmp).to_string() << endl;
	}
	ll ans = 0;
	for(ll mask = 1; mask < (1LL<<m); mask++){
		ll ls = 0;
		int cnt = 0;
		for(int i = 0; i < m; i++)
			if(mask&(1<<i)){
				cnt++;
				ls |= path[i];
			}
		int cnt2 = 0;
		for(int i = 0; i < pos; i++)
			if(ls&(1LL<<i))
				cnt2++;
		
		if(cnt%2)
			ans += (1LL<<(n-1-cnt2));
		else
			ans -= (1LL<<(n-1-cnt2));
	}
	ans = ((1LL<<(n-1)) - ans);
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)

const int N = 1e5 + 5, M = 1e9 + 7;
int n;
long long dp[N][2];
bool solved[N][2];
vector<vector<int>> g;

long long dfs(int u, int p, bool b)
{
    if (solved[u][b])
    {
        return dp[u][b];
    }
    
    dp[u][b] = 1;
    for (auto v : g[u])
    {
        if (v != p)
        {
            if (!b)
            {
                dp[u][b] *= dfs(v, u, 0) + dfs(v, u, 1);
                dp[u][b] %= M;
            }
            else
            {
                dp[u][b] *= dfs(v, u, 0);
                dp[u][b] %= M;
            }
        }
    }
    
    solved[u][b] = 1;
    return dp[u][b];
}

int main()
{
    FaSt
    cin >> n;
    g.resize(n);
    
    for (int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        g[--x].push_back(--y);
        g[y].push_back(x);
    }
    
    cout << (dfs(0, -1, 0) + dfs(0, -1, 1)) % M;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(Math.abs(A-B)%2==0) {
			System.out.println((A+B)/2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 21716
mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])

Measured memory_bytes: 51160
import java.io.*;
import java.util.*;
 
public class Main{
	
	long H, W;
	public void solve(){
		H = nextLong();
		W = nextLong();
		
		long ans = Long.MAX_VALUE;
		for(int i = 1; i * 2 <= H; i++){
			long h = H - i;
			long h1 = h / 2;
			long h2 = h - h1;
			long w1 = W / 2;
			long w2 = W - w1;
			ans = Math.min(ans, max(i * W, h1 * W, h2 * W) - min(i * W, h1 * W, h2 * W));
			ans = Math.min(ans, max(i * W, h * w1, h * w2) - min(i * W, h * w1, h * w2));
			
		}
		

		for(int i = 1; i * 2 <= W; i++){
			long h = W - i;
			long h1 = h / 2;
			long h2 = h - h1;
			long w1 = H / 2;
			long w2 = H - w1;
			ans = Math.min(ans, max(i * H, h1 * H, h2 * H) - min(i * H, h1 * H, h2 * H));
			ans = Math.min(ans, max(i * H, h * w1, h * w2) - min(i * H, h * w1, h * w2));
			
		}
		out.println(ans);
	}
	
	private long max(long a, long b, long c){
		return Math.max(a,  Math.max(b, c));
	}
	
	private long min(long a, long b, long c){
		return Math.min(a, Math.min(b, c));
	}
	
	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: 24404
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{ 
   fast
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   int ans=0;
   ans+=min({a,k});
   k-=a;
   if(k>0)
   {
   	k-=min({b,k});
   }
   if(k>0)
   {
   	ans=ans+(k*(-1));
   }
   cout<<ans;
}

Measured memory_bytes: 3600
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

A,B,C = LI()


if B > C:
    print(B + C)
else:
    # 毒入りの方が多い
    result = B * 2
    C -= B
    if A >= C:
        result += C
        print(result)
    else:
        # 毒のほうが多い
        result += A + 1
        print(result)


Measured memory_bytes: 65132
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int N;  cin>>N;
   int t[4]={0};
   for(int i=0; i<N; i++){
      str s; cin>>s;
      if(s=="AC") t[0]++;
      else if(s=="WA") t[1]++;
      else if(s=="TLE") t[2]++;
      else t[3]++;
   }
	cout << "AC x " << t[0] << endl;
   cout << "WA x " << t[1] << endl;
   cout << "TLE x " << t[2] << endl;
   cout << "RE x " << t[3] << endl;

   return 0;
}

Measured memory_bytes: 3652