akhauriyash/Code-Regression huggingface dataset:
require 'pp'

n, m = gets.chomp!.split.map(&:to_i)
p_m = []
s_m = []
memo2 = Array.new(n, 0)
memo3 = Array.new(n, 0)

m.times do |i|
    p, s = gets.chomp!.split
    p_m << p.to_i
    s_m << s
end

wa_count = 0
ac_count = 0

m.times do |i|
    if memo2[p_m[i] - 1] == 0 && s_m[i] == 'WA'
        memo3[p_m[i] -1 ] += 1
    end

    if memo2[p_m[i] -1 ] == 0 && s_m[i] == 'AC'
        memo2[p_m[i] -1 ] = 1
        ac_count += 1
    end
end

sum = 0
n.times do |i|
    if memo2[i] == 1
        sum += memo3[i]
    end
end

puts "#{ac_count} #{sum}"


Measured memory_bytes: 12156
while line = gets
    line = line.chomp
    joi = ioi = 0
    for i in 0..(line.length-3)
        joi += 1 if line[i, 3] == "JOI"
        ioi += 1 if line[i, 3] == "IOI"
    end
    puts joi
    puts ioi
end


Measured memory_bytes: 6860
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int N,D,X[10][10],ans=0;
	double sum;
	cin>>N>>D;
	for(int i=0;i<N;i++)for(int j=0;j<D;j++)cin>>X[i][j];
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			sum=0;
			for(int k=0;k<D;k++){
				sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			if(floor(sqrt(sum))*floor(sqrt(sum))==sum)ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
const ll mod=1e9+7;
// const int maxn = 3010;

ll dp[110][100010],a[110],prefix[110][100010];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n,k;
	cin>>n>>k;
	fre(i,1,n) cin>>a[i];
	// for (int i = 0; i < 100010; ++i)
	// {
	// 	dp[0][i]=1;
	// }
	dp[0][0]=1;
	for (int i = 0; i < 100010; ++i)
	{
		prefix[0][i]=1;
	}
	fre(i,1,n){
		for (int j = 0; j < 100010; ++j)
		{
			if(j<=a[i]){
				dp[i][j] = prefix[i-1][j];
			}
			else{
				dp[i][j] = (prefix[i-1][j]-prefix[i-1][j-a[i]-1]+mod)%mod;
			}
		}
		for (int j = 0; j < 100010; ++j)
		{
			if(j==0)prefix[i][j]=dp[i][j];
			else prefix[i][j]=(prefix[i][j-1]+dp[i][j])%mod;
		}
	}
	output(dp[n][k]);
	return 0;
}

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

const int N = 1e5+8;
int a[N];

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

    int n, L;
    cin>>n>>L;

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

    int mx = 0, mxid;
    for (int i=1; i<=n; i++)
        if (a[i+1]+a[i] > mx) {
            mx = a[i] + a[i+1];
            mxid = i;
        }

    if (mx < L)    {
        cout<<"Impossible"<<endl;
        return 0;
    }

    cout<<"Possible"<<endl;
    for (int i=1; i<mxid; i++)  cout<<i<<"\n";
    for (int i=n-1; i>mxid; i--)  cout<<i<<"\n";
    cout<<mxid<<endl;
}


Measured memory_bytes: 4036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define MAX_V 100000
vector<int> G[MAX_V];


pii mergeSegment(pii a,pii b){	//returns pii(1,-1) when two segments don't crossed.
	if(a.first<=-INF) return b;
	if(b.first<=-INF) return a;
	if(abs(a.first)%2!=abs(b.first)%2) return pii(1,-1);
	
	if(a.second<b.first || b.second<a.first)	return pii(1,-1);
	if(a.first<=b.first && b.second<=a.second)	return b;
	if(b.first<=a.first && a.second<=b.second)	return a;
	if(a.first<b.first && a.second<b.second)	return pii(b.first,a.second);
	if(b.first<a.first && b.second<a.second)	return pii(a.first,b.second);
	
	assert(0);
	return pii(1,-1);
}

vector<pii> dp;

pii dfs(int cur,vector<bool> &used){
	pii res = dp[cur];
	for(auto &e:G[cur]){
		if(used[e])continue;
		used[e]=true;
		pii p = dfs(e,used);
		p.first--,p.second++;
		res = mergeSegment(res,p);
	}
	return (dp[cur] = res);
}


int main(){
	int v;
	cin>>v;
	rep(i,v-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	int k;
	cin>>k;
	
	
	int root=-1;
	dp.resize(v,pii(-INF,INF));
	rep(i,k){
		int a,b;
		cin>>a>>b;
		a--;
		dp[a] = pii(b,b);
		root = a;
	}
	
	vector<bool> used(v,false);
	used[root] = true;
	
	
	dfs(root,used);
	
	rep(i,v)if(dp[i]==pii(1,-1)){cout<<"No"<<endl;return 0;}
	
	cout<<"Yes"<<endl;
	
	queue<int> que;
	que.push(root);
	
	vector<int> ans(v,-INF);
	ans[root] = dp[root].first;

	while(que.size()){
		int q = que.front();
		que.pop();
		
		int p=ans[q];
		for(auto &e:G[q]){
			if(ans[e]!=-INF)continue;
			
			if(dp[e].first<=p-1&&p-1<=dp[e].second)ans[e] = p-1;
			else ans[e] = p+1;
			que.push(e);
		}
	}
	rep(i,v)cout<<ans[i]<<endl;
}

Measured memory_bytes: 13824
nn,x=map(int,input().split())
ns=[1 for i in range(51)]
nm=[1 for i in range(51)]
for i in range(1,51):
    ns[i]=2*ns[i-1]+3
    nm[i]=2*nm[i-1]+1
def np(n,w):
    if w==0:
        return 0
    elif n==1:
        if w==1:
            return 0
        elif w==2:
             return 1
        elif w==3:
            return 2
        else:
            return 3
    else:
        if ns[n]//2+1>w:
            return np(n-1,w-1)
        elif ns[n]//2+1==w:
            return nm[n-1]+1
        else:
            return np(n-1,w-ns[n-1]-2)+nm[n-1]+1
print(np(nn,x))

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


int main(){
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%d %d %.8f\n", d, r, f);
}


Measured memory_bytes: 3212
N, A = map(int, input().split())
x = list(map(int, input().split()))

dp = [[[0] * 2550 for i in range(55)] for i in range(55)]

dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(2451):
            dp[i+1][j+1][k+x[i]] += dp[i][j][k]
            dp[i+1][j][k] += dp[i][j][k]

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A*i]

print(ans)

Measured memory_bytes: 128100
#include<stdio.h>
int main(void){
  long long int x,k,d,a,b;
  scanf("%lld%lld%lld",&x,&k,&d);
  if(x<0){
    x*=-1;
  }
  a=x/d;
  if(a>=k){
    printf("%lld\n",x-k*d);
    return 0;
  }
  b=k-a;
  if(b%2==0){
    printf("%lld\n",x-a*d);
    return 0;
  }else{
    printf("%lld\n",-(x-(a+1)*d));
    return 0;
  }
  return 0;
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long A = GetLong();
		long B = GetLong();
		long C = GetLong();
		long K = GetLong();
		long cnt = 0;
		while(B <= A)
		{
			B *= 2;
			cnt++;
		}
		while(C <= B)
		{
			C *= 2;
			cnt++;
		}
		WriteLine((cnt <= K) ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27492
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string S; cin >> S;

    for (int i = 0; i < S.length(); i++) {
        S[i] = 'x';
    }

    cout << S << endl;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    sort(all(s));
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes\n";
    else cout << "No\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3600
a, b = list(map(int, input().split(" ")))

min_i = min([a, b])

def calc(n):
  while n > 1:
    if (a % n) == 0 and (b % n) == 0:
      return n
    n -= 1
  return 1

print("{:.0f}".format(a * b / calc(min_i)))
    

Measured memory_bytes: 3188
#include <cstdio>
#include <map>
#define NDEBUG
typedef long long lld;
const int MAXN = 2e5+5;
const int MOD = 1e9+7;
int size[MAXN][2]{ };
int  two[MAXN];
lld A, B;
int K, N;
int ret, zero;

template <typename T> T gcd(T a, T b) { return (b) ? gcd(b, a % b) : a; }

struct Frac {
  lld A, B;
  
  bool operator < (const Frac& o) const {
    return (A != o.A) ? (A < o.A) : (B < o.B);
  }
  
  void reduce() {
    lld G = gcd(A, B);
    A /= G;
    B /= G;
    return this->sign();
  }
  
  void sign() {
    if (B > 0) return;
    if ((A >= 0) && (B >= 0)) return;
    // Skip: [+,+] [+,=] [=,+] [=,=] [-,+]
    // Flip: [+,-] [=,-] [-,=] [-,-]
    A *= -1;
    B *= -1;
  }

#ifndef NDEBUG
  void display() const {
    printf("%lld / %lld\n", A, B);
  }
#endif
};
std::map<Frac, int> C;
Frac f;

void compute(int i) {
  if (!f.A && !f.B) {
    ++zero;
    return;
  }
  f.reduce();

#ifndef NDEBUG
  f.display();
#endif

  if (C.count(f)) {
    ++size[C.at(f)][0];

#ifndef NDEBUG
    puts("[0]---");
#endif
    return;
  }
  Frac g = {-f.B, f.A};
  g.sign();

#ifndef NDEBUG
  g.display();
#endif

  if (C.count(g)) {
    ++size[C.at(g)][1];

#ifndef NDEBUG
    puts("[1]---");
#endif
    return;
  }
  C[f] = K++;
  ++size[C.at(f)][0];

#ifndef NDEBUG
  puts("[0]---");
#endif
}

void init() {
  two[0] = 1;
  for (int i = 1; i <= N; ++i) {
    two[i] = 2LL * two[i-1] % MOD;
  }
}

int main() {
  scanf("%d", &N);
  init();
  zero = 0;
  for (int i = 1; i <= N; ++i) {
    scanf(" %lld%lld", &f.A, &f.B);
    compute(i);
  }
  ret = 1;
  for (int i = 0; i < K; ++i) {
    int cnt = (1LL * two[size[i][0]] + two[size[i][1]]) % MOD;
    cnt = (1LL * cnt - 1 + MOD) % MOD;
    ret = 1LL * ret * cnt % MOD;
  }
  ret = (1LL * ret - 1 + MOD) % MOD;
  ret = (1LL * ret + zero) % MOD;
  printf("%d\n", ret);
  return 0;
}

/*
5
1 0
-1 0
0 -1
0 1
1 0
*/

Measured memory_bytes: 17900
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string a;
	getline(cin,a);
    for(int i=0;i<1200;i++)
     {
	  if(a[i]<91&&a[i]>64)
	  a[i]=a[i]+32;
	  else if(a[i]>96&&a[i]<123)
	  a[i]=a[i]-32;
	 }
     cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
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;}

int N;
int a,b,c,d,e;
string S, T;

// auto solve(){
// 	auto ans = 0;
// 	return ans;
// }

int main(){
	cin>>S;
	auto ans = "Yes";
	if(S[0]==S[1] && S[1]==S[2]) ans = "No";
	cout<< ans <<endl;
	// cout<< solve() <<endl;
	// printf("%f\n",solve());
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
	double v,t,y,n1;
	int n;
	while(scanf(" %lf",&v)!=EOF){
    	t=v/9.8;
    	y=4.9*t*t;
    	n=0;
    	n1=(5+y)/5;
    	while(n<n1){
    		n=n+1;
    	}
		printf("%d\n",n);
    }
	return 0;
}

//debug for alfa

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<vector<int>> A(N, vector<int>(N));
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        A[l][r]++;
    }

    vector<vector<int>> sum(N + 1, vector<int>(N + 1));
    rep(i, N) {
        rep(j, N) {
            sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + A[i][j];
        }
    }

    rep(i, Q) {
        int p, q;
        cin >> p >> q;
        int ans = sum[q][q] - sum[p - 1][q];
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll x;
    cin >> x;
    for(ll i = sqrt(sqrt(x));i>=0;i--){
        for(ll j = i-1;j>-1*sqrt(sqrt(x));j--){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int N, t, m;
int T[20][20];
const int INTMax = 1 << 17;
int dp[INTMax];

int solve() {
	for (int i = 0; i < N; i++){
		for (int j = 0; j <= N; j++) {
			cin >> T[i][j];
		}
	}
	
	for(int i = 0; i < INTMax; i++) dp[i] = INTMax * 1000;
	dp[0] = 0;
	
	for (int cnt = 0; cnt < (1 << N); cnt++) {
		for (int i = 0; i < N; i++) {
			if(((cnt >> i) & 1) == 0) {
				//cout << cnt << endl;
				m = T[i][0];
				for (int j = 0; j < N; j++) {
					if(i == j) continue;
					if(((cnt >> j) & 1) == 1) {
						m = min(m, T[i][j + 1]);
					}
				}
				dp[cnt | (1 << i)] = min(dp[cnt] + m, dp[cnt | (1 << i)]);
			}
		}
	}
	
	cout << dp[(1 << N) - 1] << endl;
}

int main() {
	cin >> N;
	while(N) {
		solve();
		cin >> N;
	}
}



Measured memory_bytes: 3584
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print(sum(map(lambda v: math.fabs(v[0] - v[1]), zip(x, y))))
print(sum(map(lambda v: math.fabs((v[0] - v[1]) ** 2), zip(x, y))) ** (1/2))
print(sum(map(lambda v: math.fabs((v[0] - v[1]) ** 3), zip(x, y))) ** (1/3))
print(max(map(lambda v: math.fabs(v[0] - v[1]), zip(x, y))))



Measured memory_bytes: 5696
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
int a[22];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 2) {
		if (a[i + 1] != max({ a[i],a[i + 1],a[i + 2] }) && a[i + 1] != min({ a[i],a[i + 1],a[i + 2] }))ans++;
	}
	cout << ans << endl;
	ggr
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int a,b;
    char ch;
    cin >> a >> ch >> b;
    if( ch == '+'){
        cout << a + b << endl;
    }else{
        cout << a - b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// 基本テンプレート

#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>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int 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;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int ans[100010];

signed main() {
    cin >> N;
    vector<pii> v;
    v.push_back(pii(0, 0));
    rep(i,0,N) {
        int p; cin >> p;
        v.push_back(make_pair(p, -i));
    }

    sort(v.begin(), v.end(), greater<pii>());
    int idx = 0, c = INF;
    while(v[idx].first != 0) {
        chmin(c, -v[idx].second);

        int ub = N, lb = idx;
        while(ub - lb > 1) {
            int mid = (ub + lb) / 2;
            if(v[mid].first != v[idx].first) ub = mid;
            else lb = mid;
        }

        int diff = v[idx].first - v[ub].first;
        ans[c] += ub * diff;
        idx = ub;
    }

    rep(i,0,N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int r;
  cin >> r;
  cout << 3 * r * r << endl;

	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

#素因数分解
def prime_factorize(n):
    a = []
    a.append(1)
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    
    b = [[],[]]
    cnt = 1
    for i in range(len(a)+1):
        if i > 0 and i < len(a):
            if a[i] == a[i-1]:
                cnt += 1
            else:
                b[0].append(a[i-1])
                b[1].append(cnt)
                cnt = 1
        if i == len(a) and i > 0:
            b[0].append(a[i-1])
            b[1].append(cnt)
        elif i == len(a) and i == 0:
            b[0].append(a[i])
            b[1].append(cnt)
    return b

#コンビネーション(特殊例)
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**5 + 100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, m = MAP()
mar = prime_factorize(m)
arr = mar[1]
ans = 1
for i in range(1, len(arr)):
    ans *= cmb(arr[i] + n - 1, arr[i])
    ans %= mod
print(ans)


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

int main(){
    long a,b,c;
    long long ans;
    cin >> a >> b >> c;
    if(a+b>=c)ans=b+c;
    if(a+b<c)ans=b+a+b+1;
    cout << ans <<endl;
}

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

int main(){
    double X, Y, a;
    //double n;

    std::cin >> X >> Y;

    a = (4.0 * X - Y)/2.0;

    if(ceil(a) == a && X >= a && a >= 0){
        std::cout << "Yes";
    }else{
        std::cout << "No";

    }

}

Measured memory_bytes: 3716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	var x = []int{}
	for i := 0; i < m; i++ {
		x = append(x, nextInt())
	}

	free := n
	for _, day := range x {
		free -= day
	}

	if free < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(free)
	}

}


Measured memory_bytes: 2224
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    string ar , br;
    cin >> ar >> br;
    int cnt = 0;
    for(int i=0;i<ar.size();i++){
        if(ar[i]==br[i])cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

int main()
{
  double a, b, x;
  cin >> a >> b >> x;
  double res;
  if (a * a * b <= x * 2) {
    res = atan(2*b/a - 2*x/(a*a*a)) * 180.0 / M_PI;
  } else {
    res = atan(a * b * b / x / 2) * 180.0 / M_PI;
  }
  printf("%.10lf\n", res);
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    G[x].append(y)

memo = [-1]*n
def dp(v):
    if memo[v] != -1:
        return memo[v]
    res = 0
    for nv in G[v]:
        res = max(res, dp(nv) + 1)
    
    memo[v] = res
    return res

ans = 0
for v in range(n):
    ans = max(ans, dp(v))
print(ans)

Measured memory_bytes: 59056
#include <bits/stdc++.h>
using namespace std;
char s[5];
int main()
{
	scanf("%s",s);
	int cnt=0,ans=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='R') cnt++;
		else 
		{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  int maxv=0;
  int s=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    if(a[i]>maxv)
    {
      s+=maxv;
      maxv=a[i];
    }
    else
      s+=a[i];
  }
  if(maxv<s)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

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

typedef long long ll;
using namespace std;

int main(){
    ll n;cin >> n;
    vector<ll>L(n+1);
    L[0]=2;
    L[1]=1;
    for(ll i=2;i<=n;i++){
        L[i]=L[i-1]+L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int i=1, j, sum, x;
    char ch[10000];

    while (i) {
        scanf("%s", ch);
	    x=atoi(ch);
        if (x==0) break;
        j=0;
        while (ch[j]!=0) {
            sum+=ch[j]-'0';
            j++;
        }
        printf("%d\n", sum);
        sum=0;
    }
    return 0;
}



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

int main()
{
  int N;
  cin >> N;
  int Asum=0;
  int Bsum=0;
  vector<int>a(N);
  for(int i=0;i<N;i++){
	cin >>a.at(i);
  }
     
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i=0;i<N;i++){
	if(i%2==0)  Asum+=a.at(i);
    if(i%2==1)  Bsum+=a.at(i);
  }
  cout << Asum - Bsum << endl;
}

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

using namespace std;

int main(void) {

	int a[3];

	for (int k = 0; k < 3; k++) {
		cin >> a[k];
	}

	sort(a, a + 3,greater<int>());

	cout << (a[0] * 10) + a[1] + a[2] << "\n";



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N, C;
    cin >> N >> C;
    vector<int> x(N), v(N);
    REP(i, N){
        cin >> x[i] >> v[i];
    }

    vector<int> leftmax(N + 1), rightmax(N + 1);
    leftmax[0] = 0;
    rightmax[0] = 0;

    int maxval = 0, val = 0;
    REP(i, N){
        val += v[i];
        if(maxval < val - x[i]) maxval = val - x[i];
        leftmax[i + 1] = maxval;
    }
    maxval = 0, val = 0;
    REP(i, N){
        val += v[N - i - 1];
        if(maxval < val - (C - x[N - i - 1])) maxval = val - (C - x[N - i - 1]);
        rightmax[i + 1] = maxval;
    }

    int ansl = rightmax[N], ansr = leftmax[N];

    val = 0;
    REP(i, N){
        val += v[i];
        if(ansl < val - 2 * x[i] + rightmax[N - i - 1]) ansl = val - 2 * x[i] + rightmax[N - i - 1];
    }
    val = 0;
    REP(i, N){
        val += v[N - i - 1];
        if(ansr < val - 2 * (C - x[N - i - 1]) + leftmax[N - i - 1]) ansr = val - 2 * (C - x[N - i - 1]) + leftmax[N - i - 1];
    }

    cout << max(ansl, ansr);

    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
//fsdgfsgsgs
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

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

int main(){

    int N, K, h, cnt=0;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if(h >= K){
            cnt++;
        }
    }
    cout << cnt << endl;

}


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

int main(){
  vector<int> v(3);
  for(int i = 0; i < 3; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
  return 0;
}

Measured memory_bytes: 256
mod_val = 10**9+7
n, k = map(int, input().split())
factorials = [1]*(n+1)  # values 0 to n
for i in range(2, n+1):
  factorials[i] = (factorials[i-1]*i)%mod_val
def mod_binomial(a, b):
  numerator = factorials[a]
  denominator = (factorials[b]*factorials[a-b])%mod_val
  invert = pow(denominator, mod_val-2, mod_val)
  return (numerator*invert)%mod_val
partial = 0
# m is number of rooms with no people
for m in range(min(k+1, n)):
  # m places within n to place the 'no people' rooms
  # put n-(n-m) people in n-m rooms (n-m) must be placed to be non-empty
  partial = (partial + (mod_binomial(n, m) * mod_binomial(n-1, m))%mod_val)%mod_val
print(partial)

Measured memory_bytes: 72272
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        s: Chars
    }

    for c in s {
        if c == '?' {
            print!("D");
        } else {
            print!("{}", c);
        }
    }
}


Measured memory_bytes: 2988
import java.util.Scanner;

public class Main {

    static int a = 0;
    static int b = 0;
    static int count = 0;

    static String p;
    static String q;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        StringBuilder sbp = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sbp.append(scan.next());
        }
        p = sbp.toString();
        StringBuilder sbq = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sbq.append(scan.next());
        }
        q = sbq.toString();
        scan.close();

        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            sb.append(i);
        }

        permutation(sb.toString(), "");

        System.out.println(Math.abs(a - b));
    }

    private static void permutation(String s, String ans) {
        if (s.length() == 1) {
            count++;
            String perm = ans + s;
            if (perm.equals(p)) {
                a = count;
            }
            if (perm.equals(q)) {
                b = count;
            }
            return;
        }

        for (int i = 0; i < s.length(); i++) {
            permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
        }
    }

}


Measured memory_bytes: 40916
#include<bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x)
{
  char c=getchar();
  bool f=0;
  x=0;
  while(!isdigit(c)) f|=c=='-',c=getchar();
  while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
  if(f) x=-x;
  return x;
}
template<class t> inline void write(t x)
{
  if(x<0) putchar('-'),write(-x);
  else
  {
    if(x>9) write(x/10);
    putchar('0'+x%10);
  }
}
bool cmp(int x,int y)
{
	return x>y;
}
int n,k,a[100],ans=0;
int main()
{
	read(n);
	read(k);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++) ans+=a[i];
	write(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++) 
#define FI(i,L,R) int i; for(i = L;i<R;i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FEI(i,L,R) int i;for(i = L;i <= R;i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFI(i,L,R) int i;for (i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define FFEI(i,L,R) int i;for (i = L; i >=R; i--)
 
#define getI(a) cin>>a 
#define getII(a,b) cin>>a>>b
#define getIII(a,b,c) cin>>a>>b>>c
#define wez(n) int (n); cin>>n //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); cin>>n>>m
#define wez3(n,m,k) int (n),(m),(k); cin>>n>>m>>k
#define TESTS wez(testow);while(testow--) //for multilple cases problems
#define arrayIn(a,L,R) FE(i,L,R) cin>>a[i]
#define VectorIn(V,n) FE(i,0,n-1){wez(xscd);V.pb(xscd);}  // remember to not use ;
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define fi first
#define se second
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
#define pb push_back

#define MOD (int)(1000000007)
#define MOD1 (int)(998244353)
#define pi pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pq priority_queue<int>

#define pcout(x) cout<<setprecision(15)<<x<<'\n';

ll GCD(ll x,ll y){ if(y == 0) return x; if(x>y) return GCD(y,x%y); return GCD(x,y%x);}
ll LCM(ll x,ll y){ return (x*y)/GCD(x,y);}
ll MPOW(ll a,ll b,ll m = LLONG_MAX){if(b == 0) return 1; if(b&1)return ((a%m)*(MPOW(a,b-1,m)%m))%m; a = (a*a)%m; return (MPOW(a,b/2,m));}
ll MINV(ll a,ll m){return MPOW(a,m-2,m);}
inline bool max3(ll a,ll b,ll c) {return max(a,max(b,c));}
inline bool min3(ll a,ll b,ll c){return min(a,min(b,c));}
inline bool sortbythis(pi a,pi b){return ((a.fi==b.fi && a.se<b.se)|| (a.fi<b.fi));}
inline bool sortbythat(pi a,pi b){return ((a.se == b.se && a.fi<b.fi)||(a.se<b.se));}

class pnc
{
  ll FACTMAX,MODU;
  vll fact;
public:
	pnc(ll n,ll m){FACTMAX = n;MODU = m;fact.resize(n+1);MFACT_INIT(MODU);}
	void MFACT_INIT(ll m){fact[0] = 1; FE(i,1,FACTMAX) fact[i] = (i*fact[i-1])%MODU;}
	ll MFACT(ll n){return fact[n];}
	ll PERM(ll n,ll r){return (fact[n]*MINV(fact[n-r],MODU))%MODU;}
	ll COMB(ll n,ll r){return (PERM(n,r)*MINV(fact[r],MODU))%MODU;}
};

const int MAXN = int(1e5)+1;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    wez(n);
    int arr[202];
    arrayIn(arr,1,2*n);
    sort(arr+1,arr+2*n+1);
    ll ans = 0;
    FE(i,1,2*n)
    {
    	if(i%2 == 1)
    		ans = (ans+arr[i]);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
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; }

int main(){
  int N;
  cin >> N;
  int w[110];
  int S = 0;
  int s1 = 0;
  int diff = 1000;
  for(int i=0;i<N;++i){
    cin >> w[i];
    S += w[i];
  }
  for(int i=0;i<N;++i){
    s1+=w[i];
    diff = min(diff,abs(S-2*s1));
  }
  cout << diff <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
    }

    auto cal = [&](int x) {
        ll ans = 0;
        ll sum = 0;
        REP(i, N) {
            sum += a[i];
            if (sum * x <= 0) {
                ans += abs(sum) + 1;
                sum = x;
            }
            x *= -1;
        }
        return ans;
    };
    ll ans = min(cal(1), cal(-1));
    print(ans);

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200000 + 10;
const LL MOD = 1e9 + 7;
int n, c[N], dep[N], ans[N];
vector<int> g[N], vec[N];
void dfs(int u, int p) {
	dep[u] = dep[p] + 1;
	vec[dep[u]].push_back(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs(v, u);
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i ++) {
		int u, v; scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	long long s = 0;
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &c[i]); s += c[i];
	}
	sort(c + 1, c + 1 + n); s -= c[n];
	dfs(1, 1);
	for (int i = n, j = 1; i >= 1; i --) {
		for (auto x: vec[i]) {
			ans[x] = c[j ++];
		}
	}
	printf("%lld\n", s);
	for (int i = 1; i <= n; i ++) {
		printf("%d ", ans[i]);
	}
}	


Measured memory_bytes: 11648
package main

import (
	"fmt"
	"sort"
)

func main() {
	n := 0
	fmt.Scan(&n)

	x := make([]int, n)
	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Scan(&tmp)
		x[i] = tmp
	}

	X := make([]int, n)
	copy(X, x)
	sort.Ints(X)

	mid := n / 2
	for i := 0; i < n; i++ {
		if x[i] < X[mid] {
			fmt.Println(X[mid])
		} else {
			fmt.Println(X[mid-1])
		}
	}
}


Measured memory_bytes: 10404
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,pd,q[52][52];
    char p[52][52];
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>p[i][j];
            q[i][j]=-1;
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(p[i][j]=='.')
            {
                pd=0;
                if(i-1>0 && j-1>0 && p[i-1][j-1]=='#') pd++;
                if(i>0 && j-1>0 && p[i][j-1]=='#') pd++;
                if(i+1<=h && j-1>0 && p[i+1][j-1]=='#') pd++;
                if(i-1>0 && j>0 && p[i-1][j]=='#') pd++;
                if(i>0 && j>0 && p[i][j]=='#') pd++;
                if(i+1<=h && j>0 && p[i+1][j]=='#') pd++;
                if(i-1>0 && j+1<=w && p[i-1][j+1]=='#') pd++;
                if(i>0 && j+1<=w && p[i][j+1]=='#') pd++;
                if(i+1<=h && j+1<=w && p[i+1][j+1]=='#') pd++;
                q[i][j]=pd;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(q[i][j]>=0 && q[i][j]<=8) cout<<q[i][j];
            else cout<<'#';
        }
        cout<<endl;
    }
    return 0;
}

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

#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"

typedef long long ll;
typedef long double ld;

const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;

int main()
{
   bolt;
   string s;
   cin>>s;
   for (ll i=0;i<s.size();i++)
   {
      if (s[i]=='1')
         s[i]='9';
      else if (s[i]=='9')
         s[i]='1';
   }
   cout<<s;
}


Measured memory_bytes: 256
"""
K,S=map(int,input().strip().split(" "))
count=0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if((x+y+z)==S):
                count+=1
                #print(x,y,z)
print(count)
            
"""

K,S=map(int,input().strip().split(" "))
count=0

for x in range(K+1):
    for y in range(K+1):
        if(0<=S-x-y<=K):
            count+=1
print(count)
            


Measured memory_bytes: 3064
using System;

namespace ABC_092_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var D = int.Parse(Console.ReadLine());

            Console.WriteLine((A < B ? A : B) + (C < D ? C : D));
        }
    }
}


Measured memory_bytes: 13140
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	A := make([][]byte, N)
	for i := range A {
		A[i] = make([]byte, N)
		fmt.Scan(&A[i])
	}
	B := make([][]byte, M)
	for i := range B {
		B[i] = make([]byte, M)
		fmt.Scan(&B[i])
	}
	// fmt.Println("N", N, "A", A)
	// fmt.Println("M", M, "B", B)
	for i := 0; i+M <= N; i++ {
		for j := 0; j+M <= N; j++ {
			ok := true
			for k := 0; k < M; k++ {
				for l := 0; l < M; l++ {
					if A[i+k][j+l] != B[k][l] {
						ok = false
					}
				}
			}
			if ok {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;

/*
  let's try computer shogi!!!
 */


int N;

const long long int infdist = 114514191919334;
long long int d[300][300];
long long int mind[300][300];

int main(){
  cin >> N;
  long long int  ans = 0;
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      cin >> d[i][j];
      mind[i][j] = d[i][j];
    }
  }

  // Warshall Floyd
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      for(int k=0;k<N;++k){
	mind[j][k] = min(mind[j][k] , mind[j][i] + mind[i][k]);
      }
    }
  }

  /*
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      cerr<<mind[i][j]<<",";
    }
    cerr<<endl;
  }
  */
  
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(i==j){continue;}
      if(d[i][j] != mind[i][j]){
	cout<<"-1"<<endl;
	return 0;
      }else{
	bool build = true;
	for(int k=0;k<N;++k){
	  if(k==j || k == i){continue;}
	  if(d[i][k] + d[k][j] == d[i][j]){
	    build = false; 
	    //cerr<<"load cut "<<i<<","<<j<<","<<k<<" (i,j,k)"<<endl;
	    break;
	  }
	}
	if(build){
	  ans += d[i][j];
	}
      }
    }
  }
  cout<<ans/2<<endl;
  return 0;
}



Measured memory_bytes: 1664
a , b = gets.strip.split(' ').map(&:to_i);
ans0 = a * b;
ans1 = a * b * 2;
ans2 = a * b * 3;

if ans0 % 2 == 1 || ans1 % 2 == 1 || ans2 % 2 == 1 
	puts "Yes"
	else
	puts "No"
end




Measured memory_bytes: 1788
x,y = map(int,input().split())
result = False
for turtleI in range(51):
    if turtleI > x:
        break
    if (turtleI * 2 + (x - turtleI) * 4 == y):
        result = True
        break
if result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
k,t=map(int,input().split())
A=sorted(list(map(int,input().split())), key=lambda x: -x)
while len(A)!=1:
    A[0] -=A.pop(1)
    A=sorted(A, key=lambda x: -x)
print(A[0]-1 if A[0]!=0 else 0)

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

int main() {
  int n, k, ans;
  cin >> n >> k;
  ans = 1;
  
  for (int i=0; i<n; i++) {
    if (ans*2 < ans+k)
      ans *= 2;
    else
      ans += k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624