akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 605

int N;
ll ADD;
ll table[SIZE];
ll dp[SIZE][5][SIZE]; //dp[数列の末尾][何人目(=k)か][k人目の始点] = 場合の数
ll BASE;

ll recursive(int tail,int index,int loc){

	if(dp[tail][index][loc] != -1){

		return dp[tail][index][loc];
	}

	if(index == 4){ //取り分は自動決定

		if(table[tail]-table[loc-1]+ADD >= BASE){

			return dp[tail][index][loc] = 1;
		}else{

			return dp[tail][index][loc] = 0;
		}
	}

	int left = loc,right = tail,mid = (left+right)/2;
	int left_loc = tail+1;

	while(left <= right){

		if(table[mid]-table[loc-1]+ADD >= BASE){

			left_loc = mid;
			right = mid-1;
		}else{

			left = mid+1;
		}
		mid = (left+right)/2;
	}

	ll ret = 0;
	for(int next_start = left_loc+1; next_start <= tail; next_start++){

		ret += recursive(tail,index+1,next_start);
	}

	return dp[tail][index][loc] = ret;
}


int main(){

	scanf("%d %lld",&N,&ADD);

	table[0] = 0;
	ll tmp_sum = 0;

	for(int i = 1; i <= N; i++){

		scanf("%lld",&table[i]);
		tmp_sum += table[i];

		table[N+i] = table[i];
	}
	BASE = tmp_sum/5;


	for(int i = 1; i <= 2*N; i++){

		table[i] += table[i-1];
	}

	for(int tail = N; tail <= 2*N-1; tail++){
		for(int i = 1; i <= 4; i++){
			for(int k = 1; k <= 2*N-1; k++){

				dp[tail][i][k] = -1;
			}
		}
	}

	ll ans = 0;
	int left,right,mid;
	int left_loc = 2*N,tail;

	for(int start = 1; start <= N; start++){ //0人目の始点

		tail = start+(N-1);
		left = start,right = tail,mid = (left+right)/2;

		while(left <= right){ //和がS/5以上となる最小のインデックスを求める

			if(table[mid]-table[start-1]+ADD >= BASE){

				left_loc = mid;
				right = mid-1;
			}else{

				left = mid+1;
			}
			mid = (left+right)/2;
		}

		for(int next_start = left_loc+1; next_start <= tail; next_start++){

			ans += recursive(tail,1,next_start);
		}
	}

	printf("%lld\n",ans/5); //円順列

	return 0;
}



Measured memory_bytes: 10084
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, x);
	LL a = 100, c = 0;
	until(a >= x) { a += a / 100; c++; }
	OUT(c);
}


Measured memory_bytes: 3636
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a[]=new int[30];
	for(int i=0;i<28;i++)
	    {
		int n=scan.nextInt()-1;
		a[n]++;
	    }
	for(int i=0;i<30;i++)
	    {
		if(a[i]==0)System.out.println(++i);
	    }
    }
}

Measured memory_bytes: 17368
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


int main() {
	int N, K;
	int human;
	int sunake;
	int cnt = 0;
	cin >> N >> K;
	vector<int>sunuke(N,0);
	rep(i, K) {
		cin >> human;
		rep(j, human) {
			cin >> sunake;
			sunuke[sunake - 1] += 1;
		}
	}

	for (int i : sunuke) {
		if (i == 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link relink
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName) {
  if (fileName.empty()) return;
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
  return;
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 2e5 + 100;

int n;
LL siz[N];

int main() {
  srand((int)time(0));
  ios::sync_with_stdio(false);
  cin.tie(0);
  // printf("Hello, world!\n");
  EnableFileIO("");

  cin >> n;
  for (int i = 0; i < n; i++) cin >> siz[i];
  sort(siz, siz + n);

  LL ans = 0, tot = 0;
  for (int i = 0; i < n; i++) {
    if (2 * tot >= siz[i]) {
      ++ans;
    } else {
      ans = 1;
    }
    tot+=siz[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
using P = pair<int, int>;
ll f(ll i, ll n)
{
    if(n < i) return n;
    return f(i, n/i) + n % i;
}
int main()
{
    ll n, s;
    cin >> n >> s;

    for(ll i = 2; i * i <= n; i++)
    {
        if(f(i, n) == s)
        {
            cout << i << endl;
            return 0;
        }
    }
      if(n == s)
    {
        cout << n+1 << endl;
        return 0;
    }
    // n = a*b + c, a < root(n)
    ll ans = 2*n;
    for(ll a = 1; a * a <= n; a++)
    {
        ll b = (n-s+a)/a;
        ll c = s - a;
        if(sqrt(n) < b && f(b, n) == s)
        {
            ans = min(ans, b);
        }
    }
    if(ans < 2*n) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
import sys
S = input()
n = [int(S[i]) for i in range(4)]

sum = 0
for i in range(4):
    sum = sum + n[i]


if sum == 7:
    print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')

else:
    if 4*n[1] == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()

    if 4*n[2] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*n[3] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[3] + n[2])  == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 2*n[1] + 2*n[3] == sum - 7:
        print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2] + n[3])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')

Measured memory_bytes: 3188
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int M = sc.nextInt();
    int D = sc.nextInt();
    int ans = 0;
    for (int i = 22; i <= D; i++) {
      int d1 = i%10;
      int d10 = i/10;
      if (d1 >= 2 && d10 >= 2 && d1*d10 <= M) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int max = Math.max(a, Math.max(b, c));
        if(max==a) {
        	System.out.println(b*c/2);
        }else if(max==b) {
        	System.out.println(a*c/2);
        }else {
        	System.out.println(a*b/2);
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
int main(){
  int a, b, c, tmp;
  scanf("%d %d %d", &a, &b, &c);
  if(b<a){
    tmp=a;
    a=b;
    b=tmp;
  }

  
  if(c<b){
    tmp=b;
    b=c;
    c=tmp;

  }
if(b<a){
    tmp=a;
    a=b;
    b=tmp;
  }
   
  printf("%d %d %d\n", a, b, c);



  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;

int main(){
	cin >> n;
	n -- ;
	ll ans = 0;
	for(int i = 1; i <= n;i ++ ){
		ans += n/i;
	} 
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 200005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;
int a[N];
ll dp[N][2][2];

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

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

	memset(dp, 0x80, sizeof dp);
	dp[0][1][0] = 0;
	for (int i = 1; i <= n; ++i) {
		if (i & 1) {
			chkmax(dp[i][0][0], dp[i - 1][1][0]);
			chkmax(dp[i][0][0], dp[i - 1][1][1]);
			chkmax(dp[i][0][1], dp[i - 1][0][0] + a[i]);
			chkmax(dp[i][1][1], dp[i - 1][1][0] + a[i]);
		} else {
			chkmax(dp[i][0][0], dp[i - 1][0][0]);
			chkmax(dp[i][0][0], dp[i - 1][0][1]);
			chkmax(dp[i][1][0], dp[i - 1][1][0]);
			chkmax(dp[i][1][0], dp[i - 1][1][1]);
			chkmax(dp[i][1][1], dp[i - 1][0][0] + a[i]);
		}
	}

	printf("%lld\n", max(dp[n][!(n & 1)][0], dp[n][!(n & 1)][1]));
	return 0;
}


Measured memory_bytes: 10720
#include <cstdio>
#include <cmath>

int main(void)
{
  int n,i,j;
  int s[1000];
  double m,a;

  for(;;){
    m=0;
    a=0;
    scanf("%d", &n);
    if(n==0) break;

    for(i=0;i<n;i++){
      scanf("%d", &s[i]);
      m+=s[i];
    }

    m=m/n;

    for(j=0;j<n;j++){
      a+=(s[j]-m)*(s[j]-m);
    }

    a=a/n;
    a=sqrt(a);

    printf("%lf\n", a);
  }

  return 0;
}


Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x;
    int y;
} a[200009];
int cmp(node a,node b)
{
    return a.y<b.y;
}
int main()
{
    int n,flag=1,tmp=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i].x>>a[i].y;
    sort(a,a+n,cmp);
    for(int i=0; i<n; i++)
    {
        if(tmp+a[i].x<=a[i].y)
            tmp+=a[i].x;
        else
        {
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

long double a, b;
long double x;

long double deg(long double deg){
  return deg * 180.0 / M_PI;
}


int main(){
  cin >> a >> b >> x;
  long double men = x / a;
  long double sank = a * b;
  long double buf;
  long double ans, tan;
  // printf("%f\n", men);
  if(men >= sank / 2){
    //そんな傾かない
    buf = sank - men;
    tan = 2.0 * buf / (a * a);
    // printf("%f\n", tan);
    ans = atan(tan);
  }else{
    tan  =  b * b / (men * 2);
    ans = atan(tan);
  }
  printf("%Lf\n", deg(ans));
  return 0;
}


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


def solve(N: int, S: str):
    eCount = [0]
    wCount = [0]
    for i in range(N):
        ce = S[i]
        cw = S[i]
        eCount.append(eCount[i] + (1 if ce == "W" else 0))
        wCount.append(wCount[i] + (1 if cw == "E" else 0))
    result = 10 ** 18
    for i in range(N):
        result = min(result, eCount[i] - wCount[i+1] + wCount[-1])
    print(result)
    return


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 27412
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define all(c) (c).begin(),(c).end()

using namespace std;
int in(){int x;cin>>x;return x;}

main(){
    const ll N=1LL<<53;
    while(1){
        ll n;cin>>n;
        if(!n)return 0;
        string s;cin>>s;
        ll k=1;
        for(auto e:s)k=k*2+(e-'0');
        ll st = k;
        ll sisuu = 0;
        while(1){
            ll m = (N-st+k-1)/k;
            if(m>n){
                st+=n*k;break;
            }
            n-=m;
            st = (st+k*m);
            st>>=1;
            k>>=1;
            sisuu++;
            if(!k)break;
        }
        rep(i,12){
            if((1<<(11-i))&sisuu){
                cout<<'1';
            }
            else cout<<'0';
        }
        rep(i,52){
            if(st&(1LL<<(51-i)))cout<<'1';
            else cout<<'0';
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3088
k = int(input())
numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(numbers[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    char a;
    for(int i=0;i<3;i++){
        cin>>a;
        if(a=='1'){
            cout<<9;
        }
        else if(a=='9'){
            cout<<1;
        }
        else cout<<a;
    }
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_D&lang=jp
#include<bits/stdc++.h>
using namespace std;
long n,a,sum,max_value,min_value;
int main(void){
  cin>>n;
  min_value=INT_MAX;
  max_value=INT_MIN;
  for(int i=0;i<n;i++){
    cin>>a;
    sum+=a;
    if(a>max_value)max_value=a;
    if(a<min_value)min_value=a;
  }
  printf("%ld %ld %ld\n",min_value,max_value,sum);
  return 0;
}



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

int main() {
    long long L, R;
    cin >> L >> R;
    if(R - L >= 2018) cout << 0 << endl;
    else {
        long long res = 1001001001;
        for(long long i=L; i<R; ++i) {
            for(long long j=i+1; j<=R; ++j) {
                res = min(res, i * j % 2019);
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    cin >> h;
    ll sum = 0;
    ll temp = 1;
    while(h!=0){
        sum += temp;
        h /= 2;
        temp *= 2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

const int mod = 100000;

int main()
{
	while(true) {
	
		int n, m, s;
	
		scanf("%d%d%d", &n, &m, &s);
		
		if(n == 0 && m == 0 && s == 0)
			break;
	
		n = n * n;
		s -= (0 + (n - 1)) * n / 2;
		m = min(m, s);
	
		static int dp[3001][2001] = {0};
		
		memset(dp[0], 0, 3001 * 2001 * sizeof(int));
	
		for(int i = 1; i <= m; ++i)
			dp[i][i] = 1;
	
		for(int i = 1; i < n; ++i) {
		
			for(int x = 1; x <= m - i; ++x) {
	
				for(int sum = s; sum > x; --sum)
					dp[sum][x] = (dp[sum - 1][x - 1] + dp[sum - x][x]) % mod;

				for(int sum = x; sum > 0; --sum)
					dp[sum][x] = (dp[sum - 1][x - 1]) % mod;
			}	
		}
		
		int ans = 0;
		
		for(int i = 1; i <= m - (n - 1); ++i) {
			ans += dp[s][i];
			ans %= mod;
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 24492
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define P(x) cout << (x) << endl

int main(void){  
  int n,m;
  while(cin>>n>>m){
    if(!n) break;
    int ch[102] = {0};
    char a;
    REP(h,m){
      cin >> a;
      if(a == 'A'){
        FOR(i,1,n+1){
          if(ch[i] == 0){
            ch[i] = 'A';
            break;
          }
        }
      }else if(a == 'B'){
        bool f=false;
        for(int i=n; i>0; i--){
          if(ch[i]==0 && ch[i+1] != 'A' && ch[i-1] != 'A'){
            ch[i] = 'B';
            f = true;
            break;
          }
        }
        if(!f){
          FOR(i,1,n+1){
            if(ch[i] == 0){
              ch[i] == 'B';
              break;
            }
          }
        }
      }else if(a == 'C'){
        int c=-1;
        FOR(i,1,n+1){
          if(ch[i] != 0){
            c = i;
            break;
          }
        }
        if(c==-1){
          ch[(n%2)?(n+1)/2:n/2+1] = 'C';
        }else{
          while(c<n+1){
            if(ch[c+1]==0&&c<n){
              ch[c+1] = 'C';
              break;
            }else if(ch[c-1]==0&&c>1){
              ch[c-1] = 'C';
              break;
            }
            c++;
          }
        }
      }else if(a == 'D'){
        int maxi,max=0;
        FOR(i,1,n+1){
          if(ch[i] == 0){
            int l=100,r=100,mi;
            for(int j=i-1; j>0; j--)
              if(ch[j] != 0){
                l = i-j;
                break;
              }
            for(int j=i+1; j<n+1; j++)
              if(ch[j] != 0){
                r = j-i;
                break;
              }
            mi = min(l,r);
            if(mi>max){
              maxi = i;
              max = mi;
            }
          }
        }
        ch[maxi] = 'D';
      }
    }
    for(int i=1; i<n+1; i++){
      if(ch[i] == 0) cout <<"#";
      else printf("%c",ch[i]);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
	  int n;
	  cin>>n;
	  if(n==22)
	    cout<<"Christmas Eve Eve Eve";
	  if(n==23)
	    cout<<"Christmas Eve Eve";
	  if(n==24)
	    cout<<"Christmas Eve";
	  if(n==25)
	    cout<<"Christmas";
	  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    int a=n/100;
    int b=n%100;
    bool k;
    if(a<=12&&1<=a)k=true;
    else k=false;
    bool l;
    if(b<=12&&1<=b)l=true;
    else l=false;
    if(k==true&&l==true)cout<<"AMBIGUOUS"<<endl;
    else if(k==true)cout<<"MMYY"<<endl;
    else if(l==true)cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
    return 0;
}









Measured memory_bytes: 256
def main():
    N,A,B = map(int,input().split())

    # X = NAB[0]
    # a = 0
    # b = 0
    #
    # while X >= 0:
    #     X -= NAB[1]
    #     a += 1
    #     # print("go")
    #
    #     if X <= 0:
    #         break
    #
    #     X -= NAB[2]
    #     b += 1
    #
    # # print(a)
    # # print(b)
    #
    # if b < 0:
    #     print(NAB[1]*a - abs(X))
    # else:
    #     print(NAB[1]*a)

    b = 0

    tm = N // (A + B)*A
    amari = N % (B + A)
    tm += min(amari,A)

    print(tm)

    # if NAB[1] == 0:
    #     b = 0
    # elif NAB[2] == 0:
    #     b = NAB[1]
    #
    # elif NAB[0] < NAB[1]+NAB[2]:
    #     if NAB[0] < NAB[1]:
    #         b = NAB[0]
    #     else:
    #         b = NAB[1]
    #
    # else:
    #     tm = NAB[0]//(NAB[1]+NAB[2])
    #     amari = NAB[0] % (NAB[1]+NAB[2])
    #
    #     # print(tm)
    #     if NAB[1] < amari:
    #         b = (tm*NAB[1])+ NAB[1]
    #     else:
    #         b = (tm*NAB[1])+ amari

    # print(b)



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e5+5;
const int INF = 1e9;

int n;
int a[N];
struct node{
	int val,l,r;
}tree[N*40];
int rt[N][2],tot;
int f[N][2];
bool key[N];

void add(int &now,int qf,int l,int r,int x,int v){
	tree[now=++tot]=tree[qf];
	tree[now].val=max(tree[now].val,v);
	if (l==r)return;
	int mid=(l+r)/2;
	if (x<=mid)add(tree[now].l,tree[qf].l,l,mid,x,v);
	else add(tree[now].r,tree[qf].r,mid+1,r,x,v);
}

int getmax(int now,int l,int r,int x,int y){
	if (!now)return -INF;
	if (x<=l&&r<=y)return tree[now].val;
	int mid=(l+r)/2,ret=-INF;
	if (x<=mid)ret=getmax(tree[now].l,l,mid,x,y);
	if (y>mid)ret=max(ret,getmax(tree[now].r,mid+1,r,x,y));
	return ret;
}

bool check(int i,int cx,int hx,int cy,int hy,int q){
	int v=cx+q-cy;
	if (v<0)return 0;
	if (i>n)return v==0;
	int tmp=getmax(rt[i][v&1],1,n,hy+1,n);
	tmp=max(tmp,0);
	return tmp>=v;
}

int main(){
	n=get();
	fo(i,1,n)a[i]=get();
	int q=0,mx=0;
	fo(i,1,n)
	if (a[i]>mx)mx=a[i],q++,key[i]=1;
	tree[0].val=-INF;
	fd(i,n,1){
		fo(c,0,1){
			int c_=c;
			int v=getmax(rt[i+1][c],1,n,a[i],n);
			if (v>-INF){
				if (key[i])v+=2;else v++;
			}
			if(!key[i])c_^=1;
			f[i][c_]=v;
		}
		if (key[i])f[i][0]=max(f[i][0],2);else f[i][1]=max(f[i][1],1);
		add(rt[i][0],rt[i+1][0],1,n,a[i],f[i][0]);
		add(rt[i][1],rt[i+1][1],1,n,a[i],f[i][1]);
	}
	int cx=0,cy=0,hx=0,hy=0;
	if (tree[rt[1][q&1]].val>=q){
		fo(i,1,n){
			//0
			int cx_,hx_,q_=q-key[i];
			if (hx<a[i])hx_=a[i],cx_=cx+1;else hx_=hx,cx_=cx;
			if (check(i+1,cx_,hx_,cy,hy,q_)||check(i+1,cy,hy,cx_,hx_,q_)){
				putchar('0');
				cx=cx_,hx=hx_,q=q_;
				continue;
			}
			//1
			putchar('1');
			if (hy<a[i])hy=a[i],cy++;
			q=q_;
		}
	}
	else printf("-1\n");
	return 0;
}

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

struct UnionFind{
    vector<int> par;

    UnionFind(int n = 0){
        par.resize(n);
        for(int i = 0 ; i < n ; ++i){
            par[i] = i;
        }
    }

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        par[x] = y;
        return;
    }
};

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

    vector<int> a(n);
    vector<int> prev_id(100001, -1);
    UnionFind uf(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
        int t = a[i];
        for(int j = 2 ; j * j <= t ; ++j){
            if(t % j == 0){
                if(prev_id[j] != -1){
                    uf.unite(i, prev_id[j]);
                }
                prev_id[j] = i;
                while(t % j == 0){
                    t /= j;
                }
            }
        }
        if(t > 1){
            if(prev_id[t] != -1){
                uf.unite(i, prev_id[t]);
            }
            prev_id[t] = i;
        }
    }

    vector< vector<int> > v(n);
    for(int i = 0 ; i < n ; ++i){
        v[uf.root(i)].emplace_back(a[i]);
    }

    for(int i = 0 ; i < n ; ++i){
        sort(v[i].begin(), v[i].end());
    }

    bool flag = true;
    vector<int> id(n);
    int prev = -1;
    for(int i = 0 ; i < n ; ++i){
        flag &= (prev <= v[uf.root(i)][id[uf.root(i)]]);
        prev = v[uf.root(i)][id[uf.root(i)]];
        ++id[uf.root(i)];
    }

    cout << flag << endl;

    return 0;
}


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int h, n, sum = 0 ;
  cin >> h >> n;
  vector<int> f (n);
  for (auto &it : f) cin >> it, sum += it;
  cout << ((sum >= h) ? "Yes" : "No") << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3692
#
W, H, x, y = map(int, input().split())

#x,yが図形の半分の位置かどうか
if x == W/2 and y == H/2:
  menseki = W*H/2
  print(menseki,1)
else:
  menseki = W*H/2
  print(menseki,0)
  

Measured memory_bytes: 2940
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int i = sc.nextInt();

    System.out.println(N - i + 1);
    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  long long n;
  cin>>n;
  if(n&1||n==0){cout<<0;return 0;}
  else{
    long long ans = 0;
    n/=2;
    while(n){
    ans+=n/5;
      n/=5;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int N=2e5+2;
int cnt[N][2];
bool check[N];
vector<int> adj[N];
queue<int> lis;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,i,j,k,l,m;
  string s;
  cin>>n>>m>>s;
  s=" "+s;
  for(i=1;i<=m;i++){
    cin>>j>>k;
    adj[j].push_back(k);
    adj[k].push_back(j);
    cnt[k][(int)(s[j]-'A')]++;
    cnt[j][(int)(s[k]-'A')]++;
  }
  for(i=1;i<=n;i++){
    if(!cnt[i][0]||!cnt[i][1]){
      check[i]=true;
      lis.push(i);
    }
  }
  while(lis.size()){
    l=lis.front();
    lis.pop();
    for(i=0;i<adj[l].size();i++){
      j=adj[l][i];
      cnt[j][(int)(s[l]-'A')]--;
      if(!cnt[j][(int)(s[l]-'A')]&&!check[j]){
        check[j]=true;
        lis.push(j);
      }
    }
  }
  for(i=1;i<=n;i++){
    if(!check[i]){
      cout<<"Yes";
        return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 12564
import java.util.Scanner;

public class Main {

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

		    int max = 0;
		    int max_num =0;
		    int max2 = 0;
		    int n = sc.nextInt();
		    for(int i=0; i<n; i++) {
		    	int a = sc.nextInt();
		    	if(a>max) {
		    		max = a;
		    		max_num = i;
		    	}else {
		    		if(a>=max2) {
		    			max2 = a;
		    		}
		    	}
		    }
		    for(int i=0; i<n; i++) {
		    	if(i==max_num) {
		    		System.out.println(max2);
		    	}else {
		    		System.out.println(max);
		    	}
		    }
		    sc.close();

	}
}

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

const int maxn = 1e5 + 10;
vector<int> V[maxn];

int main() {
	int n, m, ans = 0;
	cin >> n >> m;
	
	int d, v;
	for (int i = 0; i < n; i++) {
		cin >> d >> v;
		if (d <= m) {
			V[m - d + 1].push_back(v);
		}
	}
	priority_queue<int> Q;
	for (int i = m; i >= 1; i--) {
		if (V[i].size() > 0) {
			for (int j = 0; j < V[i].size(); j++) {
				Q.push(V[i][j]);
			}
		}
		while (!Q.empty()) {
			ans += Q.top();
			Q.pop();
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5632
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
ll n, k, a[N],res;
vector<ll>v;
int solve()
{
    cin>>n;
    while(n)
    {
        ll k = n/26;
        ll m = (n-(k*26));
        if(m==0) 
        {
            k--;
            m=26;
        }
        v.pb(m);
        n = k;
    }
    reverse(v.begin(), v.end());
    for(auto u:v)
    {
        printf("%c", u+'a'-1);
    }
    printf("\n");
    return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int ret = solve();
    return 0;
}
/*

*/


Measured memory_bytes: 3764
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  	int n;
  	cin>>n;
  	long ans = 0;
  	for(int i =0;i<=n;i++){
  	    if(i%3!=0&&i%5!=0){
  	        ans+=i;
  	    }
  	}
  	cout<<ans<<endl;
 	return 0; 
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals("+")) {
				System.out.println(a + b);
			}
			if (op.equals("-")) {
				System.out.println(a - b);
			}
			if (op.equals("*")) {
				System.out.println(a * b);
			}
			if (op.equals("/")) {
				System.out.println(a / b);
			}
			if (op.equals("?")) {
				break;
			}
		}
	}
}



Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    while(true){
        int n;
        cin >> n;
        if (n==0) break;
        vector<string> s(n);
        string y="aiueo";
        rep(i,n){
            string u;
            cin >> u;
            int t=0;
            s[i].push_back(u.at(0));
            rep(j,5){
                if (u.at(0)==y.at(j)) t=1;
            }
            rep(j,u.size()-1){
                if (t==1) s[i].push_back(u.at(j+1));
                t=0;
                rep(k,5){
                    if (u.at(j+1)==y.at(k)) t=1;
                }
            }
        }
        int ans=-1;
        bool www=false;
        rep(i,n){
            for(int j=i+1;j<n;j++){
                if (s[i]==s[j]) {
                    cout << -1 << endl;
                    www=true;
                }
                if (www) break;
            }
            if (www) break;
        }
        rep(k,51){
            bool p=true;
        rep(i,n){
            for (int j=i+1;j<n;j++){
                bool x=true;
                rep(c,k+1){
                    // if (c==s[i].size() || c==s[j].size()) break;
                    if (s[i][c]!=s[j][c]){
                        x=false;
                        break;
                    }
                }
                if (x){
                    p=false;
                    break;
                }
                }
            if (!p) break;
        }
        if (p) {ans=k+1;break;}
        }
        if (!www) cout << ans << endl;
    }
}




Measured memory_bytes: 3152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::BTreeMap;

fn main() {
    input! {
        n: usize,
        aa: [u64;n]
    }
    let mut m = BTreeMap::new();
    for a in &aa {
        *m.entry(a).or_insert(0) += 1u64;
    }
    let v: Vec<(&u64,u64)> = m.into_iter().filter(|&(_k,v)| v >= 2u64)
                                   .rev().take(2).collect();
    if v.len() < 2 {
        println!("0");
    } else if v[0].1 >= 4 {
        println!("{}", v[0].0 * v[0].0);
    } else {
        println!("{}", v[0].0 * v[1].0);
    }
}


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

int main() 
{
int a,b;
  cin >> a >> b;
int sum = 0;
  rep(i,b){
   int t;
    cin >> t;
    sum = sum + t;
  }
  if(a-sum < 0){
   cout << -1 << endl; 
  }else{
   cout << (a-sum) << endl; 
  }
  
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main() {
  long long H, W;
  std::cin >> H >> W;
  if(H == 1 || W == 1) {
    std::cout << "1";
    return 0;
  }
  long long prod = H * W;
  if(prod%2)
    std::cout << prod/2+1;
  else 
    std::cout << prod/2;
  return 0;
}

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

    val sum = calculateSumOfCombination(K, S)

    println(sum)
}

fun calculateSumOfCombination(K :Int, S: Int): Int {
    var sum = 0
    for (x in 0 .. K) {
        for (y in 0 .. K) {
            if (S - x - y in 0..K) sum ++
        }
    }
    return sum
}

Measured memory_bytes: 37876
#include <stdio.h>
#include <string.h>
int main(){
  char w[11],t[1001];
  int c=0,i;
  scanf("%s",w);
  while(scanf(" %s",t)){
    if (!strcmp(t,"END_OF_TEXT"))break;
    i=0;
    while(t[i]!='\0'){
      if('A'<=t[i]&&'Z'>=t[i])t[i]+='a'-'A';
      i++;
    }
    if (!strcmp(t,w))c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 548
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def dfs(s, count):
    if len(s) == n:
        print(s)
        return

    for z in range(count + 1):
        dfs(s + a[z], count + 1 if z == count else count)


dfs("", 0)





Measured memory_bytes: 4340
#include<iostream>
using namespace std;
int main() {

	string s, t;
	cin >> s;
	cin >> t;
	int i;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == t[i]) {

		}
		else {
			cout << "No\n";
			return 0;
		}
	}

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

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(){
  ll N; cin>>N;

  ll cumu[N+1];
  cumu[0] = 0LL;
  for(int i=1;i<=N;++i){
    cin >> cumu[i];
    cumu[i] += cumu[i-1];
  }
  int idx_lft = 1; // 1 <= x <= idx_lft
  int idx_mid = 2; // idx_lft < x <= idx_mid
  int idx_rgt = 3; // idx_mid < x <= idx_rgt
                   // idx_rgt < x <= N
  ll ans = 1e18;
  while(idx_mid<N){
    ll P=-1,Q;
    while(idx_lft<idx_mid){
      ll P_temp = cumu[idx_lft];
      ll Q_temp = cumu[idx_mid] - cumu[idx_lft];
      if(P>0 && abs(P-Q)<abs(P_temp-Q_temp) ){
        break;
      }else{
        P = P_temp;
        Q = Q_temp;
        idx_lft = min(idx_lft+1,idx_mid);
      }
    }
    --idx_lft;
    ll R=-1,S;
    while(idx_rgt<N){
      ll R_temp = cumu[idx_rgt] - cumu[idx_mid];
      ll S_temp = cumu[N] - cumu[idx_rgt];
      if(R>0 && abs(R-S)<abs(R_temp-S_temp)){
        break;
      }else{
        R = R_temp;
        S = S_temp;
        idx_rgt = min(idx_rgt+1,(int)N);
      }
    }
    --idx_rgt;
    ll cand = abs(max({P,Q,R,S}) - min({P,Q,R,S}) );
    chmin(ans,cand);
    ++idx_mid;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 5168
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
bool cmp(const pii &a,const pii &b){
    return a.x+a.y<b.x+b.y;
}
LL fra[200005];
LL inv[200005];
int mod=1e9+7;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL C(int a,int b){
    return fra[a]*inv[b]%mod*inv[a-b]%mod;
}
int main(){
    fra[0]=1;
    for(int i=1;i<=200000;i++)
    fra[i]=fra[i-1]*i%mod;
    inv[200000]=f_pow(fra[200000],mod-2);
    for(int i=200000;i>=1;i--){
        inv[i-1]=inv[i]*i%mod;
    }
    int h,w,n;
    scanf("%d %d %d",&h,&w,&n);
    pii p[3005];
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        p[i]=mp(x,y);
    }
    p[n]=mp(h,w);
    sort(p,p+n+1,cmp);
    LL dp[3005];
    for(int i=0;i<=n;i++){
        dp[i]=fra[p[i].x+p[i].y-2]*inv[p[i].x-1]%mod*inv[p[i].y-1]%mod;
        for(int j=0;j<i;j++){
            if(p[j].x<=p[i].x&&p[j].y<=p[i].y){
                dp[i]-=dp[j]*C(p[i].x-p[j].x+p[i].y-p[j].y,p[i].x-p[j].x);
                dp[i]=(dp[i]%mod+mod)%mod;
            }
        }
    }
    printf("%lld\n",dp[n]);
}


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


int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int* x = new int[N];
  int* y = new int[N];
  int* wenemy = new int[W+1];
  int* hmm = new int [W+1];
 
  for(int i = 0; i <= W; i++){
    wenemy[i] = 0;
  }
  for(int i = 0 ; i < N; i++){
    cin >> x[i];
    cin >> y[i];
    if(wenemy[x[i]] < y[i])  wenemy[x[i]] = y[i]; 
  }
  int current = 0;
  
  for(int i = W; i >= 0; i--){
    hmm[i] = current;
    if(current < wenemy[i])current = wenemy[i];
  }
  int minpppp = 2000000;
  for(int i = 0; i <= W;i++){
    minpppp = min(minpppp,hmm[i]+i);
  }
  cout << minpppp << endl;
  
  return 0;
}



Measured memory_bytes: 4684
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b % a == 0) System.out.println(a + b);
        else System.out.println(b - a);
    }
}

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

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static int[] hs;
        static long ans;
        static void Main(string[] args)
        {
            int[] nm = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nm[0];
            int m = nm[1];
            char[,] An = new char[n, n];
            for (int i = 0; i < n; i++)
            {
                var hoge = ReadLine();
                for (int j = 0; j < n; j++)
                {
                    An[i, j] = hoge[j];
                }
            }
            char[,] Bn = new char[m, m];
            for (int i = 0; i < m; i++)
            {
                var hoge = ReadLine();
                for (int j = 0; j < m; j++)
                {
                    Bn[i, j] = hoge[j];
                }
            }

            //探索
            //探索開始点 [i,j]
            for (int i = 0; i < n-m+1; i++)
            {
                for (int j = 0; j < n-m+1; j++)
                {
                    bool roop = true;
                    //照合処理
                    //見つかったら return;
                    //照合失敗時点で continue;
                    for (int k = 0; k < m; k++)
                    {
                        if (!roop) break;
                        for (int l = 0; l < m; l++)
                        {
                            if (An[i + k, j + l] != Bn[k, l]) { roop = false;  break; }
                            else
                            {
                                if (k == m - 1 && l == m - 1)
                                {
                                    Console.WriteLine("Yes");
                                    return;
                                }
                            }
                        }
                    }


                }
            }
            Console.WriteLine("No");

        }
    }
}



Measured memory_bytes: 13268