akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef vector< pair< ll,ll > > ii;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) (c).begin() , (c).end()
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    map< ll, ll> mp,v;

    cin >> n >> m;
    ll penalty = 0,ac=0;
    for(int i = 0;i<m;i++)
    {
        int x;
        string s;
        cin>>x>>s;
        if(v[x]==0)
        {
            if(s=="WA")
            {
                mp[x]++;
            }
            else
            {
                v[x] = 1;
                ac++;
                penalty += mp[x];
            }
        }
    }
    cout << ac << " " << penalty << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int maxn=100;
int cnt[10001];
int main()
{
	int n;
	cin>>n;
	for(int x=1;x<=maxn;x++)
	{
		for(int y=1;y<=maxn;y++)
		{
			for(int z=1;z<=maxn;z++)
			{
				int num=x*x+y*y+z*z+x*y+y*z+x*z;
				if(num<=n) cnt[num]++;
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<cnt[i]<<endl;	
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,ans,rm=hell,rl,mx;
vii v;
multiset<int> stl,str;
bool cmp(pii a,pii b){
    if(a.y!=b.y) return a.y<b.y;
    else return a.x<b.x;
}
void solve(){
    cin>>n;
    rep(i,0,n){
        int l,r;
        cin>>l>>r;
        v.pb({l,r});
        stl.insert(l);
        str.insert(r);
        mx=max(mx,r-l+1);
    }
    sort(all(v));
    for(auto i:v){
        stl.erase(stl.find(i.x));
        str.erase(str.find(i.y));
        rm=min(rm,i.y);
        rl=max(rl,i.x);
        if(sz(stl)){
            ans=max(ans,max(0LL,rm-rl+1)+max(0LL,(*str.begin())-*(--stl.end())+1));
        }
    }
    for(auto i:v) stl.insert(i.x),str.insert(i.y);
    sort(all(v),cmp);
    rm=hell,rl=0;
    for(auto i:v){
        stl.erase(stl.find(i.x));
        str.erase(str.find(i.y));
        rm=min(rm,i.y);
        rl=max(rl,i.x);
        if(sz(stl)){
            ans=max(ans,max(0LL,rm-rl+1)+max(0LL,(*str.begin())-*(--stl.end())+1));
        }
    }
    vii vv;
    int f=0,L=0,R=hell;
    for(auto i:v){
        if(f==0 and i.y-i.x+1==mx) f=1;
        else vv.pb(i);
    }
    for(auto i:vv) L=max(L,i.x),R=min(R,i.y);
    ans=max(ans,mx+max(0LL,R-L+1));
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n; cin >> n;
  struct tup {
    int fi, sc, th;
    tup() {}
    tup(int fi, int sc, int th):
      fi(fi), sc(sc), th(th) {}
    bool operator<(tup &t) {
      return this->fi < t.fi;
    }
  };
  vector<tup> a(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i].fi >> a[i].sc;
    a[i].th = (i < n);
  }
  sort(all(a));
  int ans = 0;
  set<int> s;
  for (auto &i : a) {
    if (i.th) s.insert(i.sc);
    else {
      auto it = s.lower_bound(i.sc);
      if (it != s.begin()) {
        it = prev(it);
        s.erase(it);
        ans++;
      }
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main() {
  int x, y;
  cin >> x >> y;
  if(y % 2 != 0) cout << "No" << endl;
  else {
    int a = (y - 2 * x) / 2;
    if(a >= 0 && a <= x) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
      

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

using namespace std;

int main()
{
 int n;
 cin>>n;
 int arr[n];
 for(int i=1; i<=n; i++) {
    cin>>arr[i];
 }
 int odd =0;
 for(int i=1; i<=n; i++) {
    if(i%2 !=0 && arr[i] % 2 !=0) odd++;
 }
 cout<<odd;
return 0;
}


Measured memory_bytes: 3532
//***Wherever you are, and whatever you do, be in love.***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll n,ans=0;
	cin>>n;

	ll nn=n;
	for(ll i=2;i<=sqrt(nn);i++){
		if(n%i!=0) continue;
		ll c1=0;
		while(n%i==0){
			c1++;
			n/=i;
		}
		ll c3=0;
		while(c1>2*(c3+1)) {
			c3++;
			c1-=c3;
		}
		c3++;
		ans+=c3;
		//cout<<i<<" "<<c1<<"\n";
	}
	if(n>1) ans++;
	cout<<ans;
}

Measured memory_bytes: 3680
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <list>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iostream>
#include <stdlib.h>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
using namespace std;

long long a, b, c;
vector<long long>myvec;

int main(){
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>a>>b>>c;
myvec.pb(a), myvec.pb(b), myvec.pb(c);
sort(myvec.begin(), myvec.end());
if(myvec[2]%2 == 0)
	cout<<0<<endl;
else
	cout<<myvec[0]*myvec[1]*(myvec[2]/2+1)-myvec[0]*myvec[1]*(myvec[2]/2)<<endl;


return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int h, w, d;
    cin >> h >> w >> d;
    vector<pii> xy(h*w+1);
    REP(i,h) REP(j,w) {
        int a; cin >> a;
        xy[a] = make_pair(i,j);
    }
    auto dist = [&](const int a,const int b) {
        return abs(xy[a].first - xy[b].first) + abs(xy[a].second - xy[b].second);};

    vector<int> vd(h*w+1);
    FOR(i,d+1,h*w+1) {
        vd[i] = vd[i-d] + dist(i,i-d);
        // cerr << i << " " << dist(i,i-d) << endl;
    }
    
    // REP(i,vd.size()) cerr << vd[i] << " ";
    // cerr << endl;

    int q; cin >> q;
    REP(i,q) {
        int l, r;
        cin >> l >> r;
        OUT(vd[r] - vd[l])
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll a, b;
	cin >> a >> b;
	if (a == 1)a += 13;
	if (b == 1)b += 13;
	cout << (a > b ? "Alice" : a == b ? "Draw" : "Bob") << endl;
	return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

struct D {
    int row, col, step;
}

int calc(string[] g) {
    int rows = cast(int)g.length;
    int cols = cast(int)g[0].length;
    bool inp(int r, int c) { return 0 <= r && r < rows && 0 <= c && c < cols; }

    auto q = new Queue!(D);
    foreach (r; 0..rows) foreach (c; 0..cols) {
        if (g[r][c] == '#') {
            q.push(D(r, c, 0));
        }
    }

    int ans = 0;
    auto t = new int[][](rows, cols);
    auto dxy = [0, 1, 0, -1];
    while (!q.empty) {
        auto d = q.pop();
        if (t[d.row][d.col]++) continue;

        ans = max(ans, d.step);
        for (int i = 0; i < dxy.length; i++) {
            int r = d.row + dxy[i];
            int c = d.col + dxy[$-1-i];
            if (inp(r, c)) q.push(D(r, c, d.step + 1));
        }
    }
    return ans;
}

void main() {
    int h, w; scan(h, w);
    string[] g;
    foreach (_; 0..h) g ~= read!string;
    writeln(calc(g));
}

class Queue(T) {
    private DList!(T) _dlist;
    private ulong _size;

    this(T[] ary) {
        _dlist = DList!(T)(ary);
        _size = ary.length;
    }

    this() {
        _dlist = DList!(T)();
        _size = 0;
    }

    void push(T x) {
        _dlist.insertBack(x);
        _size++;
    }

    T pop() {
        T x = _dlist.front;
        _dlist.removeFront();
        _size--;
        return x;
    }

    @property T front() {
        return _dlist.front;
    }

    @property ulong size() {
        return _size;
    }

    @property bool empty() {
        return _dlist.empty;
    }
}


Measured memory_bytes: 152316
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

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

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N;
 
  cin >> N;
  
  vector<int> H(N);
  int nmax=0;
  int n=0;
  cin >> H[0];
  REP2(i,1,N){
    cin >> H[i];
    if(H[i]<=H[i-1]){
      n++;
    }
    else
    {
      chmax(nmax,n);
      n=0;
    }
  }
  chmax(nmax,n);
  
  cout << nmax << endl;
  
  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}





Measured memory_bytes: 640
n = int(input())
s = input()
t = 1
if n % 2 == 0:
	n2 = int(n / 2)
	for i in range(n2):
		if s[i] != s[i+n2]:
			t = 0
else:
	t = 0
if t == 1:
	print("Yes")
else:
	print("No")

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  // long n, m, h, w, x, y;
  long a, b;
  // long ans = 0;
  // vector<int> a, b;
  // cin >> n >> m;
  // rep(i, 1, n) {
  //   int a0, b0;
  //   cin >> a0 >> b0;
  //   a.pb(a0);
  //   b.pb(b0);
  // }
  cin >> a >> b;
  if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
  // for (const auto & a0: a) {
  //
  // }

  // cout << ans << endl;
  // cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,k;
    cin>> n>> x>> t;
    if(n%x==0)
    {
        k= (n/x)*t;
        cout<< k;
    }
    else
    {
        k=(n/x)*t+t;
        cout<< k;
    }
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>; 

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)% 2== 0) cout<<(b-a)/2<<endl;
    else{
        ll c = min(n-b+1,a);
        cout<<c+(b-a-1)/2<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj0100().doIt();
	}
	class aoj0100{
		void doIt(){
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				boolean over = false;
				long num[] = new long [4001];
				boolean num2[] = new boolean[4001];
				int ban[] = new int[n];
				long kati[] = new long[n];
				long cnt[] = new long[n];
				for(int i = 0;i < n;i++){
					ban[i] = sc.nextInt();
					kati[i] = sc.nextLong();
					cnt[i] = sc.nextLong();
				}
				for(int i = 0;i < n;i++){
					num[ban[i]] = num[ban[i]] + (kati[i] * cnt[i]);
				}
				for(int i = 0;i < n;i++){
					if(num[ban[i]] >= 1000000){
						if(!num2[ban[i]]){
							System.out.println(ban[i]);
							num2[ban[i]] = true;
						}
						over = true;
					}
				}
				if(!over)System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 27244
#include <stdio.h>

int main(void){
    int i, n;
    int count = 0;
    char s[1000000] = {'\0'};

    scanf("%d", &n);
    scanf("%s", s);

    for(i = 0; i < n; i++){
        if(s[i] != s[i+1]) count++;
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define PB push_back
#define FO(i,a,b) for (int i = a; i <= b; i++)
#define FOb(i,a,b) for(int i=b;i>=a;i--)
#define vi vector<int>
#define vulli vector<unsigned long long int>
using namespace std;
typedef unsigned long long int ulli;
void solve()
{   
    int s,i = 0;
    cin >> s;
    string str;
    cin >> str;
    if(s%2 == 0)
        for(i;i<s/2;i++)
            if(str[i] != str[(s/2)+i])
                break;
    if(i == s/2 && s%2 == 0)
        cout << "Yes";
    else
        cout << "No";
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    ulli t=1;
   // cin>>t;   
    while(t--){ solve(); cout<<"\n"; }
    return 0;
}


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

int main(){
    int n;cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }

    int ans[n];
    int search = 1;
    int index = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(arr[j] == search){
                ans[index] = j+1;
                search++;
                index++;
                break;
            }
        }
    }

    for(int i=0;i<n;i++){
        printf("%d ",ans[i]);
    }
}

Measured memory_bytes: 4504
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
		printf("a < b");
	}
	if(a>b){
		printf("a > b");
	}
	if(a==b){
		printf("a == b");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
ll a;
ll ans;
int main(){
	cin>>a;
	ans=a+a*a+a*a*a;
	cout<<ans;
	return 0;
}


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

int main() {
    string s;
    cin>>s;

    if(s.find('a')!=string::npos and s.find('b')!=string::npos and s.find('c')!=string::npos){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int dp[20][20];

int calc(int N, string S, int b) {
	string R = "", B = "";
	for(int i = 0; i < N; ++i) {
		if((b >> i) & 1) {
			R += string(1, S[i]);
		} else {
			B += string(1, S[i]);
		}
	}
	// cout << R << "," << B << endl;
	reverse(ALL(S));
	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j <= i; ++j) {
			if(j < R.size() && S[i] == R[j]) {
				dp[i+1][j+1] += dp[i][j];
			}
			if(i - j < B.size() && S[i] == B[i-j]) {
				dp[i+1][j] += dp[i][j];
			}
		}
	}
	return dp[N][R.size()];
}

signed main(){
	int N;
	string S;
	cin >> N >> S;

	int res = 0;
	for(int b = 0; b < 1 << N; ++b) {
		res += calc(N, S, b);
	}
	cout << res << endl;

	return 0;
}


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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(0)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)

string s, t;
int n, m;
int lcs[3005][3005];
vector <char> v;

int main()
{
	cin >> s;
	cin >> t;
	n=s.length();
	m=t.length();
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=m; ++j)
		{
			lcs[i][j]=max(max(lcs[i-1][j], lcs[i][j-1]), (s[i-1]==t[j-1] ? lcs[i-1][j-1]+1 : 0));
			debug
			{
				fprintf (err, "i=%d j=%d lcs[i][j]=%d\n", i, j, lcs[i][j]);
			}
		}
	}
	int x=n;
	int y=m;
	while (lcs[x][y])
	{
		while (lcs[x-1][y]==lcs[x][y])
		{
			--x;
		}
		while (lcs[x][y-1]==lcs[x][y])
		{
			--y;
		}
		debug
		{
			fprintf (err, "x=%d y=%d\n", x, y);
		}
		v.eb(s[x-1]);
		--x;
		--y;
	}
	int l=v.size();
	for (int i=l-1; i>=0; --i)
	{
		fprintf (out, "%c", v[i]);
	}
	return 0;
}
/*
*/




Measured memory_bytes: 35456
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var t = new int[3];
            for (var i = 0; i < input.Length; i++) t[i] = int.Parse(input[i]);
            var sum = t[0] + t[1] + t[2];

            var min = int.MaxValue;

            for (var i = 0; i < 3; i++)
            {
                var tmp = sum - t[i];
                if (tmp < min) min = tmp;
            }
            Console.WriteLine(min);

        }
    }
}


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

int main(){
	int N,M; cin>>N>>M;
	int S[M]; char C[M];
	rep(i,M){ cin>>S[i]>>C[i]; --S[i]; }
	rep(i,1000){
		string A = to_string(i);
		if(A.size() != N) continue;
		bool ok = true;
		rep(j,M) if(A[S[j]] != C[j]){ ok = false; break; }
		if(ok){ cout<<i<<endl; return 0; }
	}
	puts("-1");
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
 
int C[1000];
 
int main() {
	string s;
	cin >> s;
	LL ans = 0;
	for (int i = 0; i < s.size(); i++) {
		C[s[i]]++;
	}
	for (int i = 'a'; i <= 'z'; i++) {
		//if (C[i] >= 2)ans -= LL(C[i] * (C[i] - 1) / 2);
		ans += (s.size() - C[i])*C[i];
	}
	cout << ans / 2 + 1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#define swap(a,b) a^=b^=a^=b

	int ans = 8;
	int A[31] = {0} ;
	int B[] = {0,1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3} ;

	void a(){
    	swap(A[1],A[24]);
    	swap(A[4],A[27]);
    	swap(A[7],A[30]);
    	swap(A[10],A[21]);
    	swap(A[16],A[18]);
    return;
	}
 
	void b(){
    	swap(A[3],A[22]);
    	swap(A[6],A[25]);
    	swap(A[9],A[28]);
    	swap(A[12],A[19]);
    	swap(A[13],A[15]);
	}
 
	void c(){
    	swap(A[1],A[28]);
    	swap(A[2],A[29]);
    	swap(A[3],A[30]);
    	swap(A[15],A[16]);
    	swap(A[19],A[21]);
	}
 
	void d(){
    	swap(A[7],A[22]);
    	swap(A[8],A[23]);
    	swap(A[9],A[24]);
    	swap(A[13],A[18]);
    	swap(A[10],A[12]);
	}


	void solve(int num){
  		int cnt=0, i;
  		
  		for(i=1;i<31;i++){
    	if(A[i]==B[i]) cnt++;
  		}
  		if(cnt==30) ans=num;
  		
  		if(ans<=num) return;
  	
  		a();solve(num+1);a();
 		b();solve(num+1);b();
		c();solve(num+1);c(); 
  		d();solve(num+1);d();
	}

	int main(){
		int n, j, k;
		scanf("%d", &n);
	
		for(j=0; j<n; j++){
			for(k=1; k<31; k++){
				scanf("%d", &A[k]);
			}		
			ans = 8;
			solve(0);
			printf("%d\n", ans);
		}
		return 0;
	}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int K = ni();
        long ans = N-K+1;
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

void solve()
{
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
		sum=sum+i;
	}
	cout<<sum;
}
int main()
{
	fast;
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> w(n);
  for (i64 i = 0; i < n; i++)
    cin >> w[i];
  i64 ans = 1e9;
  for (i64 i = 0; i < n; i++)
  {
    i64 small = 0, big = 0;
    for (i64 j = 0; j < n; j++)
      if (i < j)
        big += w[j];
      else
        small += w[j];
    ans = min(ans, abs(big - small));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	a := make([]int, n)
	
	cnt := 0
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] % 2 != 0 {
			cnt++
		}
	}
	
	if cnt % 2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 6312
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

template<typename T>
void input(T &x) {
	x=0; T a=1;
	register char c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c==45) a=-1;
	for(;c>=48&&c<=57;c=getchar())
		x=x*10+c-48;
	x*=a;
	return;
}

int n,m;

namespace solve70 {
	
	const int N=310;
	const int M=310;
	int a[N][M],cnt[N],sum[N];
	bool go[M];

	bool Judge(int mid) {
		memset(go,0,sizeof(go));
		for(int i=1;i<=n;i++) cnt[i]=1;
		while(1) {
			memset(sum,0,sizeof(sum));
			bool flag=true;
			for(int i=1;i<=n;i++) {
				for(;cnt[i]<=m&&go[a[i][cnt[i]]];cnt[i]++);
				if(cnt[i]>m) return false;
				if(++sum[a[i][cnt[i]]]>mid)
					go[a[i][cnt[i]]]=true,flag=false;
			}
			if(flag) return true;
		}
		return false;
	}

	int main() {
		input(n),input(m);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;++j)
				input(a[i][j]);
		int l=1,r=n;
		while(l<r) {
			int mid=l+r>>1;
			if(Judge(mid)) r=mid;
			else l=mid+1;
		}
		printf("%d\n",r);
		return 0;
	}

}

int main() { return solve70::main(); }


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

int main(){
    int a, b;cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1 << endl;
    }else if(a == 0 || b == 0){
        cout << -1 << endl;
    }else{
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
result = 1
flag = True
numlist = list(map(int,input().split()))
if 0 in numlist:
    print("0")
    flag = False
else:
    for i in numlist:
        result *= i
        if result > 10**18:
            print("-1")
            flag = False
            break

if flag:
    print(result)


Measured memory_bytes: 21708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;

    int A[N];
    rep(i,N){
        cin>>A[i];
    }

    
    int ans=0;
    rep(t,K){
        ans=0;
        bool w=true;
        int a[N+10]{};
        rep(i,N){
            int x=A[i]*2+1;
            int y=max(0LL,i-A[i]);
            int z=min(N,i+A[i]);
            a[y]++;
            a[z+1]--;

            
        }
        rep(i,N){
            ans+=a[i];
            A[i]=ans;
            if(ans!=N)w=false;
        }
        if(w) break;
    }
    
    rep(i,N){
        cout << A[i] << " ";
    }
    cout << endl;

    

    



}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
int a[5],k;
signed main(){
	int ans=0;
	int cnt=0;
	rep(i,5){
		cin>>a[i];
		int z=a[i];
		a[i]=(a[i]+9)/10*10;
		cnt=max(cnt,a[i]-z);
		ans+=a[i];
	}
	cout<<ans-cnt<<endl;
	ggr;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
  
using namespace std;

char s[8][8];
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int reversenum(int x, int y, char c)
{
    int ans = 0, cookienum;
    char rc;
    if(c == 'o') rc = 'x';
    else rc = 'o';
    for(int i = 0; i < 8; i++){
        cookienum = 0;
        int nx = x + dx[i];
        int ny = y + dy[i];
        while(nx >= 0 && ny >= 0 && nx < 8 && ny < 8 && s[nx][ny] == rc){
            nx += dx[i];
            ny += dy[i];
            cookienum++;
        }
        if(nx >= 0 && ny >= 0 && nx < 8 && ny < 8 && s[nx][ny] == c) ans += cookienum;
    }
    return ans;
}

void reverse(int x, int y, char c)
{
    char rc;
    if(c == 'o') rc = 'x';
    else rc = 'o';
    s[x][y] = c;
    for(int i = 0; i < 8; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        int cookienum = 0;
        while(nx >= 0 && ny >= 0 && nx < 8 && ny < 8 && s[nx][ny] == rc){
            nx += dx[i];
            ny += dy[i];
            cookienum++;
        }
        if(nx >= 0 && ny >= 0 && nx < 8 && ny < 8 && s[nx][ny] == c){
            nx = x + dx[i];
            ny = y + dy[i];
            for(int j = 0; j < cookienum; j++){
                s[nx][ny] = c;
                nx += dx[i];
                ny += dy[i];
            }
        }
    }
    return;
}

bool mami()
{
    int maxcookie = 0;
    int maxx, maxy;
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            if(s[i][j] != '.') continue;
            int revnum = reversenum(i, j, 'o');
            // cout << "mami " << revnum << endl;
            if(maxcookie < revnum){
                maxcookie = revnum;
                maxx = i;
                maxy = j;
            }
        }
    }
    if(maxcookie == 0) return false;
    reverse(maxx, maxy, 'o');
    return true;
}

bool charlotte()
{
    int maxcookie = 0;
    int maxx, maxy;
    for(int i = 7; i >= 0; i--){
        for(int j = 7; j >= 0; j--){
            if(s[i][j] != '.') continue;
            int revnum = reversenum(i, j, 'x');
            if(maxcookie < revnum){
                maxcookie = revnum;
                maxx = i;
                maxy = j;
            }
        }
    }
    if(maxcookie == 0) return false;
    reverse(maxx, maxy, 'x');
    return true; 
}

int main()
{
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            cin >> s[i][j];
        }
    }
    int flag = 0;
    while(flag != 2){
        flag = 0;
        if(!mami()) flag++;
        if(!charlotte()) flag++;
    }
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1136
#include <iostream>

using namespace std;
typedef long long ll;

ll N, K, aux, ans, cnt;

int main ()
{
	cin >> N >> K;
	
	aux = (N / K);
	ans = (aux * aux * aux);
	if ( K % 2 == 0 )
	{
		aux = (N - (K/2)) / K + 1;
		if ( N < K / 2 )
			aux = 0;
		ans += (aux * aux * aux);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


void turi(int n){
	printf("%d %d %d\n",n%500/100,n%1000/500,n/1000);
}

main(){
	int a,b;
	while(cin>>a>>b){
		if(a==0 && b==0)break;
		
		turi(b-a);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	string s; cin >> s;
    const string t = "CODEFESTIVAL2016";
    int res = 0;
    rep(i, 16) {
        if(s[i] != t[i]) ++res;
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,i,v,j,A[100],k;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<n;i++){
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k!=n-1)printf(" ");
    }
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;	
	}
      printf("\n");
  }
  for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k!=n-1)printf(" ");
    }
   printf("\n");
  return 0;
}



Measured memory_bytes: 2072
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        //PrintWriter out = new PrintWriter(System.out);
        int[] a = new int[5];
        for(int i=0;i<5;i++) a[i]= sc.nextInt();
        int k = sc.nextInt();
        String ans = a[4]-a[0]<=k?"Yay!":":(";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import sys

K = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip('\n')

# ## COMBINATION (MOD) ###
N_MAX = 10**6  # 問題サイズに合わせて変えておく
MOD = 10**9 + 7

inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 2):
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)

# K 文字追加
ans = 0

ln = len(S)

p1 = 1
p2 = 1
s2 = pow(26, K, MOD)

for i in range(1, K + 2):

    ans += (p1 * p2 * s2) % MOD
    ans %= MOD

    # print(p1, p2, s2)

    # pre
    p1 = (p1 * (ln + i - 1) * inv[i]) % MOD
    p2 = (p2 * 25) % MOD

    # suf
    s2 = (s2 * inv[26]) % MOD

print(ans)


Measured memory_bytes: 51208
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a[] = new long[2];
        a[0] = in.nextLong();
        a[1] = in.nextLong();

        if (a[0] % 3 == 0 || a[1] % 3 == 0) {
            System.out.println(0);
            return;
        }

        Arrays.sort(a);
        long area = a[0];
        area *= a[1];

        long min = Long.MAX_VALUE;
        for (int i = 1; i < a[1]; i++) {
            long b[] = new long[3];
            b[0] = a[0] * i;
            b[1] = (a[0] / 2) * (a[1] - i);
            b[2] = area - b[0] - b[1];
            Arrays.sort(b);
            min = Math.min(min, b[2] - b[0]);

            long c[] = new long[3];
            c[0] = a[0] * i;
            c[1] = ((a[1] - i) / 2) * a[0];
            c[2] = area - c[0] - c[1];
            Arrays.sort(c);
            min = Math.min(min, c[2] - c[0]);
        }

        long tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
        for (int i = 1; i < a[1]; i++) {
            long b[] = new long[3];
            b[0] = a[0] * i;
            b[1] = (a[0] / 2) * (a[1] - i);
            b[2] = area - b[0] - b[1];
            Arrays.sort(b);
            min = Math.min(min, b[2] - b[0]);

            long c[] = new long[3];
            c[0] = a[0] * i;
            c[1] = ((a[1] - i) / 2) * a[0];
            c[2] = area - c[0] - c[1];
            Arrays.sort(c);
            min = Math.min(min, c[2] - c[0]);
        }        

        System.out.println(min);
    }
}


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

#define _GLIBCXX_DEBUG

int main() {
  int a, b, c, k;
  int ans = 0;
  cin >> a >> b >> c >> k;
  int count = k;

  int i = 0;
  while(i < a) {
    if(count == 0) break;
    ans++; count--; i++;
  }
  i = 0;
  while(i < b) {
    if(count == 0) break;
    count--; i++;
  }
  i = 0;
  while(i < c) {
    if(count == 0) break;
    ans--; count--; i++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, i;
	cin >> N >> i;
	cout << N - i + 1 << endl;
}

Measured memory_bytes: 256
h,w = [int(i) for i in input().split(" ")]
a = [[]] * (h + 1)

for i in range(1, h + 1):
    a[i] = [0] + [int(j) for j in input().split(" ")]
    
pw = ""
c = 0

for y in range(1, h + 1):
    for x in range(1, w + 1):
        if a[y][x] % 2 == 1:
            if x == w:
                if y != h:
                    a[y + 1][x] += 1
                    a[y][x] -= 1
                    pw += " ".join(map(str, [y, x, y + 1, x])) + "\n"
                    c += 1
            else:
                a[y][x + 1] += 1
                a[y][x] -= 1
                pw += " ".join(map(str, [y, x, y, x + 1])) + "\n"
                c += 1
print(c)
print(pw)

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(a>b)swap(a,b);
  cout << (b-a-w<0?0:b-a-w) << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

b = []
r = []

# input
N = int(input())
for i in range(N):
    arg = input()
    b.append(arg)

M = int(input())
for i in range(M):
    arg = input()
    r.append(arg)

# solve
br = b + r
for i in range(len(br)):
    # initialize
    count_b = 0
    count_r = 0
    # target string
    s = br[i]
    # check blue cards
    for j in range(len(b)):
        if (b[j] == s):
            count_b += 1
    # check red cards
    for j in range(len(r)):
        if (r[j] == s):
            count_r += 1
    # check difference
    diff = count_b - count_r
    if (i == 0):
        X = diff
    elif (diff > X):
        X = diff
if (X < 0):
    X = 0

print(X)


Measured memory_bytes: 3064
#include <stdio.h>

int N, K;
int V[128];

int memo[64][64][128];

int search(int l, int r, int nokori) {
	int answer = 0, candidate;
	if (l > r || nokori <= 0) return 0;
	if (memo[l][r][nokori]) return ~memo[l][r][nokori];

	/* 1個取って持つ */
	if (nokori >= 1) {
		/* 左 */
		candidate = search(l + 1, r, nokori - 1) + V[l];
		if (candidate > answer) answer = candidate;
		/* 右 */
		candidate = search(l, r - 1, nokori - 1) + V[r];
		if (candidate > answer) answer = candidate;
	}
	/* 1個取って捨てる */
	if (nokori >= 2) {
		/* 左 */
		candidate = search(l + 1, r, nokori - 2);
		if (candidate > answer) answer = candidate;
		/* 右 */
		candidate = search(l, r - 1, nokori - 2);
		if (candidate > answer) answer = candidate;
	}

	return ~(memo[l][r][nokori] = ~answer);
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &V[i]) != 1) return 1;
	}
	printf("%d\n", search(0, N - 1, K));
	return 0;
}

/*

・左から1個取って持つ (コスト1)
・右から1個取って持つ (コスト1)
・左から1個取って捨てる (コスト2)
・右から1個取って捨てる (コスト2)
ができる。「何もしない」もアリ。

「捨てる」は、「取る操作を終えた後にいらない宝石を詰める」で実現する。

*/


Measured memory_bytes: 1024
import java.util.*;

public class Main {

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

		if (X >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35676
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e10
#define NMAX 505
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;

ll N,M,K,A,B,C=0,D,E;
char dat[NMAX][NMAX]={};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = INFLL;
bool isAllWhite=true, foundWhiteColumn[NMAX] = {};

int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            char ch; cin >> ch; dat[i][j] = ch;
            if (ch == '#')
            {
                isAllWhite = false;
            }else
            {
                if (!foundWhiteColumn[j])
                {
                    foundWhiteColumn[j] = true;
                    ++C;
                }
            }
        }
    }
    if (isAllWhite)
    {
        cout << "-1\n";
        return 0;
    }

    for (int i = 0; i < N; ++i)
    {
        // calc x
        int x = 0;
        for (int j = 0; j < N; ++j) if (dat[i][j] == '.') ++x;
        bool found=false;
        for (int k = 0; k < N; ++k)
        {
            if (dat[k][i] == '#')
            {
                found = true;
                break;
            }
        }
        if (found)
        {
            ans = min(ans, x+C);
        }
        else
        {
            ans = min(ans, x+1+C);
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

//#define FILE_IO

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    string s;
    cin >> s;
    int w = 0, l = 0;
    for(auto x: s)
        if(x == 'o')    w++;
        else l++;

    int rem = 15 - l - w;
    if(w + rem >= 8)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int a,b;
	char s[15];
	cin>>a>>b;
	for(int i=1;i<=a+b+1;i++){
		cin>>s[i];
		 if(i!=a+1){
			if(s[i]>'9'||s[i]<'0'){
				cout<<"No";
				return 0;
			}
		}
		if(i==a+1){
			if(s[i]!='-'){
				cout<<"No";
				return 0;
			}
		}
	}	
	cout<<"Yes";
}
	

Measured memory_bytes: 256