akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	int u[1001];
	cin>>n;

	rep(i,n){
		cin>>u[i];
	}
	sort(u,u+n);

	double t=(double(u[0]+u[1]))/2;
	for(int i=2; i<n; i++){
		t=(double(t+u[i]))/2;
	}
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (r, g, b, n) = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0

    for (i in 0..n) {
        for (j in 0..n) {
            val rest = n - (i * r) - (j * g)
            if (rest >= 0 && rest % b == 0) cnt++
        }
    }

    println(cnt)
}

Measured memory_bytes: 36072
n,k = list(map(int,input().split()))
d = list(map(int, input().split()))
d_m = []
d_p = [i for i in d if i >= 0 or d_m.append(i)]
ret = -1
for i in range(k+1):
  if len(d_p) >= i and len(d_m) >= k-i:
    dp_t = d_p[i-1] if i > 0 else 0
    dm_t = -1 * d_m[-(k-i)] if k-i != 0 else 0
    if dp_t == 0:
      ret_t = dm_t
    elif dm_t == 0:
      ret_t = dp_t
    else:
      ret_t = dp_t + dm_t + min(dp_t, dm_t)
#    print(i, k-i, dp_t, dm_t, ret_t)
    if ret > ret_t or ret < 0:
      ret = ret_t
print(ret)

Measured memory_bytes: 14532
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
}

int solve(){
    int cntodd = 0;
    for(auto a:A) if(a%2) cntodd++;
    if(cntodd%2) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}   

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

Measured memory_bytes: 3872
#include<stdio.h>

int main()
{
 int S,h,m,s;
 scanf("%d",&S);
 h = S / 3600;
 m = ( S % 3600 ) / 60;
 s = ( S % 3600 ) % 60;
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 18;
const int N = (int)3e5 + 7;
const int MAXN = (int)2e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

LL sum(int x) {
	return 1LL * x * (x + 1) / 2;
}

LL sum(int l, int r) {
	return sum(r) - sum(l - 1);
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = k; i <= n + 1; i++) {
		LL mn = sum(0, i - 1), mx = sum(n - i + 1, n);
		int add = (mx - mn + 1) % MOD;
		ans = (ans + add) % MOD;
	}
	cout << ans;

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

using namespace std;
using i64 = long long;
const i64 INF = i64(1e18) + 7;

bool chmax(i64& x, i64 y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
bool chmin(i64& x, i64 y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

bool solve(){
    int n, m;
    cin >> n >> m;
    if(!n)
        return false;
    vector<i64> a(n), b(n), v(n);
    for(auto& x : a)
        cin >> x;
    for(auto& x : b)
        cin >> x;
    for(int i = 0; i < n; ++i){
        v[i] = (b[i] - a[i] + m) % m;
        assert(0 <= v[i] && v[i] < m);
    }
    vector<vector<i64>> dp(n, vector<i64>(n + 2, INF));
    for(int i = 0; i < n; ++i)
        dp[0][i] = v[0] + m * i;
    for(int i = 0; i < n - 1; ++i){
        for(int j = 0; j <= n; ++j){

            chmin(dp[i + 1][j], dp[i][j] + max(0LL, v[i + 1] - v[i]));
            chmin(dp[i + 1][j], dp[i][j + 1]);
            chmin(dp[i + 1][j + 1], dp[i][j] + max(0LL, v[i + 1] + m - v[i]));
            /*
            chmin(dp[i + 1][0], dp[i][0] + max(0LL, v[i + 1] - v[i]));
            chmin(dp[i + 1][0], dp[i][1] + max(0LL, v[i + 1] + - (v[i] + m)));
            chmin(dp[i + 1][1], dp[i][0] + max(0LL, v[i + 1] + m - v[i]));
            chmin(dp[i + 1][1], dp[i][1] + max(0LL, v[i + 1] + m - (v[i] + m)));
            */
        }
    }
    i64 ans = INF;
    for(auto& x : dp.back())
        chmin(ans, x);
    cout << ans << endl;
    return true;
}

signed main()
{
    while(solve());
    return 0;
}



Measured memory_bytes: 10776
n=int(input())
H = list(map(int,input().split(' ')))
i = 0
hmax = 0
hmax_temp = 0
while i < n-1:
    if H[i]>= H[i+1]:
        hmax_temp += 1
        i += 1
    else:
        if hmax_temp > hmax:
            hmax = hmax_temp
        hmax_temp = 0
        i += 1
print(max(hmax,hmax_temp))

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

int main(){

	int N,M,Q;
	cin>>N>>M>>Q;

	list<int> L;

	for(int i=0;i<N;i++)
		L.push_back(i);

	list<int>::iterator btn =L.begin();


	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		if(a%2==0){
			for(int j=0;j<a;j++){
				btn++;
				if(btn==L.end())		//最後尾にはダミーのendがあるから動かしてから
					btn=L.begin();
			}
		}
		else{
			for(int j=0;j<a;j++){
				if(btn==L.begin())		//先頭beginの前にはダミーがないのでチェックしてから
					btn=L.end();
				btn--;
			}
		}
		list<int>::iterator it=btn;
		btn++;
		if(btn==L.end())
			btn=L.begin();
		L.erase(it);
	}

	for(int i=0;i<Q;i++){
		int q;
		cin>>q;
	
		list<int>::iterator it;
	
		for(it=L.begin(); it!=L.end();it++){
			if(*it==q)
				break;
		}
		if(it==L.end())
			cout<<0<<endl;
		else
			cout<<1<<endl;
	}
	
	return 0;
}

		

Measured memory_bytes: 7440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();	
		
		int total = 0;

		for(int i = a; i > 0 && k > 0 ; i--) {
			total++;
			k--;
		}
		

		for(int i = b; i > 0 && k > 0 ; i--) {
			k--;
		}
		
		for(int i = c; i > 0 && k > 0 ; i--) {
			total--;
			k--;
		}
		
		System.out.println(total);
	}
}


Measured memory_bytes: 35812
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   string s;
    cin>>s;
    int ans=0;
    for(auto c:s)if(c=='R')ans=1;

    fo1(i,2)if(s[i]=='R' && s[i-1]=='R')ans++;
    
    
    
    cout<<ans<<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3660
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>


std::vector<int> len;

int main()
{
	int  N, M;
	std::string S;
	cin >> N >> M;

	std::vector<int> tt;
	std::vector<bool> ac;
	tt.resize(N);
	ac.resize(N);
	int w = 0;
	for (int i = 0; i < M; ++i) {
		int tmp;
		std::string str;
		cin >> tmp >> str;
		tmp -= 1;

		if (str[0] == 'A') {
			ac[tmp] = true;
		}

		if (ac[tmp] == false) {
			if (str[0] == 'W') {
				tt[tmp]++;
			}
		}
	}

	int e1 = 0;
	int e2 = 0;
	for (int i = 0; i < N; ++i) {
		if (ac[i]) {
			e1++;
			e2 += tt[i];
		}
	}

	printf("%d %d\n", e1, e2);


	return 0;
}



Measured memory_bytes: 640
import java.util.*;
import java.util.regex.*;
public class Main {

		public static int [] t ={0,1,2,3,5,7,8,9};
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            
            while(true ){
            	int n = scan.nextInt();
            	if(n==0)break;
            	f(n);
            	System.out.println();
        }
            
        }
        static void f(int n){
        	if(n>7)f(n/8);
        	System.out.print(t[n%8]);
        }
}

Measured memory_bytes: 12000
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	vector<int> geko;
	REP(i, 3) {
		int a;
		cin >> a;
		geko.push_back(a);
	}
	sort(geko.begin(), geko.end());
	cout << geko[0] + geko[1] << endl;
}

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

int main(int argc, char *argv[]){
    int N;
    std::string S;
    std::cin >> N >> S;
    int left, right;
    int len;
    int tmpLen;
    int maxLen = 0;
    for(len=1; len<N; ++len){
        left=0;
        right = left + len;
        tmpLen = 0;
        while(right < N){
            if(S[left] == S[right]){
                ++tmpLen;
                if(maxLen < tmpLen && tmpLen <= len){
                    maxLen = tmpLen;
                }
            }else{
                tmpLen = 0;
            }
            ++left;
            ++right;
        }
    }
    std::cout << maxLen << std::endl;
    return 0;
}


Measured memory_bytes: 384
def main():
    L, R = (int(i) for i in input().split())
    ans = 2*10**9
    for le in range(L, min(R, L+2020)+1):
        for ri in range(le+1, min(R, L+2020)+1):
            cur = le*ri
            cur %= 2019
            ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<int > x(N), y(N), xx(N), yy(N);
  for (int i=0; i<N; i++){
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    xx[i]=x[i];
    yy[i]=y[i];
  }
  std::sort(xx.begin(), xx.end());
  std::sort(yy.begin(), yy.end());
  xx.erase(unique(xx.begin(), xx.end()), xx.end());
  yy.erase(unique(yy.begin(), yy.end()), yy.end());
  long long ans = 4e18+10;
  for (int i=0; i<xx.size(); i++){
    for (int j=0; j<yy.size(); j++){
      for (int k=i; k<xx.size(); k++){
	for (int l=j; l<yy.size(); l++){
	  int cnt = 0;
	  for (int n=0; n<N; n++){
	    if (x[n]>=xx[i] && x[n]<=xx[k] && y[n]>=yy[j] && y[n]<=yy[l]) cnt++;
	  }
	  if (cnt>=K) ans = std::min(ans, ((long long)xx[k]-xx[i])*((long long)yy[l]-yy[j]));
	}
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
 

Measured memory_bytes: 3240
from collections import defaultdict

n,k=map(int,input().split())
arr=list(map(int,input().split()))

dd=defaultdict(int)
for a in arr:
    dd[a]+=1

brr=sorted(dd.values())
ans=0
for k in range(len(brr)-k):
    ans+=brr[k]
print(ans)


Measured memory_bytes: 32532
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    ll n;
    cin >> n;
    V<ll> A(n + 1);
    rep(i, n + 1) cin >> A[i];
    V<ll> B(n);
    rep(i, n) cin >> B[i];

    ll ans = 0;

    rep(i, n) {
        if (B[i] < A[i]) {
            ans += B[i];
            A[i] -= B[i];
            B[i] = 0;
        } else {
            ans += A[i];
            B[i] -= A[i];
            A[i] = 0;
            if (B[i] > 0) {
                if (B[i] < A[i + 1]) {
                    ans += B[i];
                    A[i + 1] -= B[i];
                    B[i] = 0;
                } else {
                    ans += A[i + 1];
                    B[i] -= A[i + 1];
                    A[i + 1] = 0;
                }
            }
        }
    }

    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 4724
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 200005
using std::min;
using std::max;
using std::swap;
#define int long long

int n,m;
int cnts[N];

inline int getint(){
    int X=0;int w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

signed main(){
    n=getint(),m=getint();
    for(int i=1;i<=n;i++)
        cnts[i%m]++;
    int ans=0;
    for(int i=0;i<m;i++){
        if((i+i)%m==0)
            ans+=cnts[i]*cnts[i]*cnts[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[80001][11];
string s;
main(){
    while(cin>>s,s!="0"){
        int sum=0;
        memset(dp,0,sizeof(dp));
        r(i,s.size()){
            int p=s[i]-'0';
            if(i%2)p-=p*2;
            if(p==0)r(j,11)dp[i+1][j]=dp[i][j];
            else{
                r(j,11)dp[i+1][(j+p+11)%11]=dp[i][j];
                dp[i+1][(p+11)%11]++;
            }
            sum+=dp[i+1][0];
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 6568
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M,K;
ll d[100010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>d[i];
    }
    sort(d,d+N);
    for(ll i=0;i<N;i++){
        if(i%2==1 && d[i]!=0){
            d[i]=24-d[i];
        }
    }
    sort(d,d+N);
    ll ans=d[0];
    for(ll i=1;i<N;i++){
        ans=min(ans,d[i]-d[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}

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

const int N = 100000 + 10;

int n;
std::vector<int> adj[N];

int dfs(int a, int fa = -1) {
  int res = 0;
  for (auto b : adj[a]) if (b != fa) res ^= dfs(b, a) + 1;
  return res;
}

int main() {
  scanf("%d", &n);
  for (int i = n - 1; i--;) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  puts(dfs(1) ? "Alice" : "Bob");
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int mx=max(a,b);
  int temp=mx;
  mx=max(mx,c);
  temp=mx;
  for(int i=0;i<k;i++) mx*=2;
  if(temp==a) cout<<mx+b+c<<endl;
  else if(temp==b) cout<<a+mx+c<<endl;
  else cout<<a+b+mx<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int T, A;
	cin >> T >> A;
	int H[1001];
	rep1(i, N) cin >> H[i];

	T *= 1000;
	A *= 1000;

	int tikai = 0;
	int sa = 1e9;

	rep1(i, N) {
		int kari = abs(T - 6 * H[i] - A);
		if (kari < sa) {
			sa = kari;
			tikai = i;
		}
	}
	co(tikai);

	Would you please return 0;
}

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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};


struct ms_t
{
	ll money;
	ll stock;
	ms_t() : money(1000), stock(0) {}
};


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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vi a(n);
		for(auto&m:a) cin >> m;

		ms_t m, s;

		ll ans=0;
		for(int i=0;i<n;i++)
		{
			ms_t pm=m, ps=s;

			ll nmm=pm.money+pm.stock*a[i];
			ll nms=ps.money+ps.stock*a[i];
			if(nmm>nms)
			{
				m.money=nmm;
				m.stock=0;
			}
			else
			{
				m.money=nms;
				m.stock=0;
			}

			ll nsm=pm.money/a[i]+pm.stock;
			ll nss=ps.money/a[i]+ps.stock;
			bool is_money=true;
			if(nsm==nss)
			{
				if((pm.money%a[i])<(ps.money%a[i])) is_money=false;
			}
			if(nsm<nss) is_money=false;
			if(is_money)
			{
				s.stock=nsm;
				s.money=pm.money%a[i];
			}
			else
			{
				s.stock=nss;
				s.money=ps.money%a[i];
			}
			if(max_u(ans, m.money))
			{
//				cout << i << "  " << ans << "\n";
			}
//			cout << i << "  " << m.money << "  " << m.stock << "  " << s.money << "  " << s.stock << "\n";
		}

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


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

int main() {
    int N;
    int B[100];
    cin >> N;
    for (int i = 0; i < N - 1; ++i){
        cin >> B[i];
    }
    int ans = 0;
    ans += B[0] + B[N-2];
    for (int i = 0; i < N - 2; ++ i){
        ans += min(B[i],B[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    char x, y;
    cin >> x >> y;
    if (x > y) {
        cout << '>' << endl;
    }else if(x < y){
        cout << '<' << endl;
    }else{
        cout << '=' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n,d;
	cin>>n>>d;
	int ans=0;
	for(int i=1;i<=n;i++){
		double a,b;
		cin>>a>>b;
		if(sqrt(a*a+b*b)<=d)ans++;
	}
	cout<<ans<<endl;
	
	
	
	
		
	return 0;
}

Measured memory_bytes: 3828
from collections import defaultdict
from math import factorial
# alpha = 'abcdefghijklmnopqrstuvwxyz'

def com(n,r):
    return factorial(n) // (factorial(n-r)*factorial(r))

N = int(input())
ans = 0
anss = defaultdict(int)
for i in range(N):
    t = input()
    ts = ''.join(c for c in sorted(t))
    anss[ts] += 1
# print(anss)
for k in anss.keys():
    if anss[k] > 1:
        ans += com(anss[k],2)
print(ans)

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

string comp(string s1,string s2){
	if(s1.size()>s2.size())
		return s1;
	else if(s1.size()<s2.size())
		return s2;

	return max(s1,s2);
}

int main()
{
	int W,H;
	while(cin>>W>>H && W!=0){
		vector<string> M;
		for(int i=0;i<H;i++){
			string s;
			cin>>s;
			M.push_back(s);
		}
		vector<vector<string> > dp(H,vector<string>(W,""));

		string ans="";

		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				if(!isdigit(M[y][x])) continue;
				dp[y][x]=M[y][x];

				string s1="",s2="";
				if(x>=1){
					s1=dp[y][x-1]+M[y][x];
				}
				if(y>=1){
					s2=dp[y-1][x]+M[y][x];
				}

				dp[y][x]=comp(dp[y][x],comp(s1,s2));
				if(dp[y][x]=="0") dp[y][x]="";

				ans=comp(dp[y][x],ans);
			}
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  int N,i,x,m;
  string S;
  x=0;
  m=x;
  cin>>N>>S;
  for(i=0; i<N; i++){
    if(S[i]=='I'){
      x+=1;
    }
    else if(S[i]=='D'){
      x-=1;
    }
    if(x>=m){
      m=x;
    }
  }
  cout<<m;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

struct Timer {
  Timer() { reset(); }
  void reset() { beg = chrono::high_resolution_clock::now(); }
  ll elapsed() const {
    chrono::high_resolution_clock::time_point en = chrono::high_resolution_clock::now();
    return chrono::duration_cast<chrono::milliseconds>(en - beg).count();
  }
private:
  chrono::high_resolution_clock::time_point beg;
} timer;

struct Xor128 {
  int rand() {
    unsigned t = x ^ (x << 11);
    x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return static_cast<int>(w);
  }
  int rand(int ub) {
    int res = rand() % ub;
    return res < 0 ? res + ub : res;
  }
  int rand(int lb, int ub) { return lb + rand(ub - lb); }
  ll randll() {
    unsigned long long res = static_cast<unsigned long long>(rand()) << 32;
    return static_cast<ll>(res | rand());
  }
  ll randll(ll ub) {
    ll res = randll() % ub;
    return res < 0 ? res + ub : res;
  }
  ll randll(ll lb, ll ub) { return lb + randll(ub - lb); }
private:
  unsigned x = 123456789, y = 362436069, z = 521288629, w = static_cast<unsigned>(time(nullptr));
} xor128;

const int D = 365, N = 26;
int c[N], s[D][N];

int calc_score(const vector<int> &t) {
  vector<int> last(N, -1);
  int score = 0;
  REP(d, D) {
    score += s[d][t[d]];
    last[t[d]] = d;
    REP(i, N) score -= c[i] * (d - last[i]);
  }
  return max(score + 1000000, 0);
}

vector<int> greedy() {
  vector<int> t(D), last(N, -1);
  REP(d, D) {
    int minus = 0;
    REP(i, N) minus += c[i] * (d - last[i]);
    int mx = -INF, idx;
    REP(i, N) {
      int tmp = s[d][i] + c[i] * (d - last[i]);
      if (tmp > mx) {
        mx = tmp;
        idx = i;
      }
    }
    t[d] = idx;
    last[idx] = d;
  }
  return t;
}

int main() {
  {int d; cin >> d;}
  REP(i, N) cin >> c[i];
  REP(i, D) REP(j, N) cin >> s[i][j];
  vector<int> t = greedy();
  // cerr << calc_score(t) << '\n';
  REP(i, D) cout << t[i] + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{

    char s[10];
    cin>>s;
    if(s[2]==s[3] && s[5]==s[4]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int N, W;
  cin >> N >> W;
  vvi dp(N + 1, vi(W + 1));
  vi v(N), w(N);
  rep(i, N) cin >> v[i] >> w[i];
  rep(i, N) rep(j, W + 1) {
    dp[i + 1][j] = dp[i][j];
    if (j >= w[i]) cmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 10696
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> a(n),b(n),c(n-1);
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	for(auto &i:c) cin>>i;
	int ans=0;
	For(i,0,n-1){
		ans+=b[a[i]-1];
		if(i>=1 && a[i]==a[i-1]+1) ans+=c[a[i]-2];
	}
	cout<<ans<<'\n';
	return 0;
}





























Measured memory_bytes: 256
def main():
    A,B,M = map(int,input().split())
    Al = list(map(int,input().split()))
    Bl = list(map(int,input().split()))
    xyc = [list(map(int,input().split())) for i in range(M)]
    minAB = min(Al) + min(Bl)
    now_min = minAB
    for m in xyc:
        s = Al[m[0]-1] + Bl[m[1]-1] - m[2]
        if s < now_min:
            now_min = s

    print(now_min)


if __name__ == "__main__":
    main()

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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] < a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) sum += a[i];
		else sum -= a[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
encode = {
' ':'101', 
"'":'000000', 
',':'000011', 
'-':'10010001', 
'.':'010001', 
'?':'000001', 
'A':'100101', 
'B':'10011010', 
'C':'0101', 
'D':'0001', 
'E':'110', 
'F':'01001', 
'G':'10011011', 
'H':'010000', 
'I':'0111', 
'J':'10011000', 
'K':'0110', 
'L':'00100', 
'M':'10011001', 
'N':'10011110', 
'O':'00101', 
'P':'111', 
'Q':'10011111', 
'R':'1000', 
'S':'00110', 
'T':'00111', 
'U':'10011100', 
'V':'10011101', 
'W':'000010', 
'X':'10010010', 
'Y':'10010011', 
'Z':'10010000'}

decode = {
"00000":"A",
"00001":"B",
"00010":"C",
"00011":"D",
"00100":"E",
"00101":"F",
"00110":"G",
"00111":"H",
"01000":"I",
"01001":"J",
"01010":"K",
"01011":"L",
"01100":"M",
"01101":"N",
"01110":"O",
"01111":"P",
"10000":"Q",
"10001":"R",
"10010":"S",
"10011":"T",
"10100":"U",
"10101":"V",
"10110":"W",
"10111":"X",
"11000":"Y",
"11001":"Z",
"11010":" ",
"11011":".",
"11100":",",
"11101":"-",
"11110":"'",
"11111":"?"}

while True:
	try:
		string = raw_input()
	except EOFError:
		break		

	e, ans = "", ""
	for s in string:
		e += encode[s]
	tmp = []
	while len(e) > 4:
		tmp.append(e[0:5])
		e = e[5:]
	if len(e) != 0:
		e += '0' * (5 - len(e))
		tmp.append(e)

	for s in tmp:
		ans += decode[s]
	print ans

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }
ll n,k;
vector<ll> a,f;
ll ans=LINF;

void solve(ll l,ll r){
    if(l>r) return;
    ll m=(l+r)/2;
    ll train=0;
    rep(i,n){
        ll tim=a[i]*f[i];
        if(tim<=m) continue;
        ll x=tim-m;
        train+=(x+f[i]-1)/f[i];
    }
    if(train<=k){
        ans=min(ans,m);
        solve(l,m-1);
    }
    else{
        solve(m+1,r);
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    cin>>n>>k;
    a.resize(n);f.resize(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>f[i];
    sort(ALL(a));
    sort(ALL(f),greater<ll>());
    solve(0,LINF);
    cout<<ans<<endl;
    return 0;
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  vector<int> creatures(n);
  for(int i = 0; i < n; ++i) {
    cin >> creatures[i];
  }
  SORT(creatures);
  int c_sum[n];
  for(int i = 0; i < n; ++i) {
    if(i == 0) c_sum[i] = creatures[i];
    else c_sum[i] = c_sum[i-1] + creatures[i];
  }
  int ans = 1;
  for(int i = n-2; i >= 0; --i) {
    if(c_sum[i]*2 < creatures[i+1]) break;
    ++ans;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

#define ll long long
#define rep(i,n) for (int i=0;i<n;++i)
typedef pair<int,int> P;

int main() {
    char x, res;
    cin >> x;
    if(isupper(x)){
        res='A';
    }else{
        res='a';
    }
    cout << res << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		int cnt = 1;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (a[i] % 2 == 0) {
				cnt *= 2;
			}
		}
		int ans = (int) (Math.pow(3, n) - cnt);
		System.out.println(ans);
	}
}

Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define mp make_pair

bool comp(int a, int b)
{
	return (a<b);
}

int main()
{
	int n; cin >> n;
	int dpa[n];
	int dpb[n];
	int dpc[n];
	int ans[n];

	int a,b,c; cin >> a >> b >> c;
	dpa[0] = a; dpb[0] = b; dpc[0] = c;
	ans[0] = max({dpa[0],dpb[0],dpc[0]},comp);

	forn(i,1,n)
	{
		cin >> a >> b >> c;
		int ma = max(dpb[i-1],dpc[i-1]);
		int mb = max(dpa[i-1],dpc[i-1]);
		int mc = max(dpa[i-1],dpb[i-1]);

		dpa[i] = a + ma;
		dpb[i] = b + mb;
		dpc[i] = c + mc;

		ans[i] = max({dpa[i],dpb[i],dpc[i]},comp);
	}

	cout << ans[n-1] << endl;

}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INF = 1LL<<60;

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

int N,W;
cin >> N >> W;
vl w(N),v(N);
rep(i,N) cin >> w[i] >> v[i];

// dp[i][sum]:= w[i-1]までの品物を使用して価値がsumとなるときの最小の重み
vvl dp(N+1,vl(100100,INF));

//初期条件
dp[0][0] = 0;

rep(i,N) {
    for(int sum = 0; sum < 100100; ++sum) {
        chmin(dp[i+1][sum], dp[i][sum]);
        if(sum >= v[i]) chmin(dp[i+1][sum], dp[i][sum-v[i]] + w[i]);
    }
}

// 最適値の出力
ll ans = 0;
for (int sum = 0; sum < 100100; ++sum) if (dp[N][sum] <= W) ans = sum;
cout << ans << endl;

return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t = ((n+1)*100+107)/108;
  int s = (n*100)/108;
  bool flag=0;
  for(int i=s;i<=t;i++){
    if(((i*108)/100)==n){
      flag=1;
      cout << i << endl;
      break;
    }
  }
  if(!flag) cout << ":(" << endl;
}


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

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int MOD = 998244353;
const int N = 3*(int)1e5 + 10;

int n, a, b, k, sil[N];
int res;

int fpow(int x, int y) {
  if (y == 0)
    return 1;
  if (y&1)
    return (x*fpow(x, y-1))%MOD;
  int res = fpow(x, y/2);
  return (res*res)%MOD;
}

int ne(int x, int y) {
  if (y > x || y < 0)
    return 0;
  int res = sil[x];
  res = (res*fpow(sil[y], MOD-2))%MOD;
  res = (res*fpow(sil[x-y], MOD-2))%MOD;
  return res;
}

signed main() {
  init_ios();
  sil[0] = 1;
  for (int i = 1; i < N-5; ++i)
    sil[i] = (i*sil[i-1])%MOD;
  cin >> n >> a >> b >> k;
  for (int i = 0; i <= n; ++i) {
    int zost = k-i*a;
    if (zost < 0)
      break;
    if (zost%b != 0)
      continue;
    int ile = zost/b;
    res = (res+ne(n, i)*ne(n, ile))%MOD;
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 2560
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


bool solve(string s){
  if(s.size()>=4 && s.substr(0,4)=="YAKI") return true;
  return false;
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  string s;cin>>s;
  puts(solve(s)?"Yes":"No");

  return 0;
}






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

void read(int &x)
{
	char c=getchar(); x=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
}

const int PLUS=0;
const int MINUS=1;
const int maxn=1e5+10;

int n,a[maxn];
LL pre[maxn],suf[maxn],Ans;
bool op[maxn];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	read(n);
	read(a[1]);
	op[1]=PLUS;
	for (i=2;i<=n;i++)
	{
		char c=getchar();
		while (c!='+'&&c!='-') c=getchar();
		if (c=='+') op[i]=PLUS;
		else op[i]=MINUS;
		read(a[i]);
	}
	for (i=1;i<=n;i++)
		pre[i]=pre[i-1]+(op[i]==PLUS?a[i]:-a[i]);
	for (i=n;i>=1;i--)
		suf[i]=suf[i+1]+a[i];
	Ans=pre[n];
	int last=0;
	for (i=n;i>=1;i--)
		if (op[i]==MINUS)
		{
			if (last)
				Ans=max(Ans,suf[last]+pre[i-1]-(suf[i]-suf[last]));
			last=i;
		}
	printf("%lld\n",Ans);
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll B[n];
    ll cnt=0;
    rep(i,0,n-1)	cin>>B[i];
    rep(i,1,n-1){
    	cnt += min(B[i], B[i-1]);
    }
    cnt += B[0] + B[n-2];
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
vector<pair<lli, lli>> b;
int main() {
  cin >> n >> m;
  for (lli i=0; i<m; ++i) {
    lli x, y; cin >> x >> y;
    b.emplace_back(x, y);
  }
  sort(begin(b), end(b), [](auto&& x, auto&& y){
    return x.first < y.first; 
  });
  lli r = 0, ans = 0;
  for (auto&& p : b) {
    r = min(r, p.second);
    if (r <= p.first) {
      r = p.second;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2420