akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X, Y, Z; cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
    return 0;
}


Measured memory_bytes: 256
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const int MOD = 1000000007;
//{{{ modular algebra
template<int mod=MOD>
struct Num{
	int v;
	template<class T>
	Num(T n){
		v = n%mod;
		if(v<0)v+=mod;
	}
	Num():v(0){}
	operator int() const {return v;}
	operator long long() const {return v;}
	inline void operator *=(const Num<mod> &a) {
		v = (v*(long long)a.v)%mod;
	}
	inline Num operator *(const Num<mod> &a) {
		Num n(*this);n*=a;
		return n;
	}
	inline void operator+=(const Num<mod> &a){
		v+=a.v;
		if(v>=mod)v-=mod;
		//	assert(0<=v and v<mod);
	}
	inline Num operator+(const Num<mod> &a){
		Num n(*this);n+=a;
		return n;
	}
	inline Num operator -(){
		if(v==0)return 0;
		else return Num(mod-v);
	}
	inline void operator -=(const Num<mod> &a){
		v-=a.v;
		if(v<0)v+=mod;
	}
	inline Num operator -(const Num<mod> &a){
		Num n(*this);n-=a;
		return n;
	}
#ifdef __GCD_H
	inline Num inv(){
		return Num(invMod(this->v,mod));
	}
	inline void operator /=(const Num<mod> &a){
		(*this)*=invMod(a.v,mod);
	}
	inline Num operator /(const Num<mod> &a){
		Num n(*this);n/=a;
		return n;
	}
#endif
};

template<class T, int mod>
T& operator <<(T &os, const Num<mod> &n){
	os<<(int)n.v;
	return os;
}

template<class T, int mod>
T& operator >>(T &is, Num<mod> &n){
	is>>n.v;
	return is;
}
//}}}
using Mint =  Num<MOD>;

int N;
int M;
vector<int> S;
vector<int> T;

Mint prev_sum[100010];
Mint dp[2020][2020];

void solve(){
	memset(prev_sum,0,sizeof(prev_sum));
	for(int i = 0;i <= N;i++)dp[i][0] = 1;
	for(int j = 0;j <= M;j++)dp[0][j] = 1;
	for(int i = 1;i <= N;i++){
		for(int j = 1;j <= M;j++){
			prev_sum[T[j-1]] += dp[i-1][j-1];
			dp[i][j] = prev_sum[S[i-1]] + dp[i-1][j];
		}
		REP(j,M)prev_sum[T[j]] = 0;
	}
	cout<<dp[N][M]<<endl;
}

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    cin >> M;
    S.assign(N,Int());
    for(int i = 0 ; i < N ; i++){
        cin >> S[i];
    }
    T.assign(M,Int());
    for(int i = 0 ; i < M ; i++){
        cin >> T[i];
    }
	solve();
	return 0;
}

//}}}



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

int main(void) {
	
	char a, b;

	scanf("%c %c", &a, &b);
	
	if (a == 'H'&&b == 'H') printf("%c", 'H');
	else if (a == 'H'&&b == 'D') printf("%c", 'D');
	else if (a == 'D'&&b == 'H') printf("%c", 'D');
	else printf("%c", 'H');

	return 0;
}

Measured memory_bytes: 128
k, n = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(lambda x: x + k, a))
a.extend(b)
min = float('inf')
for i in range(n):
    if a[i + n - 1] -  a[i] < min:
        min = a[i + n - 1] - a[i]
print(min)


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

int main(){
  int n, l[10], max=0, sum=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> l[i];
    if(l[i] > max) max = l[i];
    sum += l[i];
  }
  sum -= max;
  if(max < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace A_RightTriangle
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var AB = int.Parse(inputs[0]);
            var BC = int.Parse(inputs[1]);
            var CA = int.Parse(inputs[2]);

            var S = AB * BC / 2;

            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
	int n,k;
	cin>>n>>k;
	vector<string>v;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		v.pb(s);
	}
	sort(v.begin(),v.end());
	string s="";
	for(int i=0;i<n;i++)
	{
		s+=v[i];
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
main = do
    s_ <- getLine
    let parse [] = "YES"
	parse str = case splitAt 5 str of
	    ("dream",rem)	-> case rem of
				    'e':'r':'a':_   -> parse rem
				    'e':'r':rem'    -> parse rem'
				    otherwise	    -> parse rem
	    ("erase",rem)	-> case rem of
				    'r':rem'	-> parse rem'
				    otherwise	-> parse rem
	    otherwise	-> "NO"
    putStr$parse s_

Measured memory_bytes: 4988
n,q=map(int,input().split())
s=input()
list=[0]*(n+1)
cnt=0
for i in range(1,n):
    if s[i]=="C" and s[i-1]=="A":
        cnt+=1
        list[i+1]+=cnt
    else:
        list[i+1]+=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(list[r]-list[l])


Measured memory_bytes: 8308
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::multiprecision::cpp_int;

int main() {
	int n, count; cpp_int cppi;
	while (1) {
		cin >> n; if (n == 0) break;
		count = 0; cppi = 1;
		for (int i = 2; i <= n; i += 2) cppi *= i;
		for (int i = 5; i <= n; i += 10) cppi *= i;
		while (cppi % 10 == 0) { cppi /= 10; count++; }
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>
int main(void){
  char s[20000001];
  int q=0;
 
scanf("%s",&s);
  
  for(int i=0;i<strlen(s);i++){
    q+=s[i]-'0';
    //printf("%d|n",q);
    q=q%9;
  }
  if(q==0)printf("Yes");
  else printf("No");
  
  return 0;
}

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

typedef long long ll;
int N;

int main(){
    cin >> N;
    ll A[N], B[N];
    ll sumA, sumB;
    sumA = 0;
    sumB = 0;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        sumA += A[i];
    }
    for(ll i = 0; i < N; i++){
        cin >> B[i];
        sumB += B[i];
    }

    if(sumA < sumB){
        cout << -1 << endl;
        return 0;
    }

    ll C[N];
    bool isChanged[N];
    ll lenm, lenp;
    for(ll i = 0; i < N; i++){
        C[i] = A[i] - B[i];
        isChanged[i] = false;
    }
    sort(C, C + N);

    ll give_ind = N - 1;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(C[i] >= 0){
            break;
        }
        while(give_ind > 0){
            if(C[give_ind] + C[i] > 0){
                C[give_ind] = C[give_ind] + C[i];
                if(isChanged[give_ind]==false){
                    ans += 1;
                    isChanged[give_ind] = true;
                }
                break;
            }else{
                C[i] = C[give_ind] + C[i];
                if(isChanged[give_ind]==false){
                    ans += 1;
                    isChanged[give_ind] = true;
                }
                give_ind -= 1;
            }
        }
        if(isChanged[i] == false){
            ans += 1;
            isChanged[i] = true;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N;
    cin >> N;
    REP(X, N + 1){
        if((ll)(X * 1.08) == N){
            PRINT(X);
            return 0;
        }
    }
    PRINT(":(");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long a[N], b[N];
  for(int i=0; i<N; i++) {
    cin >> a[i];
    if(a[i]==0) {
      cout << 0 << endl;
      return 0;
    }
    if(a[i]>1e18) {
      cout << -1 << endl;
      return 0;
    }
    if(a[i]!=1) b[i]=a[i]-1;
    else b[i]=a[i];
  }
  long long ans=a[0], ans2=a[0]+1;
  for(int i=1; i<N; i++) {
    ans2*=b[i];
    if(ans2<0||ans2>1000000000000000000||ans2%b[i]!=0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for(int i=1; i<N; i++) {
    ans*=a[i];
    if(ans<0||ans>1000000000000000000||ans%a[i]!=0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5132
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n;
	cin >> n;

	int tmp = n; 
	int s = 0;
	while(tmp > 0){
		s += tmp % 10;
		tmp /= 10;
	}

	if(n % s == 0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, ans = 0; cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  int cnt = 0;
  for(int i = 0; i < n-1; i++){
    if(v[i] >= v[i+1])cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  system("pause");
}


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

int main () {

  string s;
  cin >> s;

  if (s=="RRR") {
    cout << 3 << endl;
  } else if (s=="RRS") {
    cout << 2 << endl;
  } else if (s=="SRR") {
    cout << 2 << endl;
  } else if (s=="SRS") {
    cout << 1 << endl;
  } else if (s=="RSR") {
    cout << 1 << endl;
  } else if (s=="RSS") {
    cout << 1 << endl;
  } else if (s=="SSR") {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3556
def ranlength(A):
    num = list(A)
    count = 1
    result = ''
    table = []
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
               count = count + 1
            else:
                result += str(num[i]) + str(count)
                table.append(count)
                count = 1
        except:
            result += str(num[i]) + str(count)
            table.append(count)
    return(table)
    
N,K=map(int,input().split())
S=input()

RL=ranlength(S)
if S[0]=='0':
    RL=[0]+RL
if S[-1]=='0':
    RL.append(0)

#しゃくとり法
cnt=RL[0]
ans=RL[0]
for i in range(len(RL)):
    if i%2==0 and i>=2:
        cnt+=RL[i]
        cnt+=RL[i-1]
        if i>=K*2+2:
            cnt-=RL[i-(K*2+1)]
            cnt-=RL[i-(K*2+2)]
        ans=max(ans,cnt)
        #print(cnt)
print(ans)

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

int main(void) {
    long int n, k;
    cin >> n >> k;

    long int x = n;
    long int a;
    while(!(x < k)) {
        a = x/k;
        x = abs(x-a*k);
    }

    if(x < abs(x-k))    cout << x;
    else                cout << abs(x-k);

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int d, g;
int p[20], c[20];
int solve(int i, int g, int t) {
	int sum = Inf;
	for (int j = 0; j < d; j++) {
		if (!(t & (1 << j))) {
			if (g <= 100 * (j + 1) * p[j] + c[j]) {
				if (100 * (j + 1) * p[j] >= g) {
					sum = (int)min((ld)sum, (ld)ceil(g / (100. * (j + 1))));
				}
				else {
					sum = min(sum, p[j]);
				}
			}
			else {
				sum = min(sum, solve(i, g - 100 * (j + 1) * p[j] - c[j], t | (1 << j)) + p[j]);
			}
		}
	}
	return sum;
}
signed main() {
	cin >> d >> g;
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}
	cout << solve(0, g, 0) << endl;
}

Measured memory_bytes: 256
import sys

def query(N):
    n=str(N)
    print("?",n)
    sys.stdout.flush()
    a=input()
    return a=="Y"

count=0
L=-1
start=2
end=11
while end-start>1:
    test=(end+start)//2
    if not query("1"+"0"*(test-1)):
        end=test
    else:
        start=test
    count+=1
if not query("1"+"0"*(start-1)):
    L=start-1
elif not query("1"+"0"*(end-1)):
    L=end-1
else:
    start=1
    end=10
    while end-start>1:
        test=(end+start)//2
        if query("9"*test):
            end=test
        else:
            start=test
        count+=1
    if query("9"*start):
        L=start
    elif query("9"*end):
        L=end
    count+=2
count+=2


ans=""
first=True
while L>1:
    start=int(first)
    end=9
    while end-start>1:
        test=(end+start)//2
        if query(ans+str(test)):
            start=test
        else:
            end=test
        count+=1
    #print(ans,start,end)
    if query(ans+str(end)):
        ans+=str(end)
    else:
        ans+=str(start)
    count+=1
    first=False
    L-=1

start=int(first)
end=9
while end-start>1:
    test=(end+start)//2
    if query(ans+str(test)+"0"):
        end=test
    else:
        start=test
    count+=1
if query(ans+str(start)+"0"):
    ans+=str(start)
else:
    ans+=str(end)
count+=1

print("!",ans)

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

ll a[200005], b[200005];

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        ll A;
        cin >> A;
        a[i] = a[i - 1] + A;
    }
    for (int i = 1; i <= m; i++) {
        ll B;
        cin >> B;
        b[i] = b[i - 1] + B;
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) break;
        int j = upper_bound(b + 1, b + m + 1, k - a[i]) - b - 1;
        ans = max(ans, i + j);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
    int i,n,l,r,mid,cnt,ans=1e9,tot,k;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++)cin>>a[i];
    l=1;r=1e9+5;
    while(l<=r){
        mid=(l+r)/2;tot=0;
        for(i=1;i<=n;i++){
            cnt=(a[i]+mid-1)/mid;
            cnt--;
            tot+=cnt;
        }
        if(tot>k){
            l=mid+1;
        }else{ans=mid;r=mid-1;}
    }cout<<ans;
    return 0;
}

Measured memory_bytes: 5156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var p = ReadInts();
            var ans = 0;
            for (int i = 1; i < p.Count()-1; i++)
            {
                var list = new List<int>() { p[i-1],p[i],p[i+1]};
                list.Sort();
                if (p[i] == list[1]) ans++;
            }
            WriteLine(ans);
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

int main(){
    int N,M,l,r;
    cin >> N >> M;
    int X[N + 1] = {};
    for (int i = 0;i < M;i++){
        cin >> l >> r;
        X[l-1]++;
        X[r]--;
    }
    int Y[N] = {};
    Y[0] = X[0];
    for (int i = 0;i < N;i++){
        Y[i + 1] = Y[i] + X[i + 1];
    }
    int ans = 0;
    for (int i = 0;i < N;i++){
        if (Y[i] == M) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
//Malfurion_Drake
#include<bits/stdc++.h>
#define Maxn 100005
using namespace std;

int n,a[Maxn];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

/*template<typename Drake>
inline Drake max(Drake Cmp1,Drake Cmp2){
	return(Cmp1>Cmp2 ? Cmp1 : Cmp2);
}

template<typename Drake>
inline Drake min(Drake Cmp1,Drake Cmp2){
	return(Cmp1<Cmp2 ? Cmp1 : Cmp2);
}

void addedge(int u,int v){
	++tot;
	ver[tot]=v;
	Next[tot]=head[u];head[u]=tot;
}*/

void init(){
	
	read(n);
	
}

int main(){
	init();
	int T,t,v,mn;
	mn=INT_MAX;
	cin>>T;
	for(int i=1;i<=n;++i){
		
		cin>>t>>v;
		if(v<=T)
		mn=min(mn,t);
	}
	if(mn<INT_MAX)
	cout<<mn<<endl;
	else puts("TLE");
	return 0;
}

Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())
lcm = c * d // fractions.gcd(c, d)
x = b//c - (a-1)//c
y = b//d - (a-1)//d
warikireru = x+y - (b//lcm - (a-1)//lcm)
print(b-a+1-warikireru)

Measured memory_bytes: 5432
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    R = 2**(N.bit_length())
    st = [0] * (R*2)

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += R-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(a,b,n,l,r):
        ret = 0
        if a <= l and r <= b: return st[n]
        if a < r and b > l:
            vl = query(a,b,n*2+1,l,(l+r)//2)
            vr = query(a,b,n*2+2,(l+r)//2,r)
            ret = vl | vr
        return ret

    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1,0,0,R)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

void Solve()
{
    ll n,m,sum=0;
    cin>>n>>m;
    vector <ll> days(m);

    for(int i=0;i<m;i++)
    {
        cin>>days.at(i);
        sum += days.at(i);
    }

    if( n < sum)
        cout<<"-1\n";
    else
        cout<<n-sum<<"\n";
}

int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
        Solve();
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

int main(){
    int N;
    cin >> N;
    double A[1005];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    double ans = 0;
    for(int j = 0; j < N; j++){
        ans += 1 / A[j];
    }
    cout << 1 / ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
const ll p=998244353ll;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
	ll a,b,g;int c,d;
	scanf("%lld%lld%d%d",&a,&b,&c,&d);--a;
	g=((ll)c)*(d/gcd(c,d));
	printf("%lld",((b-(b/c)-(b/d)+(b/g))-(a-(a/c)-(a/d)+(a/g))));
	return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
Hs = list(map(int, input().split()))

Ts = list(map(lambda x: T-x * 0.006, Hs))

i = 0
v = None
for _i, _T in enumerate(Ts):
    if v is None or abs(_T-A) < v:
        v = abs(_T-A)
        i = _i

print(i+1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

const int N=5e5+5;
vector<int> last(N,0),c(N),bit(N,0);
vector<vector<int> > qr(N),qid(N);
int n,q;
void update(int i,int x)
{
    for(;i<=n;i+=(i&-i)) bit[i]+=x;
}

int sum(int i)
{
    int cur=0;
    for(;i;i-=(i&-i)) cur+=bit[i];
    return cur;
}

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

int main()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++) qr[i].clear(),qid[i].clear();
    for(int i=1;i<=n;i++) cin>>c[i],last[i]=0,bit[i]=0;
    vector<int> ans(q);
    for(int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;
        qr[r].pb(l);
        qid[r].pb(i);
    }

    for(int i=1;i<=n;i++)
    {
        if(last[c[i]]>0) update(last[c[i]],-1);
        last[c[i]]=i;
        update(i,1);
        for(int j=0;j<qr[i].size();j++)
        {
            ans[qid[i][j]]=range(qr[i][j],i);
        }
    }

    for(int i=0;i<q;i++) cout<<ans[i]<<endl;

    return 0;
}



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

using namespace std;

int main()
{
   int a,b,x;
   float y;
   scanf("%d %d",&a,&b);
   x=(a+b)/2;
   float c=a;
   float d=b;
   y=(c+d)/2;
   if(x!=y)
   {
      printf("%d\n",x+1);
   }
   else
   {
      printf("%d\n",x);
   }
   return 0;
}


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

using namespace std;

int getCnt(vector<long long> &a, long long v, long long mid) {
    int n = a.size();
    if (v == 0) {
        return mid > 0 ? n-1 : 0;
    }
    auto amid = abs(mid);
    auto target = (amid/v) * (mid > 0 ? 1 : -1);
    if (mid >= 0 && amid%v == 0) {
        target--;
    }
    if (mid < 0) {
        target--;
    }
    auto it = upper_bound(a.begin(), a.end(), target);
    int res = it - a.begin();
    if (v*v < mid) {
        res--;
    }
    //cout << "   " << v << " " << res  << " target= " << target << endl;
    return res;
}

long long solve(vector<long long> a, long long k) {
    int n = a.size();
    vector<long long> b(n);
    for (int i = 0; i < n; i++) {
        b[i] = -a[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    long long l = -1e18 + 9;
    long long r =  1e18 + 9;
    while (l < r) {
        long long mid = (l+r+1)/2;
        long long tot = 0;
        for (auto v: a) {
            tot += getCnt(v > 0 ? a : b, abs(v), mid);
        }
        tot /= 2;
        //cout << mid << " -> " << tot << endl;
        if (tot <= k-1) {
            l = mid;
        } else {
            r = mid-1;
        }
    }
    return l;
}

long long naive(vector<long long> a, long long k) {
    vector<long long> b;
    int n = a.size();
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            b.push_back(a[i]*a[j]);
        }
    }
    sort(b.begin(), b.end());
    return b[k-1];
}

void test() {
    int n = 30;
    int mx = 100;
    while (true) {
        vector<long long> a(n);
        for (int i = 0; i < n; i++) {
            a[i] = rand() % (2*mx) - mx;
        }
        for (int k = 1; k <= n*(n-1)/2; k++) {
            auto actual = solve(a, k);
            auto expected = naive(a, k);
            if (actual != expected) {
                cout << n << " " << k << endl;
                for (int i = 0; i < n; i++) {
                    cout << a[i] << " ";
                }
                cout << endl;
                cout << "expected: " << expected << endl;
                cout << "actual:   " << actual << endl;
                return;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //test();
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << solve(a, k) << endl;
}




Measured memory_bytes: 4992
#include<stdio.h>
int main(void){
   int a,b;
   scanf("%d",&a);
   scanf("%d",&b);
   if(a>b){
       printf("a > b\n");
   }else if(a<b){
       printf("a < b\n");
   }else{
       printf("a == b\n");
   }
   return 0;
}


Measured memory_bytes: 2604
using System ;
namespace Main{
 class Program{
  static void Main(string[] args){
   int N = 2 * int.Parse(Console.ReadLine());
    string []buff = Console.ReadLine().Split(' ');
    int []a = new int[N];
    for ( int i= 0 ; i< N  ;i++)
      a[i] = int.Parse(buff[i]);
    
    for ( int i = 0 ; i < N -1  ; i++){
      for ( int j = i+1 ; j < N ;j++){
        if( a[i] > a[j]){
         int swap = a[i];
          a[i] = a[j];
          a[j] = swap;
        }
      }
    }
    int sum = 0;
    for ( int i = 0 ; i < N / 2  ;i++){
      sum += min(a[2 * i],a[2 * i+1]); 
    }
    Console.WriteLine(sum);
  }
   static int min(int a , int b){
    return a < b ? a : b  ;
   }
 }
}

Measured memory_bytes: 11092
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define hahaha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    hahaha
    
    int n;
    cin>>n;
    d p[n+1];
    int i,j;
    for(i=1;i<=n;++i)
        cin>>p[i];
    
    d dp[n+1];
    fill(dp+1,dp+n+1,0.0);
    dp[0]=1.0;
    
    for(i=1;i<=n;++i)
    {
        for(j=i;j>=0;--j)
        {
            dp[j]=(1-p[i])*dp[j] + ( (j==0) ? 0.0 : p[i]*dp[j-1] );
        }   
    }
    
    d ans=0;
    for(j=n/2+1;j<=n;++j)
        ans+=dp[j];
    
    cout<<fixed<<setprecision(10)<<ans;
    
        
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    priority_queue<pair<ll,int>> pq;
    rep(i,N){
        cin >> A[i] >> B[i];
        pq.push(make_pair(A[i]+B[i],i));
    }
    ll Taka=0;
    ll Aoki=0;
    ll i=0;
    while(!pq.empty()){
        auto P = pq.top();
        pq.pop();
        if(i%2==0){
            Taka += A[P.second];
        }else{
            Aoki += B[P.second];
        }
        i++;
    }
    cout << Taka - Aoki << endl;
    return 0;
}

Measured memory_bytes: 6864
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int cnt = 0;
        for(char c : s.toCharArray() ) {
            if(c == '1') {
                cnt += 1;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes.size < n
		$primes << next_prime($primes[-1]+1)
	end
	$primes[0,n]
end


loop do
	n = gets.to_i
	break if n == 0
	puts make_prime(n).inject{|x,y| x+y}
end

Measured memory_bytes: 6604
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;

const double PI= acos(-1.0);

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n; cin >> n;
    map<long long,long long> mp;
    long long sm = 0;
    for(int i =0; i <n; i++){
        long long ipt;
        cin>>ipt;
        if(mp.find(ipt)!=mp.end()){
            mp[ipt]++;
        }else{
            mp[ipt] = 1;
        }
        sm+=ipt;
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        long long b,c; cin >> b >> c;
        long long diff = c-b;
        long long occ = 0;
        if(mp.find(b)!=mp.end()){
            occ = mp[b]; mp[b] = 0;
        }
        if(mp.find(c)!=mp.end()){
            mp[c]+=occ;
        }
        else{
            mp[c] = occ;
        }
        sm += occ*diff;
        cout << sm << endl;
    }
}

Measured memory_bytes: 8936
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<bitset>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;


using namespace std;

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

int main() {
    int n,w;
    cin>>n>>w;
    
    vector<long long> wt(w+1,0);
    
    long long weight,val;
    
    for(int i=0;i<n;i++){
        cin>>weight>>val;
        for(int j=w+1-weight;j>=0;j--){
            wt[j+weight]=max(wt[j+weight],wt[j]+val);
        }
    }
    
    // // int max=0;
    // for(int i=0;i<w+1;i++){
    //     // if(max<wt[i])
    //     //     max=wt[i];
    //     cout<<" | "<<wt[i];
    // } 
    // cout<<endl;
    cout<<*max_element(wt.begin(),wt.end());
    
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
    return 0;
}



Measured memory_bytes: 3932
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

struct NODE{
	vector<ll> children;
	ll a;
	ll ans;
};

NODE nodes[200001];
ll dp[200001];
ll N;
void DFS(int node, int parent){
	ll temp = *lower_bound(dp, dp+N, nodes[node].a);
	*lower_bound(dp, dp+N, nodes[node].a) = nodes[node].a;
	nodes[node].ans = lower_bound(dp, dp+N, LLONG_MAX) - dp;
	
	for(int i = 0; i < nodes[node].children.size(); i++){
		if(nodes[node].children[i] != parent){
			DFS(nodes[node].children[i], node);
		}
	}
	*lower_bound(dp, dp+N, nodes[node].a) = temp; // DPの状態をもとに戻す
}

int main()
{
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> nodes[i].a;
	}
	for(int i = 0; i < N-1; i++){
		int u,v;
		cin >> u >> v;
		nodes[u].children.push_back(v);
		nodes[v].children.push_back(u);
	}
	fill(dp, dp+N, LLONG_MAX);
	DFS(1, 0);
	for(int i = 1; i <= N; i++){
		cout << nodes[i].ans << endl;
	}
	return 0;
}

Measured memory_bytes: 33532
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  string l;
  ll n;
  cin >> l;
  n=l.size();

//  cout<<n;
  mint dp[2][100005];//0未満
  dp[1][0]=1;
  dp[0][0]=0;
  rep(i,n){
    //cout<<"i"<<i<<endl;
    ll now=l[i]-'0';
    if(now==1){
    //  cout<<"1"<<endl;
      dp[0][i+1]+=dp[0][i]*3;//1,0 0,1 0,0
      dp[0][i+1]+=dp[1][i];//0,0
      dp[1][i+1]+=dp[1][i]*2;//1,0 0,1

    }
    else{
    //  cout<<"0"<<endl;

      dp[0][i+1]+=dp[0][i]*3;//0,0 1,0 0,1
      dp[1][i+1]+=dp[1][i];//0,0
    }
  //  cout<<dp[0][i+1]<<" "<<dp[1][i+1]<<endl;
  }
mint ans=dp[0][n]+dp[1][n];
cout<<ans;

}


Measured memory_bytes: 5288
n = int(input())
A = list(map(int, input().split()))

odd = 0
two = 0
four = 0

for a in A:
    if(a%2): odd += 1
    else:
        if(a%4==0):four+=1
        else: two += 1


if(two):
    if(odd<=four): print("Yes")
    else: print("No")

else:
    if(odd-1<=four): print("Yes")
    else: print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const int mod = 1000000007;

int dp[100001][3] = {0};

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1), c(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 1; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][0] + b[i]);
        dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
    }
    int tmp = max(dp[n][0], dp[n][1]);
    int ans = max(tmp, dp[n][2]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] ch = str.toCharArray();
        int v = 0;
        int max = 0;
        
        for(int i=0;i<ch.length;i++){
            if(ch[i]=='A'||ch[i]=='C'||ch[i]=='G'||ch[i]=='T'){
                v = v+1;
            }else{
                if(max<v){
                    max = v;
                }
                v = 0;
            }
            
            if(max<v){
                max = v;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	string s;
	cin >> s;
	int maxi=0,count=0;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')
			count++;
		else{
			maxi=max(maxi, count);
			count=0;
		}
	}
	maxi=max(maxi, count);
	cout << maxi << endl;
	return 0;
}

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

int main(){
  int n,s = 0;
  cin >> n;
  vector<int> w(110,0);
  for(int i=0; i<n; i++){
    cin >> w[i];
    s += w[i];
  }
  int t = 0;
  vector<int> a(110,0);
  for(int i=0; i<n; i++){
    t += w[i];
    a[i] = max(s - 2*t , 2*t - s);
  }
  sort(a.begin(),a.end());
  cout << a[110-n] << endl;
}

Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

int n;
int main() {
    R(n);
    int s=0,x=0;
    while ( s<n ) {
        x++;
        s+=x;
    }
    if ( s==n ) {
        REP1(i,1,x) W(i);
    } else {
        int y=s-n;
        REP1(i,1,x) if ( i!=y ) W(i);
    }
    return 0;
}


Measured memory_bytes: 764
#ifdef Force
#include <cstdio>
#include <algorithm>
const long long MOD = 998244353;
long long fc[1000001], fi[1000001], O;
int N, M;
int main()
{
	scanf("%d%d", &N, &M);
	fc[0] = fi[0] = fi[1] = 1;
	for (int i = 2; i <= N + M; i++)
		fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
	for (int i = 1; i <= N + M; i++)
	{
		fc[i] = fc[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * fi[i] % MOD;
	}
	for (int i = 0; i <= N; i++)
		for (int j = i == 0; j <= M; j++)
			O = (O + fc[N + M - i - j] * fc[i + j - 1] % MOD * fi[N - i] % MOD * fi[M - j] % MOD * fi[i] % MOD * fi[j] % MOD * std::max(i, j)) % MOD;
	printf("%lld\n", O * fc[N] % MOD * fc[M] % MOD * fi[N + M] % MOD);
	return 0;
}
#else
#include <cstdio>
#include <algorithm>
const long long MOD = 998244353;
long long fc[1000001], fi[1000001], O;
int N, M;
int main()
{
	scanf("%d%d", &N, &M);
	fc[0] = fi[0] = fi[1] = 1;
	for (int i = 2; i <= N + M; i++)
		fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
	for (int i = 1; i <= N + M; i++)
	{
		fc[i] = fc[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * fi[i] % MOD;
	}
	if (N > M)
		std::swap(N, M);
	for (int i = 1; i <= N; i++)
		O = (O + fi[N - i] * fi[i] % MOD * fi[M - i] % MOD * fi[i] % MOD * fc[i + i] % MOD * fc[N + M - i - i]) % MOD;
	O = (O * fc[N] % MOD * fc[M] % MOD * fi[N + M] % MOD * (MOD + 1 >> 1) + M) % MOD;
	printf("%lld\n", O);
}
#endif

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

using namespace std;

int main(){
	long  sum = 0;
	int n;
	int a[200001];
	int pos[200001];
	set<int> data;

	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		pos[a[i]] = i;
	}

	data.insert(0);
	data.insert(n+1);


	for (int i = 1; i <= n; ++i)
	{
		int l, r;
		data.insert(pos[i]);
		set<int>::iterator it = data.find(pos[i]);
		r = *(++it) - pos[i];
		--it;
		l = pos[i] - *(--it);

		sum += (long)i * r * l;
	}
	cout << sum << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  int r,g,p;
  cin >> r;
  cin >> g;
  p=2*g-r;
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        int maxCount = 0;
        int result = 1;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 1;i <= n; i++){
            int count = 0;
            int currentNum = i;
            
            while(true){
                if (currentNum % 2 == 0) {
                    currentNum = currentNum / 2;
                    count++;
                } else {
                    break;
                }
                
            }

            if (count > maxCount) {
                maxCount = count;
                result = i;
            }
        }
        
        System.out.println(result);
        
        sc.close();
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
using namespace std;
using Int = long long int;

    struct rule {
        Int b;
        Int c;

        bool operator<(const rule& right) const{
            return c < right.c;
        }
    };

int main() {

    Int n, m;
    cin >> n >> m;

    vector<Int> a(n);
    vector<rule> rules(m);

    rep(i, n) cin >> a[i];

    rep(i, m) {
        cin >> rules[i].b >> rules[i].c;
    }

    sort(a.begin(), a.end());
    sort(rules.rbegin(), rules.rend());

    //rep(i, n) cout << a[i] << " ";
    //cout << endl;

    Int now = 0;
    rep(i, m) {
        rep(j, rules[i].b) {
            if(rules[i].c <= a[now]) {
                break;
            }
            a[now] = rules[i].c;
            now++;
        }
    }

    //rep(i, n) cout << a[i] << " ";
    //cout << endl;

    Int sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2560