akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
vector<ll> v;
ll sum;
signed main(){
	ios_base::sync_with_stdio(0);
	ll a,b;
	cin>>a>>b;
	for(ll i=1;i<=999;i++){
		sum+=i;
		v.pb(sum);
	}
	for(ll i=0;i+1<sz(v);i++){
		//cout<<v[i]<<' ';
		if(v[i]<a||v[i+1]<b) continue;
		if(v[i]-a==v[i+1]-b){
			cout<<v[i]-a;
			re 0;
		}
	}
	re 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int n, a=0, b=0;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n;i++){
        if((s[i]=='0'&&i%2==1)||(s[i]=='1'&&i%2==0))a++;
        if((s[i]=='0'&&i%2==0)||(s[i]=='1'&&i%2==1))b++;
    }
    cout<<min(a, b)<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
double a[55];
int n;
double ans,k;
int main() {
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	k=a[0];
	for(int i=1;i<n;i++) k+=a[i],k/=2;
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    dp = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N + 1)]

    dp[0][3][3][3] = 1

    for i in range(N):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if dp[i][j][k][l] == 0:
                        continue
                    for m in range(4):
                        if k == 0 and l == 1 and m == 2:
                            continue
                        if k == 0 and l == 2 and m == 1:
                            continue
                        if k == 1 and l == 0 and m == 2:
                            continue
                        if j == 0 and k == 1 and m == 2:
                            continue
                        if j == 0 and l == 1 and m == 2:
                            continue

                        dp[i + 1][k][l][m] += dp[i][j][k][l]
                        dp[i + 1][k][l][m] %= MOD

    ans = 0
    for j in range(4):
        for k in range(4):
            for l in range(4):
                ans += dp[N][j][k][l]

    print(ans % MOD)


    

    

if __name__ == '__main__':
    main()




Measured memory_bytes: 3320
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
queue<int> que;

ll calc() {
  int cnt = 9;
  rep(i,9) que.push(i+1);
  while(cnt<N) {
    ll q = que.front(); que.pop();
    // 0, 1-8, 9
    if (q%10==0) {
      rep(i,2) {
        que.push(q*10+i);
        cnt++;
        if (cnt==N) return q*10+i;
      }
    } else if (q%10==9) {
      rep(i,2) {
        que.push(q*10+8+i);
        cnt++;
        if (cnt==N) return q*10+8+i;
      }
    } else {
      rep(i, 3) {
        que.push(q*10+q%10-1+i);
        cnt++;
        if (cnt==N) return q*10+q%10-1+i;
      }
    }

  }
  return cnt;
}

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

  cin >> N;
  if (N<10) {
    cout << N << "\n";
    return 0;
  }
  cout << calc() << "\n";
  return 0;
}

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

struct UnionFind{
  vector<int> par;
  vector<int> rank;

  UnionFind(int n) : par(n, -1), rank(n, 0){}

  int find(int x){
    if(par[x] < 0) return x;
    else return par[x] = find(par[x]);
  }

  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x==y) return false;
    else if(rank[x]<rank[y]) par[x] = y;
    else if(rank[x]>rank[y]) par[y] = x;
    else par[y] = x, rank[x] += 1;
    return true;
  }

  bool same(int x, int y){
    return find(x)==find(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n+1);
  int ans = 0;
  rep(i, m){
    int x, y, z;
    cin >> x >> y >> z;
    ans += uf.unite(x, y);
  }
  cout << n-ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/

bool ok[1005];
int main(int argc,char* argv[]){
	for(int i=1;i<=50;i++){
		int ex=i;
		for(int j=2;j<=1000;j++){
			ex*=i;
			if(ex>1000){
				break;
			}else{
				ok[ex]=true;
			}
		}
	}
	
	int x;
	cin>>x;
	
	while(!ok[x]){
		x--;
	}
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    vector<ll> a(n);
    map<ll, ll> mp;
    ll sum = 0;
    rep(i,n) {
        cin>>a[i];
        mp[a[i]]++;
        sum += a[i];
    }

    int q; cin>>q;
    while (q--) {
        ll b,c; cin>>b>>c;
        sum -= b*mp[b];
        sum += c*mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 10076
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll T[100007];

int main(){
  ll N,A,B;
  pair<ll,ll> C[100007],D[100007];
  ll sum = 0;
  cin >> N ;
  rep(i,N){
    cin >> A >> B; 
    sum -= B;
    C[i].fr=A;C[i].sc=B;
  }
  sort(C,C+N,[](pair<ll,ll> &a,pair<ll,ll> &b){return  a.fr+a.sc >  b.fr+b.sc ;});
  rep(i,N){
    if(i%2==0){
      sum += C[i].fr+C[i].sc;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	cin >> s;
	int k;
	cin>>k;
	for (int i = 0; i < k; ++i){
		if (s[i] != '1'){
			printf("%c", s[i]);
			return 0;
		}
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int s[w][h]={0},x[n],y[n],a[n];
  for (size_t i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> a[i];
    if(a[i] == 1){
      for (size_t yc = 0; yc < h; yc++) {
        for (size_t xc = 0; xc < x[i]; xc++) {
          s[xc][yc] = 1;
        }
      }
    }
    if(a[i] == 2){
      for (size_t yc = 0; yc < h; yc++) {
        for (size_t xc = x[i]; xc < w; xc++) {
          s[xc][yc] = 1;
        }
      }
    }
    if(a[i] == 3){
      for (size_t yc = 0; yc < y[i]; yc++) {
        for (size_t xc = 0; xc < w; xc++) {
          s[xc][yc] = 1;
        }
      }
    }
    if(a[i] == 4){
      for (size_t yc = y[i]; yc < h; yc++) {
        for (size_t xc = 0; xc < w; xc++) {
          s[xc][yc] = 1;
        }
      }
    }
  }
  int ans=0;
  for (size_t i = 0; i < h; i++) {
    for (size_t l = 0; l < w; l++) {
      if(s[l][i] == 0){
        ans++;
      }
    }
  }
  cout << ans;
}


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

using namespace std;

#define sp << " " <<

long long dp[10000][100][2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int d;
    cin >> s >> d;
	for(int i=0;i<s[0]-'0';i++)
    {
		dp[0][i%d][0]++;
	}
	dp[0][(s[0]-'0')%d][1]=1;
	for(int i=1;i<s.length();i++)
    {
		for(int k=0;k<10;k++)
		{
			for(int j=0;j<d;j++)
			{
				dp[i][(j+k)%d][0]+=dp[i-1][j][0];
				dp[i][(j+k)%d][0]%=1000000007;
				if(k<s[i]-'0')
				{
					dp[i][(j+k)%d][0]+=dp[i-1][j][1];
					dp[i][(j+k)%d][0]%=1000000007;
				}
				if(k==s[i]-'0')
				{
					dp[i][(j+k)%d][1]+=dp[i-1][j][1];
					dp[i][(j+k)%d][1]%=1000000007;
				}
			}
		}
	}
	cout << (dp[s.length()-1][0][0]+dp[s.length()-1][0][1]-1+1000000007)%1000000007;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int res[4];
  for(int i=0; i<4; ++i) res[i] = 0;
  for(int i=0; i<n; ++i){
    string s; cin >> s;
    if(s[0] == 'A') ++res[0];
    else if(s[0] == 'W') ++res[1];
    else if(s[0] == 'T') ++res[2];
    else ++res[3];
  }
  cout << "AC x " << res[0] << "\n";
  cout << "WA x " << res[1] << "\n";
  cout << "TLE x "<< res[2] << "\n";
  cout << "RE x " << res[3] << "\n";
  return 0;
}

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

using namespace std;

#define forinc(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define fordec(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

typedef long long ll;
typedef unsigned long long ull;

const int N=3e5+5;
int h,w,n;
ii a[N];
int f[N], g[N];

int32_t main(){
    fasty;
    cin>>h>>w>>n;
    forinc(i,1,n) cin>>a[i].fi>>a[i].se;
    forinc(i,1,n) f[a[i].fi]++, g[a[i].se]++;
    int mf=0, mg=0;
    forinc(i,1,h) mf=max(mf, f[i]);
    forinc(i,1,w) mg=max(mg, g[i]);
    int cf=count(f+1, f+h+1, mf);
    int cg=count(g+1, g+w+1, mg);
    int tot=0;
    forinc(i,1,n) if(f[a[i].fi]==mf && g[a[i].se]==mg) tot++;
    if(tot==cf*cg) cout<<mf+mg-1<<'\n';
    else cout<<mf+mg<<'\n';
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string a,b;
	cin>>a>>b;
	int suda=a.size();
	int pon=b.size();
	if(suda>pon){
		cout<<"GREATER"<<endl;
	}
	else if(suda<pon){
		cout<<"LESS"<<endl;
	}
	else{
		for(int i=0;i<suda;i++){
			if(a[i]>b[i]){
				cout<<"GREATER"<<endl;
				return 0;
			}
			if(a[i]<b[i]){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, k;
int main()
{
    cin >> n >> k;
    char c, cc;
    int kk = 0;
    cin >> c;
    for (int i = 0; i != n - 1; ++i)
    {
        cin >> cc;
        if (cc != c) ++kk;
        c = cc; 
    }
    if (kk < 2 * k) kk = 0;
    else kk -= 2 * k;
    cout << n - 1 - kk << endl;
    return 0;
}

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

int main(){
  long long N,sum=0;
  cin >> N;
  vector<long long> A(N),ans(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  
  ans[0] = sum;
  for(int i=1;i<N;i+=2) ans[0] -= A[i]*2;
  cout << ans[0];
  
  for(int i=1;i<N;i++){
    ans[i] = A[i-1]*2 - ans[i-1];
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int m = sc.nextInt();
	  System.out.println(48 - m);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


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

using namespace std;
using ll = long long;

int main(){
    int n; cin>>n;
    string s;
    cin>>s;
    vector<int> v;
    for(auto x: s){
        auto y = int(x-'A');
        y = (y + n) % 26;
        cout<<char('A'+y);
    }
    cout<<endl;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	set<string> s;
	rep(i, n)
	{
		string t; cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 19220
# N = int(input())
# A,B = map(int,input().split())
# li = list(map(int,input().split()))

N = int(input())
A = list(map(int,input().split()))

li1 = [1]
for i in range(N):
    # if li1[-1]>=10**20:
    #     li1.append(10**20)
    # else:
    li1.append(min(10**15,2*li1[-1]-A[i]*2))

li2 = [0 for i in range(N+2)]
for i in range(N,-1,-1):
    li2[i] = A[i]+li2[i+1]

ans = 0
li3 = []
for i in range(N+1):
    ans += min(li1[i],li2[i])
    li3.append(ans) 
    if li1[i]<A[i]:
        print(-1)
        break
else:
    print(ans)



# print(*li1)
# print(*li2)
# print(ans)

# print(ans)






# if :
#     print("Yes")
# else:
#     print("No")


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

int main(){
  int n,a,b,c,d;
  cin >> n;
  d = n%10;
  n = n/10;
  c = n%10;
  n = n/10;
  b = n%10;
  n = n/10;
  a = n;
  if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
  else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
  else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
  else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
  else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
  else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
  else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
  else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 21:02:07 2019

@author: doppe
"""

N, K = map(int, input().split())
count = 0
for i in range(1, N + 1, 2):
    count += 1
if (count >= K):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  int h,w;
  cin>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        char[] Sc = S.toCharArray();
        int count = 0;

        for(int i=0; i < Sc.length-2; i++){
           if(Sc[i] == 'A' && Sc[i+1] == 'B' && Sc[i+2] == 'C'){
               count++;
           }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
import sys

N = 100
n = int(input())

p = [0]*(N+1)
m = [list([0]*(N+1)) for _ in range(N+1)]

for i in range(n):
    p[i],p[i+1]=map(int,input().split())
for l in range(2,n+1):
    for i in range(1,n-l+2):
        j = i+l-1
        m[i][j]=sys.maxsize
        for k in range(i,j):
            m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1] *p[k]*p[j])

print(m[1][n])    
    


Measured memory_bytes: 5684
#include <bits/stdc++.h>
using namespace std;
#define ll long int
int main(){
    ll n;
    cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; ++i)
        cin >> v[i];

    bool f = true;

    for(int i = 1; i < n; ++i)
        if(v[i-1][v[i-1].size() - 1] != v[i][0]) f = false;

    sort(v.begin(),v.end());

    for(int i = 1; i < n; ++i){
        if(v[i - 1] == v[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

  ll h;
  cin >> h;

  ll ans = 1;

  while (h) {
    h /= 2;
    ans *= 2;
  }

  cout << ans-1 << '\n';

  return (0);
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    //rsp
    int n,k;cin>>n>>k;
    vector<pair<int,char>> sc(3);
    int r,s,p;cin>>r>>s>>p;
    sc[0]=make_pair(r,'r');
    sc[1]=make_pair(s,'s');
    sc[2]=make_pair(p,'p');
    sort(ALL(sc));
    reverse(ALL(sc));

    string t;cin>>t;
    string w=t;

    rep(i,n){
        if(t[i]=='r') w[i]='p';
        if(t[i]=='s') w[i]='r';
        if(t[i]=='p') w[i]='s';
    }

    ll ans=0;

    rep(i,3){
        //勝ちたい手
        char hand=sc[i].second;
        rep(j,n)if(w[j]==hand){
            int pre=j-k;
            if(pre<0 or w[pre]!=hand){
                ans+=sc[i].first;
            }else{
                w[j]='?';
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
H, W, K = [int(x) for x in input().split()]
c = [input() for x in range(H)]

import itertools
HH = list(range(H))
WW = list(range(W))
ans = 0
totalblack = sum([x.count('#') for x in c])

HHH = [list(itertools.combinations(HH, i)) for i in range(H+1)]
WWW = [list(itertools.combinations(WW, i)) for i in range(W+1)]

for hh in HHH:
    for ww in WWW:
        for h in hh:
            count = 0
            for i in h:
                count += c[i].count('#')
            
            for w in ww:
                ccount = 0
                for j in w:
                    for i, l in enumerate(c):
                        if i in h:
                            continue
                        ccount += l[j] == '#'
                ans += totalblack - (count+ccount) == K

print(ans)

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

int main(){
  int s;
  cin >> s;
  int i=0;
  vector<int> a;
  for(i;i<MOD;i++){
    a.push_back(s);
    s = (s%2 == 0) ? s/2 : 3*s + 1;
    bool flag = false;
    for(d:a) flag |= d == s;
    if (flag) break;
  }
  cout<<i+2<<endl;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;
  string rt = t + t;
  if (rt.find(s) != std::string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
struct edge{int to,cost;};
vector<int> es[114];
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a>b||(n==1&&a!=b))cout<<0<<endl;
    else{
        int min=a*(n-1)+b;
        int max=b*(n-1)+a;
        cout<<max-min+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, total = 0;
    scanf("%d", &n);
    int a[n], b[n], c[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n-1; i++) {
        scanf("%d", &c[i]);
    }
    for(int i = 0; i < n; i++) {
        total += b[a[i]-1];
        if(i > 0) {
            if(a[i-1] + 1 == a[i]) {
                total += c[a[i-1]-1];
            }
        }
    }
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int maxn = 2e5 + 10;
void solve(){
    ll a, b; cin >> a >> b;
    cout << a * b << endl;
}
int main(){
    IOS; int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

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

const int M=2e5+5;
int a[M],b[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",a+i,b+i);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	int ma,mb;
	if(n&1^1)
	{
		ma=a[n/2]+a[n/2+1];
		mb=b[n/2]+b[n/2+1];
	}
	else
	{
		ma=a[(n+1)/2];
		mb=b[(n+1)/2];
	}
	printf("%d\n",mb-ma+1);
	return 0;
}

Measured memory_bytes: 5392
#include<bits/stdc++.h>
// #define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
#define V vector
using namespace std;

V<V<ll>> dp(401,vll(401,1e18));
int n;

signed main()
{
    io
    cin >> n;
    vll a(n);
    vll slimadd(n+1,0);
    fori(0,n){
        cin >> a[i];
        slimadd[i+1] = slimadd[i] + a[i];
    }
    fori(0,n-1){
        dp[i][i] = 0;
        dp[i][i+1] = a[i] + a[i+1];
    }
    dp[n-1][n-1] = 0;
    for(int i=n-2;i>=0;--i){
        for(int j=i+2;j<n;++j){
            for(int k=i;k<j;++k){
                dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k+1][j]-slimadd[i]+slimadd[j+1]);
            }
        }
    }
    cout << dp[0][n-1] << endl;

} 

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
#define N 20
#define M 33000
#define mod 1000000007
int n,m,a[M],b[M],f[2][M],bin[M],c[M],d[M],ans;
int main(){
	scanf("%d%d",&n,&m);
	bin[0]=1;rep (i,1,2*m) bin[i]=2ll*bin[i-1]%mod;
	rep (i,1,m){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--,b[i]--;
	}
	rep (i,0,(1<<n)-1) rep (j,1,m){
		if ((i>>a[j]&1)&&(i>>b[j]&1)) c[i]++;
		if ((i>>a[j]&1)||(i>>b[j]&1)) d[i]++;
	}
	rep (i,0,1) rep (j,0,(1<<n)-1) if (!(~j>>i&1)){
		f[i][j]=bin[c[j]];
		for (int k=j;k;--k&=j) f[i][j]=(f[i][j]+mod-(ll)f[i][j-k]*bin[c[k]]%mod)%mod;
	}
	rep (i,0,(1<<n)-1) rep (j,0,(1<<n)-1)
		if (!(i&j)&&c[i]+c[j]==c[i|j])
			ans=(ans+(ll)f[0][i]*f[1][j]%mod*bin[m-d[i|j]]%mod)%mod;
	ans=(bin[m]+mod-ans)%mod;
	cout<<ans<<'\n';
	return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    if(v[0]+v[1] == v[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3596
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val map = sortedMapOf<String, Int>()
    var maxCount = 0
    0.until(n).forEach {
        val s = readLine() ?: return
        val count = map[s]?.let { it + 1 } ?: 1
        map[s] = count
        if (count > maxCount) {
            maxCount = count
        }
    }
    map.entries
        .filter {
            it.value == maxCount
        }.sortedBy { it.key }
        .forEach {
            println(it.key)
        }
}

Measured memory_bytes: 81896
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
//#include <bitset>
#include<cstdio>
using namespace std;

long long val[200005];
long long dp[200005];
long long neg[200005];
long long mod = 0;

long long power(long long x, long long t) {
    if (mod <= 0) return 0ll;

    if (t == 0) return 1ll;
    else if (t == 1) return x;

    long long p = power(x, t/2)%mod;
    p *= p;
    p %= mod;

    if (t%2 == 0) return p;
    else return (p*x)%mod;
}

long long f(long long x) {
    if (x == 0) return 1ll;
    else if (dp[x] != -1ll) return dp[x];

    long long cnt = 0;
    long long tmp = x;

    while (tmp) {
        if (tmp&1) cnt ++;
        tmp >>= 1;
    }

    return (dp[x] = 1+f(x%cnt));
}

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

    long long n;
    cin >> n;
    string x;
    cin >> x;

    for (long long i = 0; i < n; i++) {
        if (x[i] == '1') mod ++;
    }

    long long tmp2 = 0, tmp3 = 0;
    for (long long i = n-1; i >= 0; i--) {
        if (x[i] == '1') {
            mod --;
            tmp2 += power(2ll, n-i-1);
            mod ++;
            mod ++;
            tmp3 += power(2ll, n-i-1);
            mod --;
        }

        if (mod > 1) tmp2 %= (mod-1);
        else tmp2 = 0;

        tmp3 %= (mod+1);
    }

    for (long long i = n-1; i >= 0; i--) {
        if (x[i] == '0') {
            mod ++;
            val[i] = (tmp3+power(2ll, n-i-1))%mod;
            mod --;
        } else if (mod == 1 && x[i] == '1') {
            val[i] = 0ll;
        } else {
            mod --;
            long long tmp = power(2ll, n-i-1);
            val[i] = (mod+tmp2-tmp)%mod;
            mod ++;
        }
    }

    for (int i = 0; i <= n; i++) dp[i] = -1;

    for (int i = 0; i < n; i++) {
        //cout << i << " " << val[i] << endl;
        if (mod == 1 && x[i] == '1') cout << 0 << endl;
        else cout << f(val[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 6348
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 303;
const int K = 1000000;
int dp[N][N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    dp[0][1][1] = 1;
    for (int i = 0; i < m; i++){
        for (int j = 0; j <= min(i + 1, n); j++){
            for (int l = 0; l <= j; l++){
             //   dp[i][j][l] = (dp[i - 1][j][l] * (j - 1) + dp[i - 1][j - 1][l] * (n - j + 1) + s[i - 1][j][l]) % mod;
               // cout << i << " " << j << " " << l << " " << dp[i][j][l] << endl;
                dp[i + 1][j][j] = (dp[i + 1][j][j] + dp[i][j][l] * l) % mod;
                dp[i + 1][j][l] = (dp[i + 1][j][l] + dp[i][j][l] * (j - l)) % mod;
                dp[i + 1][j + 1][l] = (dp[i + 1][j + 1][l] + dp[i][j][l]) % mod;
            }
        }
    }
    for (int i = 2; i <= n - 1; i++){
        dp[m][n][n] = dp[m][n][n] * i % mod;
    }
    cout << dp[m][n][n];

}


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

using namespace std;
 
long long x, y, z, K, a[1009], b[1009], c[1009];
vector <long long> vec;
 
int main() 
{
	cin >> x >> y >> z >> K;
	for (int i = 0; i < x; i++) cin >> a[i]; sort(a, a + x, greater <long long>());
	for (int i = 0; i < y; i++) cin >> b[i]; sort(b, b + y, greater <long long>());
	for (int i = 0; i < z; i++) cin >> c[i]; sort(c, c + z, greater <long long>());
	
	for (int i = 0; i < x; i++) 
		for (int j = 0; j < y; j++) 
			for (int k = 0; k < z; k++) 
				if ((i + 1) * (j + 1) * (k + 1) <= K) vec.push_back(a[i] + b[j] + c[k]);
				else break;
	
	sort(vec.begin(), vec.end(), greater <long long>());
	for (int i = 0; i < K; i++) cout << vec[i] << endl;
	return 0;
}


Measured memory_bytes: 1400
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

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

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    int h,w;
    cin>>n>>h>>w;

    int a = max(0,n-h+1);
    int b = max(0,n-w+1);
    cout<<a*b;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		//方針f(x)つまり各桁の合計でfxわれれば正解
      		String[] numberStrSplit = N.split("");
		//それぞれ数値にしてたす
		int suutiSum = 0;
		for(int i = 0;i < numberStrSplit.length;i++){
			suutiSum += Integer.parseInt(numberStrSplit[i]);	
		}
		if( Integer.parseInt(N)%suutiSum == 0){
			System.out.println("Yes");			
		}else{
			System.out.println("No");			
		}

		
		

		
		
	
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long MOD = 1e9 + 7;

long long modstr(const string &s, long long mod) {
    long long a = 0;
    for (auto &c : s) a = (c - '0' + a * 10) % mod;
    return a;
}
long long modpow(long long a, long long n, long long mod) {
    if (n == 0) return 1;
    long long res = modpow(a, n / 2, mod);
    return res * res % mod * (n & 1 ? a : 1) % mod;
}
long long modpow(const string &a, const string &n, long long mod) {
    long long r = modstr(a, mod);
    return r == 0 ? (n == "0") : modpow(r, modstr(n, mod - 1), mod);
}

int main() {
    string m, n; cin >> m >> n;
	cout << modpow(m, n, MOD) << endl;
    return 0;
}


Measured memory_bytes: 3204
n = int(input())
a = list(map(int, input().split()))
up = 0

for x in a:
    up = max(up, x)

t = [0 for _ in range(up + 1)]

rgb = 3
ans = 1
for i in range(n):
    if a[i] == 0:
        t[a[i]] += 1
        ans *= rgb
        ans %= 1000000007
        rgb -= 1
    else:
        ans *= t[a[i] - 1]
        ans %= 1000000007
        t[a[i]] += 1
        t[a[i] - 1] -= 1


ans %= 1000000007
print(ans)
exit(0)


Measured memory_bytes: 14020
n = int(input())
val1 = 10
val2 = 9
val3 = 8
if n == 1:
    print(0)
else:
    for i in range(n-1):
        val1 = (val1*10)%(10**9+7)
        val2 = (val2*9)%(10**9+7)
        val3 = (val3*8)%(10**9+7)
    ans = int((val1-2*val2+val3)%(10**9+7))
    if ans<0:
        print(ans+1000000007)
    else:
        print(ans)

Measured memory_bytes: 9004
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    string s,t;cin>>s>>t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0)),
                        rev(s.size()+1,vector<int>(t.size()+1,-1));
    REP(i,s.size()) REP(j,t.size()){
        if(s[i]==t[j]){
            dp[i+1][j+1]=dp[i][j]+1;
            rev[i+1][j+1]=0;
        }
        else if(dp[i+1][j]>dp[i][j+1]){
            dp[i+1][j+1]=dp[i+1][j];
            rev[i+1][j+1]=1;
        }
        else{
            dp[i+1][j+1]=dp[i][j+1];
            rev[i+1][j+1]=2;
        }
    }
    string ans;
    int x=s.size(),y=t.size(),q=rev[x][y];
    while(q!=-1){
        if(q==0){
            x--;y--;
            ans.push_back(s[x]);
        }
        if(q==1) y--;
        if(q==2) x--;
        q=rev[x][y];
    }
    reverse(All(ans));
    cout<<ans<<endl;
}

Measured memory_bytes: 70912
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n;
		cin >> n;
		cout << n*n;
		
    return 0;
} // What is to be written here?


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

// n以下の素数を列挙する
class Prime
{
public:
    const int n;
    vector<bool> is_prime;
    vector<int> primes;
    Prime(int size) : n(size), is_prime(n + 1, true)
    {
        is_prime[0] = false;
        is_prime[1] = false;
        for (int i = 2; i <= n; ++i)
        {
            if (!is_prime[i])
                continue;
            primes.push_back(i);
            int tmp = 2 * i;
            while (tmp <= n)
            {
                is_prime[tmp] = false;
                tmp += i;
            }
        }
    }

    bool check(int x) { return is_prime[x]; }
};

int main()
{
    int x;
    cin >> x;
    vector<int> pr;
    Prime prime(100003);
    for (int p : prime.primes)
    {
        pr.push_back(p);
    }

    rep(i, pr.size())
    {
        if (x <= pr[i])
        {
            cout << pr[i] << endl;
            break;
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int X,Y;
  cin>>X>>Y;
  int ans=INF;
  if(Y-X>=0){
    ans=min(ans,Y-X);
  }
  if(Y-(-X)>=0){
    ans=min(ans,1+Y-(-X));
  }
  if((-Y)-(-X)>=0){
    ans=min(ans,2+(-Y)-(-X));
  }
  if((-Y)-X>=0){
    ans=min(ans,1+(-Y)-X);
  }
  cout<<(ans==INF?0:ans)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

vector<int> enum_div(int n,int m){
    vector<int> ret;
    FOR(i,1,100){
        if(n%i == 0 && m%i == 0){
            ret.push_back(i);
        }
    }
    return ret;
}

int main(){
    int A,B,K; cin >> A >> B >> K;
    vector<int> ans;
    ans = enum_div(A,B);
    cout << ans[ans.size()-K] << endl;
}


Measured memory_bytes: 3612
n = STDIN.gets.to_i

n1 = STDIN.gets.to_i
n2 = STDIN.gets.to_i

max = n1
min = n1

if n1 > n2 then
  min = n2
  diff = n2 - n1
  max = n2
else
  max = n2
  diff = n2 - n1
end


(3..n).each { |i|
  x = STDIN.gets.to_i

  max = x if max.nil?
  min = -x if min.nil?

  if x > max then
    diff = x - min if x - min > diff
    max = x
  elsif x <= min then
    diff = x - max if x - max > diff
    min = x
    max = x
  end
}
puts diff

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

#define int long long
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define repp(i,a,b) for(int i=a;i<b;i++)
#define repm(i,a,b) for(int i=a;i>b;i--)
#define debug_interval endl
#define dump_interval ' '
#define debug_toggle 0


inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
inline int gcd(int a,int b){return a?gcd(b%a,a):b;} //Don't use C++17
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

string s;

main(){
    ios::sync_with_stdio(false);
    cin>>s;
    s.pop_back();
    s.pop_back();
    while(true){
    if(s.substr(0,s.size()/2)==s.substr(s.size()/2,s.size()/2)){
        dump(s.size());
        return 0;
    }
    s.pop_back();
    s.pop_back();
  }
}

Measured memory_bytes: 256
import java.io.IOException
import java.io.InputStream
import java.io.PrintWriter
import java.util.NoSuchElementException

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val w = sc.nextIntArray(n)
    var sum = 0
    val sigma = (0 until n).map {
        sum += w[it]
        sum
    }
    val ans = sigma.map { Math.abs(it - (sum - it)) }.min()
    println(ans)
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 29736
n=input()
d=len(n)
n=int(n)

#nの桁数はd
count=0
if d%2==1:
    count+=n-10**(d-1)+1
    for i in range((d-1)//2):
        count+=10**(2*i+1)-10**(2*i)
else:
    for i in range(d//2):
        count+=10**(2*i+1)-10**(2*i)
print(count)

Measured memory_bytes: 38448