akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main(){
  map<string,int> m;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string t;
    cin >> t;
    m[t]++;
  }
  int M;
  cin >> M;
  for(int i = 0; i < M; i++){
    string t;
    cin >> t;
    m[t]--;
  }
  int pmax = -100000;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    pmax = max(itr->second, pmax);
  }
  cout << max(pmax, 0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	cout << 800 * N - 200 * (N / 15) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n - 1) {
        if(a[i] == a[i + 1]) {
            ans++;
            a[i + 1] = 105 + i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> data(26);
  vector<string> data2;
  vector<int> data3;
  
  rep(i,N){
    string S, C;
    cin >> S;
    rep(j, 10) data.at(S.at(j)-'a')++;
    rep(j, 26) {
      while(data.at(j) > 0){
        C += (char)(j + 'a');
        data.at(j)--;
      }
    }
    data2.push_back(C);
  }
  
  sort(data2.begin(), data2.end());
  data2.push_back("  ");
  
  int64_t count = 0;
  
  for(int i=0; i < N; i++){
    if(data2.at(i) == data2.at(i+1)) {
      count++;
    } else {
      data3.push_back(count);
      count = 0;
    }
  }
  
  int64_t ans = 0;
  for (int64_t x : data3){
    ans += x * (x + 1) /2;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 8180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N;
    cin >> N;
    vi(a, N);
    rep(i, N) cin >> a.at(i);
    int m=1, c=0;
    while(m!=2){
        m = a.at(m-1);
        c++;
        if(m==1){
            c=-1;
            break;
        }
        if(c>N){
            c=-1;
            break;
        }
    }
    cout << c << endl;
    return 0;

}

Measured memory_bytes: 640
from collections import deque

def main():
    N,M = map(int,input().split())
    s = [list(str(input())) for _ in range(N)]
    count = 0
    for i in range(N):
        for j in range(M):
            if s[i][j] == ".":
                count += 1
    
    q = deque([(0,0)])
    dx,dy = [1,0,-1,0],[0,1,0,-1]
    dist = [[10**10 for _ in range(M)] for _ in range(N)]
    dist[0][0] = 1
    
    while q:
        x,y = q.pop()
        for _x,_y in zip(dx,dy):
            nx,ny = x+_x,y+_y
            if (0<=nx<N and 0<=ny<M and s[nx][ny] == "."):
                if dist[nx][ny] > dist[x][y]+1:
                    dist[nx][ny] = dist[x][y]+1
                    q.append((nx,ny))
    
    if dist[-1][-1] == 10**10:
        print(-1)
    else:
        print(count-dist[-1][-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 44140
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 100005;
ll gr[MAX];
vector<ll> children[MAX];
vector<ll> G[MAX];
ll parent[MAX];

void grundy(ll x) {
	ll ans = 0;
	for (ll i = 0; i < children[x].size(); i++) {
		ll c = children[x][i];
		ll cnt = 1 + gr[c];
		ans ^= cnt;
	}
	gr[x] = ans;
}

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n - 1) {
		ll x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	stack<ll> st1,st2;
	st1.push(1); st2.push(1);
	parent[1] = 1;
	while (!st1.empty()) {
		ll cur = st1.top();
		st1.pop();
		for (ll i = 0; i < G[cur].size(); i++) {
			ll next = G[cur][i];
			if (next != parent[cur]) {
				children[cur].push_back(next);
				parent[next] = cur;
				st1.push(next);
				st2.push(next);
			}
		}
	}
	while (!st2.empty()) {
		ll cur = st2.top();
		st2.pop();
		grundy(cur);
	}
	if (gr[1] == 0) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    double R, ans;
    cin >> R;
    ans = 2*R*M_PI;
    printf("%f", ans);
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  int ans=1000000000;
  for(int p=1;p<101;p++){
    int cost=0;
    for(int j=0;j<N;j++){
      cost+=(vec[j]-p)*(vec[j]-p);
    }
      ans=min(ans,cost);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  int n,m;
  cin>>m>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin>>x[i];
  sort(x.begin(),x.end());
  vector<int> sa(n-1);
  for(int i=0;i<n-1;i++)sa[i]=abs(x[i]-x[i+1]);
  sort(sa.begin(),sa.end());
  int sum=0;
  for(int i=0;i<n-m;i++)sum+=sa[i];
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    A, Z = MAX, 0

    for i in range(len(S)):
        if S[i] == 'A':
            A = min(A, i)
        elif S[i] == 'Z':
            Z = max(Z, i)
    print(Z - A + 1)


if __name__ == '__main__':
    main()


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint keta(llint n) {
    llint ans = 0;

    while(n>0) {
        n /= 10;
        ans++;
    }
    return ans;
}

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

    llint a, b;
    for(llint in=1;in<sqrt(n)+1;in++) {
        if(n%in==0) a = in;
    }
    b = n / a;
    if(a<b) swap(a, b);
    
    cout << keta(a) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define testcase int t;cin>>t;while(t--)
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define P pair<int,int>
/*bool isprime(lli n)
{
    if(n==1) return 0;
    for(lli i=2;i<=n/2;i++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}
bool issemiprime(lli n)
{
    for(int i=2;i<n;i++)
    {
        if(isprime(i)&&isprime(n/i)&&n%i==0&&i!=n/i){
            return 1;
        }
    }
    return 0;
}
lli extendedgcd(lli q,lli r1,lli r2,lli r,lli s1,lli s2,lli s,lli t1,lli t2,lli t)
{
if(r2==0) return r1;
	r1=r2;
        r2=r;
        s1=s2;
        s2=s;
        t1=t2;
        t2=t;
        q=r1/r2;
        r=r1%r2;
        s=s1-(s2*q);
        t=t1-(t2*q);
return extendedgcd(q,r1,r2,r,s1,s2,s,t1,t2,t);
}
lli gcd(lli a,lli b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
void SOE()
{
    for(lli i=2;i<=100000;i++)
    {
        if(sieve[i]) continue;
        for(lli x=i;x<=100000;x+=i)
        {
            sieve[x]+=1;
        }
    }
}*/
/*bool func(pair<int,int> a,pair<int,int> b)
{
    return a.first<b.first;
}*/
int dp[1000000];
int dfs(vector<vector<int>> g,int n)
{
    if(g[n].size()==0) return 0;
    if(dp[n]!=-1) return dp[n];
    for(auto x:g[n])
    {
        dp[n]=max(dp[n],1+dfs(g,x));
    }
    return dp[n];
}
void solve()
{
    lli a,b;
    cin>>a>>b;
    char arr[a][b];
    lli dp[a][b];
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            cin>>arr[i][j];
        }
    }
    dp[0][0]=1;
    for(lli i=0;i<a;i++)
    {
        for(lli j=0;j<b;j++)
        {
            if(i==0&&j==0) continue;
            if(arr[i][j]=='#') dp[i][j]=0;
            else if(i==0)
            {
                dp[i][j]=dp[i][j-1];
            }
            else if(j==0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
            }
        }
    }
    cout<<dp[a-1][b-1];
}
int main()
{
    fast_io;
    solve();
}


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

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

int main() {
    int h, w; cin >> h >> w;
    vector<string> c(h);
    for(int i = 0; i < h; i++) cin >> c[i];

    for(int i = 0; i < h; i++){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
roads = list(map(int, input().split()))
cost_total = 0
tmp = 0
roads = [0] + roads
roads.append(0)
for i in range(1, n+1):
    cost_total += abs(roads[i] - tmp)
    tmp = roads[i]
cost_total += abs(roads[n])
l = 0
c = roads[1]
for i in range(n):
    ans = cost_total
    r = roads[i+2]
    ans = ans + abs(r-l) - abs(r-c) - abs(c-l)
    print(ans)
    l, c = c, r


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int d; cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main(){
	 int N;
  cin >> N;
  vector<int> A(N);
  int SUM = 0;
  rep(i, N) {
    cin >> A[i];
    SUM += A[i];
  }
  int AVG1 = SUM / N;
  int AVG2 = AVG1 + 1;
 
  int ANS1 = 0;
  int ANS2 = 0;
  rep(i, N) {
    int diff1 = A[i] - AVG1;
    ANS1 += diff1 * diff1;
    int diff2 = A[i] - AVG2;
    ANS2 += diff2 * diff2;
  }
  cout << min(ANS1, ANS2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

        int m1,d1,m2,d2;
        cin>>m1>>d1>>m2>>d2;
      if(m1!=m2) cout<<"1";
      else cout<<"0";
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
N, M = map(int, input().split())
A = tuple([int(s) for s in input().split()])
m = (0, 2, 5, 5, 4, 5, 6, 3, 7, 6)
dp = [None for _ in range(N+1)]
dp[0] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for n in range(2, N+1):
    for a in A:
        dn = m[a]
        if n - dn < 0 or dp[n - dn] is None:
            continue
        state = dp[n - dn][:]
        state[0] += 1
        state[10 - a] += 1
        if dp[n] is None:
            dp[n] = state
        else:
            dp[n] = max(dp[n], state)
for i in range(1, 10):
    print(str(10-i) * dp[N][i], end="")
print("")


Measured memory_bytes: 5236
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

void Solve(){
    UL n; cin >> n;
    UL x[1000]; rep(i, n) cin >> x[i];
    sort(x, x+n);
    cout << (x[n-1] - x[0] + 1) / 2 << endl;
}

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



Measured memory_bytes: 3164
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	string a = "abcdefghijklmnopqrstuvwxyz";
	int res = -1;
	for (int i = 0; i < a.size(); i++) {
		if (s.find(a.at(i)) == string::npos) {
			res = i;
			break;
		}
	}
	if (res == -1) {
		cout << "None";
	} else {
		cout << a.at(res);
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1e6;
const LL OO=1e18;

const int N=1e5,M=1e6;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int head[N],nxt[M],to[M],w[M],tot=1;
int q[N],cur[N],dep[N],S,T,all;
inline void link(int a,int b,int _w) {
	to[++tot]=b,nxt[tot]=head[a],head[a]=tot,w[tot]=_w;
	to[++tot]=a,nxt[tot]=head[b],head[b]=tot,w[tot]=0;
}
inline bool bfs() {
	int i,k,l,r;
	for (i=1;i<=all;i++) dep[i]=0;
	for (l=0,dep[q[r=1]=T]=1;l!=r;)
		for (i=head[k=q[++l]];i;i=nxt[i])
			if (w[i^1]&&!dep[to[i]])
				dep[q[++r]=to[i]]=dep[k]+1;
	return dep[S];
}
inline int dfs(int k,int low) {
	if (k==T) return low;
	int s=0,x;
	for (int &i=cur[k];i;i=nxt[i])
		if (w[i]&&dep[to[i]]==dep[k]-1)
			if (x=dfs(to[i],min(low-s,w[i]))) {
				s+=x,w[i]-=x,w[i^1]+=x;
				if (s==low) return s;
			}
	return s;
}

bool o[110][110];
int main()
{
	int n=gi(),m=gi(),i,j,t;char c;
	all=n*m*2+n+m;
	for (i=t=1;i<=n;i++)
		for (j=1;j<=m;j++,t++) {
			while ((c=getchar())!='.'&&c!='o'&&c!='S'&&c!='T');
			o[i][j]=c!='.';
			if (c=='S') S=t*2;
			if (c=='T') T=t*2-1;
		}
	for (i=t=1;i<=n;i++)
		for (j=1;j<=m;j++,t++)
			if (o[i][j]) {
				link(t*2-1,t*2,1);
				link(t*2,n*m*2+i,oo);
				link(n*m*2+i,t*2-1,oo);
				link(t*2,n*m*2+n+j,oo);
				link(n*m*2+n+j,t*2-1,oo);
			}
	int ans=0;
	while (bfs()) {
		for (i=1;i<=all;i++) cur[i]=head[i];
		ans+=dfs(S,oo);
	}
	printf("%d\n",ans>n*m?-1:ans);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  //入力を受け取る
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int now = 0,c = 0;
  while(true){
    if(now == 1){
      cout << c << endl;
      break;
    }
    if(c >= N){
      cout << (-1) << endl;
      break;
    }
    now = vec[now] - 1;
    c++;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int k,a,b;
    cin >> k >> a >> b;
    int sta = b/k;
    int sta2 = (a-1)/k;
    if(sta2 != sta)cout << "OK\n";
    else cout << "NG\n";
    return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;

  while(1){

    
    cin>>str;
    
    int a[4];
    
    if(str=="0000"){
      break;
    }else if(str[0]==str[1]&&str[1]==str[2]&&str[2]==str[3]){
      cout<<"NA"<<endl;
      continue;
    }

    for(int i=0;i<4;i++){
      a[i]=str[i]-'0';
    }
    int cnt=0;

    while(1){

      int c[4];

      c[0]=a[0];
      c[1]=a[1];
      c[2]=a[2];
      c[3]=a[3];

      
      if(c[0]==6&&c[1]==1&&c[2]==7&&c[3]==4){
	break;
      }
      
      sort(a,a+4);
      
      int cnt1=a[0]*1000+a[1]*100+a[2]*10+a[3];
      int cnt2=a[3]*1000+a[2]*100+a[1]*10+a[0];
      
      cnt2=cnt2-cnt1;
      
      c[3]=cnt2%10;
      cnt2/=10;
      c[2]=cnt2%10;
      cnt2/=10;
      c[1]=cnt2%10;
      cnt2/=10;
      c[0]=cnt2%10;


      cnt++; 

      a[0]=c[0];
      a[1]=c[1];
      a[2]=c[2];
      a[3]=c[3];

    }

    cout<<cnt<<endl;
  }

  return 0;

}



Measured memory_bytes: 3228
/**
 * @author      : omgursocute
 * @created     : 19/01/2020
 * @task        : A
 */

// ==== CODE STARTS AT LINE 53 ==== //

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair

#define sqr(x) 1ll*(x)*(x)
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n';

namespace io {
	void openIn(string s) {freopen(s.c_str(), "r", stdin);}
	void openOut(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s = "") {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
		if(s.size()) {openIn(s + ".inp"); openOut(s + ".out");}
	}
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::setIO("");

	char c;
	cin >> c;
	cout << char(c+1);

	return 0;
}



Measured memory_bytes: 256
# coding: utf-8
MOD = 10**9+7

# 二分累積法による a^n mod の計算
def modpow(a, n):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % MOD
        a = a * a % MOD
        n >>= 1
    return res

# nCr mod.p (n <= 10**6)
MAX = 1000010
fac = [0] * MAX 
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
# より高速化が必要な場合
def COM(n, k):
    res = 1
    for i in range(k):
        res = res * (n-i) % MOD
    return res * finv[k] % MOD

COMinit()
n, a, b = map(int, input().split())
tot = modpow(2,n) - 1
ans = (tot - COM(n,a) - COM(n,b)) % MOD
print(ans)

Measured memory_bytes: 121716
#include<iostream>
#include<cstdlib>
int main(){
  int n,index,i,j,flag;
  int x[100],y[100],h[100];
  int px,py,ph;
  int xt=0,yt=0,ht=0;
  int pc;
  int cx,cy,ch;
  std::cin>>n;
  for(index=0;index<n;index++){
    std::cin>> x[index] >>y[index] >> h[index];
    if(h[index] >= 1 && ht == 0){
      xt=x[index];
      yt=y[index];
      ht=h[index];
    }
    else{
    }
  }
  for(px=0;px<=100;px++){
    flag=0;
    for(py=0;py<=100;py++){
      flag=0;
      ph=ht+abs(px-xt)+abs(py-yt);
      for(index=0;index<n;index++){
	pc= std::max(ph-abs(px-x[index])-abs(py-y[index]),0);
	if(pc != h[index]){
	  flag=1;
	  break;
	}
      }
      if(flag == 0){
	std::cout << px <<" " << py << " "<< ph <<std::endl;
      }
    }
  }
  return 0;
}


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

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int start = (h1 * 60) + m1;
  int end = (h2 * 60) + m2;

  int ans = end - start - k;

  if (ans < 0) cout << 0 << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int A[20];
int n;

int solve(int p, int t);
int sort(void *a, void *b);

int main(void) {
	int i, q, M;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	
	qsort(A, n, sizeof(A[0]), sort);
	
	scanf("%d", &q);
	for (i = 0; i < q; ++i) {
		scanf("%d", &M);
		if (solve(-1, M)) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	
	return 0;
}

int solve(int p, int t) {
	if ((p == n) || (t == 0)) return t == 0;
	if ((t >= A[p + 1]) && (solve(p + 1, t - A[p + 1]))) return 1;
	return solve(p + 1, t);
}

int sort(void *a, void *b) {
	return *(int*)a - *(int*)b;
}

Measured memory_bytes: 584
import Control.Monad

main :: IO ()
main = do
  [n,m] <- rListM :: IO [Int]
  dat <- concat <$> replicateM m rListM :: IO [Int]
  putStrLn . unlines $ fmap (show . countc dat) [1..n]

rListM :: Read a => IO [a]
rListM = fmap read . words <$> getLine

countc :: Eq t => [t] -> t -> Int
countc ls con = length $ filter (con == ) ls

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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int N;
string S;

void solve() {
    cin >> N >> S;
    int p = 0;
    REP(i,1,N) {
        if (S[i] == 'E') p++;
    }
    int ans = p;
    REP(i,1,N) {
        if (S[i-1] == 'W') p++;
        if (S[i] == 'E') p--;
        ans = min(p, ans);
    }
    cout << ans << endl;
}

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

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll d,t,s;
    cin >> d >> t >> s;
    Yes(d<=t*s);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main(){
    int k,n;
    int *a;
    int i,j,max = 0,count = 0;
    int *dis;

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

    a = (int*)malloc(sizeof(int) * n);
    dis = (int*)malloc(sizeof(int) * n);  

    for(i = 0; i < n; i++){
        scanf("%d" ,(a+i));
    }

    for(i = 0; i < n-1; i++){
        dis[i] = a[i+1] - a[i];
    }
    dis[n-1] = (k - a[n-1]) + a[0];
    
    for(i = 1; i < n; i++){
        if(dis[i] > max){
            max = dis[i];
        }
    }

    printf("%d\n" ,k-max);


    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  char c; cin >> c;
  cout << (c == 'A' ? 'T' : c == 'T' ? 'A' : c == 'C' ? 'G' : 'C');
}


Measured memory_bytes: 256
from math import ceil 
x,k,d = list(map(int,input().split()))

xi = abs(x)
if abs(x) > d*k:
  m = min(abs(x+d*k),abs(x-d*k))
else:
  n = ceil(xi / d)
  if (n+k) % 2 == 0:
    m = abs(xi-d*n)
  else:
    m = abs(xi-d*(n-1))
print(m)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
		int x = 0, f = 1; char ch = getchar();
		while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
		while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
		return x * f;
}
const int N = 3e5 + 10;
int n;
map<int, int> s;
int a[N];
int main()
{
	n = read();
	rep(i, 1, n)
	{
		a[i] = read();
		s[a[i]] ++;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int ans[3], cnt = 0;
	ans[2] = 0;
	rep(i, 1, n)
	{
		if(cnt == 2) break;
		if(s[a[i]] >= 2) ans[++ cnt] = a[i], s[a[i]] -= 2, i ++;
	}
	cout << (ll)ans[1] * ans[2];
	return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 577;
const ll INF = LLONG_MAX / 2;

int N;
ll A[MAX_N][MAX_N], cost1[MAX_N][MAX_N], cost2[MAX_N][MAX_N];
ll dp[MAX_N][MAX_N];

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i == j) continue;
            scanf("%lld", &A[i][j]);
            if (i < j) cost1[i][j] = A[i][j];
            else cost2[j][i] = A[i][j];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cost1[i][j] += cost1[i][j - 1];
        }
    }
    for (int i = N; i; i--) {
        for (int j = 1; j <= N; j++) {
            cost1[i][j] += cost1[i + 1][j];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = N; j; j--) {
            cost2[i][j] += cost2[i][j + 1];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cost2[i][j] += cost2[i - 1][j];
        }
    }
    for (int i = 1; i < N; i++) {
        dp[0][i] = cost1[1][i];
        for (int j = 1; j < i; j++) {
            dp[j][i] = INF;
            for (int k = 0; k < j; k++) {
                dp[j][i] = min(dp[j][i], dp[k][j] + cost1[j + 1][i] + cost2[j][i + 1] - cost2[k][i + 1]);
            }
        }
    }
    ll ans = INF;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < i; j++) {
            ans = min(ans, dp[j][i] + cost1[i + 1][N]);
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 10496
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

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

  vector<vector<vector<string>>> tbl(21, vector<vector<string>>(10));

  ll cnt = 0;
  string ans;

  rep(i, 10) {
    string add = to_string(i);
    tbl[1][i].push_back(add);
    if (i != 0) cnt++;
    if (cnt == k) {
      ans = add;
      cout << ans << endl;
      return 0;
    }
  }

  for (ll i = 1; i <= 21; i++) {
    for (ll j = 0; j <= 9; j++) {
      for (ll d = -1; d <= 1; d++) {
        bool docond = j + d >= 0 && j + d <= 9;
        if (!docond) continue;
        for (size_t ii = 0; ii < tbl[i][j + d].size(); ii++) {
          string add = to_string(j) + tbl[i][j + d][ii];
          tbl[i + 1][j].push_back(add);
          if (j != 0) cnt++;
          if (cnt == k) {
            ans = add;
            cout << ans << endl;
            return 0;
          }
        }  // ii
      }    // d
    }      // j
  }        // i

  return 0;
}



Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,s1,s2,s3;
  cin >> a ;
  s1 = a / 100;
  s2 = a - s1 * 100;
  s2 = s2 / 10;
  s3 = a - (s1 * 100 + s2 * 10);
  a = s1 + s2 + s3;
  cout << a << endl;   
 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){double a,b,n,m;
scanf("%lf%lf%lf%lf",&a,&b,&n,&m);
n=30.0*(n+m/60.0);m=m*6.0;
printf("%.10f",sqrt(a*a+b*b-2*a*b*cos((n-m)/360.0*2.0*M_PI)));return 0;}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  long int N, ans;
  cin >> N;
  ans = N-1;
  for(int i=1;i<1000001;i++){
    if((N % i == 0)){
      ans = min(ans, (N/i + i -2));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
    LL a, b, c;
    cin >> a >> b >> c;
    LL ans = b;
    ans += min(c, a+b+1);
    cout << ans << endl;


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace TOPSIC
{
	public class Program
	{
		/// <summary>
		/// ABC 102
		/// </summary>
		public static void Main()
		{
			var n = int.Parse(ReadLine());
			var list = ReadLine().Split().Select(x => int.Parse(x)).ToList();

			var ans = list.Max() - list.Min();
			WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    vector<ll> S(n + 1);
    S[0] = 0;
    for(int i = 0; i < n; ++i){
        cin >> S[i + 1];
        S[i + 1] += S[i];
    }
    ll ans = 1e+15;
    for(int i = 2; i <= n - 2; ++i){
        int lb = 1, ub = i;
        while(ub - lb > 1){
            int mid = (lb + ub) >> 1;
            if(S[mid] * 2 <= S[i])  lb = mid;
            else    ub = mid;
        }
        vector<ll> p, q;
        p.emplace_back(S[lb]);
        q.emplace_back(S[i] - S[lb]);
        if(ub < i){
            p.emplace_back(S[ub]);
            q.emplace_back(S[i] - S[ub]);
        }
        lb = i + 1, ub = n;
        while(ub - lb > 1){
            int mid = (lb + ub) >> 1;
            if((S[mid] - S[i]) * 2 <= S[n] - S[i])  lb = mid;
            else    ub = mid;
        }
        vector<ll> r, s;
        r.emplace_back(S[lb] - S[i]);
        s.emplace_back(S[n] - S[lb]);
        if(ub < n){
            r.emplace_back(S[ub] - S[i]);
            s.emplace_back(S[n] - S[ub]);
        }
        int n1 = p.size(), n2 = r.size();
        for(int j = 0; j < n1; ++j){
            for(int k = 0; k < n2; ++k){
                ll maxe = max({p[j], q[j], r[k], s[k]});
                ll mine = min({p[j], q[j], r[k], s[k]});
                chmin(ans, maxe - mine);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    int a[10000];
    int ans=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        while(a[i]%2==0){
            ans++;
            a[i]=a[i]/2;
        }
    }
    cout << ans << endl;
    
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




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

int main(){
  int N;
  cin >> N;
  ll arr[100005];
  for (int i=0;i<N;i++){
    cin >> arr[i];
  }
  int a=0;
  for(int i=0;i<N;i++){
    if(arr[i]==0){
      a++;
    }
  }
  if(a>0){
    cout << "0" <<endl;
    return 0;
  }
  ll x = 1;
  for(int i=0;i<N;i++){
    if(arr[i]<=1000000000000000000/x){
      x*=arr[i];
    }else{
      cout << "-1" << endl;
      return 0;
    }
  }

  cout << x << endl;

  return 0;

}


Measured memory_bytes: 4428
a,b,c,d=[int(i) for i in input().strip().split(' ')]

'''
入力は他の人のを見た
'''

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)



Measured memory_bytes: 3060
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i * 500 + j * 100 + k * 50 == x:
        ans += 1
print(ans)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int u=n-i*r-j*g;
            if(u<0){
                break;
            }
            if(u%b==0){
                ans++;
            }
        }
    }

    cout<<ans;



}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, k;
    cin >> n >> k;

    // 処理
    // 出力
    cout << ((n % k == 0) ? 0 : 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in(),k=in();
    vecll s1(n+1),s2(n+1);
    s1[0]=s2[0]=0;
    rep(i,n){
        int x=in();
        s1[i+1]=s1[i]+x;
        s2[i+1]=max(0,x)+s2[i];
    }
    ll ans=0;
    rep(i,n-k+1)ans=max(ans,s2[n]-s2[i+k]+s2[i]+max(s1[i+k]-s1[i],0ll));
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = Console.ReadLine();
            string nickname = name.Substring(0, 3);
            Console.WriteLine(nickname);
        }
    }
}

Measured memory_bytes: 25888