akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  cin>>N>>M;
  if(N<M)cout<<0<<endl;
  else cout<<10<<endl;
  
}


Measured memory_bytes: 256
import math
data_dim = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
D_1=0
D_2=0
D_3=0
D_inf=0

for i in range(data_dim):
    D_1 += abs(x[i]-y[i])
    D_2 += abs(x[i]-y[i])**2
    D_3 += abs(x[i]-y[i])**3
    D_inf = max(D_inf,abs(x[i]-y[i]))

print("%f"%(D_1))
print("%f"%(math.sqrt(D_2)))
print("%f"%(math.pow(D_3,1/3)))
print("%f"%(D_inf))



Measured memory_bytes: 5688
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  string s;
  int k;
  cin>>s>>k;
  vector<string> v;
  for(int i=0; i<s.size(); i++) {
    for(int cnt=1; cnt<=5; cnt++) {
      string sub = s.substr(i, cnt);
      v.push_back(sub);
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  std::cout << v[k-1] << std::endl;
  return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N, M;
	cin >> N >> M;

	int sum = 0;

	map <ll, ll> mp;

	while(N--)
	{
		int a;
		cin >> a;
		sum += a;
		sum %= M;
		mp[sum]++;
	}

	ll ans = mp[0];

	for (auto p : mp)
	{
		ans += p.snd * (p.snd - 1) / 2;
	}

	cout << ans << endl;


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 4224
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


_,k = LI()
a = LI()

a = list(map(lambda x:x-1,a))

# 訪れる順序、indexは移動回数
route = [0]
# 訪れた番号、高速検索用にhash tableを使う
visited = set([0])
next = a[0]

while True:
    if next in visited:
        loopStart = route.index(next)
        break
    else:
        route.append(next)
        visited.add(next)
        next = a[next]

# print(route)
# print(loopStart)

beforeLoop = route[:loopStart]
# print(beforeLoop)
loop = route[loopStart:]
# print(loop)

# loop前
if k < loopStart:
    ans = beforeLoop[k]
# loop後
else:
    numOfLoops,mod = divmod((k-(loopStart)),len(loop))
    # print(numOfLoops,mod)
    ans = loop[mod]

ans += 1
print(ans)

Measured memory_bytes: 32520
#include <stdio.h>
int main(void) {
	int n, a, b, tmp;

	scanf("%d", &n);
	a = b = 1;
	while (n--) {
		tmp = b;
		b = a + b;
		a = tmp;
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
  Cin(ll, n);
  int k = sqrt(n);
  Cout(k*k);
}


Measured memory_bytes: 256
def main():
    paths = [0]*4
    for i in range(3):
        a,b = map(int, input().split())
        paths[a-1] += 1
        paths[b-1] += 1
    paths.sort()
    if paths == [1,1,2,2] or paths == [0,0,0,3]:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int n[10],ba,i,j,nn,tem;
  char yama[101];  

  while(1){
    scanf("%d",&nn);
    if(nn==0) break;
    ba=0;
    for(i=0;i<nn;i++) n[i]=0;
    scanf("%s",yama);
    for(i=0;i<100;i++){
      if(yama[i]=='M') n[i%nn]++;
      else if(yama[i]=='S'){
	ba += n[i%nn]+1;
	n[i%nn] = 0;
      }
      else if(yama[i]=='L'){
	n[i%nn]+=ba+1;
	ba=0;
      }	
    }
    for(i=0;i<nn-1;i++){
      for(j=i+1;j<nn;j++){
	if(n[i]>n[j]){
	  tem=n[i];
	  n[i]=n[j];
	  n[j]=tem;
	}
      }
    }
    for(i=0;i<nn;i++) printf("%d ",n[i]);
    printf("%d\n",ba);		     
  }
  return 0;
}

Measured memory_bytes: 604
//
// Created on 2020/07/30.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    cin>>n;
    vector<int>h(n,0);
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
        int l;
        int r;
        bool ok = false;
        for (int j = 0; j < n; ++j) {
            if(h[j] >= i && !ok){
                ok = true;
            }else if(h[j] >= i && ok){
                continue;
            }else if(h[j] < i && ok){
                ok = false;
                ans ++;
            }else if(h[j] < i && !ok){
                continue;
            }
        }
        if(ok){
            ans ++;
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3628
mod=10**9+7
n,k=map(int,input().split())
def inv(x):
    return pow(x,mod-2,mod)
MAX_N=2*10**5
Fact=[0 for i in range(MAX_N+1)]
Finv=[0 for i in range(MAX_N+1)]
Fact[0]=1
for i in range(MAX_N):
    Fact[i+1]=(i+1)*Fact[i]
    Fact[i+1]%=mod
Finv[-1]=inv(Fact[-1])
for i in range(MAX_N-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)
    Finv[i]%=mod
def C(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%mod)%mod

'''
for N in range(n,n+1):
    for K in range(N):
        print(C(N,K)*C(N-1,K),end=" ")
    print("")
'''
ans=0
for i in range(min(n,k+1)):
    ans+=(C(n,i)*C(n-1,i))%mod
    ans%=mod
    #print(ans)
print(ans)

Measured memory_bytes: 55372
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC088B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var a = ReadInts;
            a = a.OrderByDescending(x => x).ToArray();

            int alice = 0;
            int bob = 0;
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    alice += a[i];
                }
                else
                {
                    bob += a[i];
                }
            }
            Console.WriteLine(alice - bob);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String sb1 = br.readLine();
        String[] a = sb1.split(" ");
        long[] c = new long[a.length];
        long[] b = new long[a.length];
        long d  = 2019;
        for(int i = 0;i < a.length;i++){
            c[i] = Long.parseLong(a[i]);
            b[i] = c[i]/d;
        }
        
        if(b[0] == b[1]){
            for (long i = c[0]; i < c[1]; i++) {
                for (long j = i+1; j <= c[1]; j++) {
                    long e = i % 2019;
                    long f = j % 2019;
                    long g = e * f;
                    d = Math.min(d, g % 2019);
                }
            }
            System.out.println(d);
        }  else {
            System.out.println(0);
        }
        
    }
}

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

using namespace std;

long long inf = (1LL << 62LL);

int N;
long long tree[8005];

void update(int i, long long v){
	for(i += N;i > 0;i >>= 1) tree[i] = min(tree[i], v);
}

long long query(int l, int r){
	long long res = inf;
	for(l += N, r += N;l < r;l >>= 1, r>>= 1){
		if(l&1) res = min(res, tree[l++]);
		if(r&1) res = min(res, tree[--r]);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	long long n, x; cin >> n >> x;
	N = 2 * n;
	
	fill(tree,tree+8005, inf);
	
	for(int i = 0;i < n;i++){
		long long a; cin >> a;
		update(i, a);
		update(i + n, a);
	}
	
	long long ans = inf;
	for(long long take = 0;take < n;take++){
		long long res = take * x;
		for(int i = 0;i < n;i++){
			long long r = i + n;
			long long l = r - take;
			res += query(l,r+1);
		}
		//cout << res << "\n";
		ans = min(res, ans);
	}
	
	cout << ans;
}


Measured memory_bytes: 384
s = list(input())
ans = 'AC'
tmp = [0]
if s[0] != 'A':
    ans = 'WA'
for i in range(2, len(s)-1):
    if s[i] == 'C':
        tmp.append(i)
if len(tmp) != 2:
    ans = 'WA'
for i in range(len(s)):
    if not i in tmp:
        if not s[i].islower():
            ans = 'WA'
    else:
        pass
print(ans)


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 v : m) os << v << ",";
  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() {
  LL n, m;
  cin >> n >> m;
  LL ans = 0;
  for (LL a = 1; a * a <= m; ++a) {
    if (m % a != 0) continue;
    LL b = m / a;
    if (a >= n) ans = max(ans, b);
    if (b >= n) ans = max(ans, a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


long long dp[305][305][305];
signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  int n, K;
  cin >> n >> K;
  vi a(n + 1), b(n + 1);
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0] = 0;
  for(int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(all(b));
  vi p(n + 1);
  for(int i = 1; i <= n; ++i) {
    p[i] = lower_bound(all(b), a[i]) - b.begin();
  }
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= n; ++j) {
      for(int k = 0; k <= K; ++k) {
        if(b[j] != a[i + 1]) {
          dp[i + 1][j][k + 1] = min(dp[i + 1][j][k + 1], dp[i][j][k]);
          if(b[j] >= a[i + 1]) {
            dp[i + 1][p[i + 1]][k] = min(dp[i + 1][p[i + 1]][k], dp[i][j][k]);
          } else {
            dp[i + 1][p[i + 1]][k] = min(dp[i + 1][p[i + 1]][k], dp[i][j][k] + a[i + 1] - b[j]);
          } 
        } else {
          dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        }
      }
    }
  }
  long long res = INF;
  for(int i = 0; i <= n; ++i) {
    res = min(dp[n][i][K], res);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 221952
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


bool is_Leap(int n){
	if(n%400==0)return true;
	if(n%100==0)return false;
	if(n%4==0)return true;
	return false;
}


int main(){
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int y1,y2,m1,m2,d1,d2;
	ll ans=0;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
		ans=0;
		if(d1==-1&&d2==-1)break;
		if(y1<y2){
			if(is_Leap(y1)){
				ans+=b[m1-1]-d1+1;
				for(int i=m1; i<12; i++){
					ans+=b[i];
				}
			}
			else{
				ans+=a[m1-1]-d1+1;
				for(int i=m1; i<12; i++){
					ans+=a[i];
				}
			}
			m1=1;
			d1=1;
		}
		y1++;
		while(y1<y2){
			if(is_Leap(y1))ans+=366;
			else ans+=365;
			y1++;
		}
		for(int i=m1-1; i<m2-1; i++){
			if(is_Leap(y1))ans+=b[i];
			else ans+=a[i];
			//d1=1;
		}
		ans+=d2-d1;
		cout<<ans<<endl;
	}
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll n, m;
bool b[100][100];

void f(int y, int x) {
   for (int i = -1; i <= 1; i++) {
      for (int j = -1; j <= 1; j++) {
         int ny = y + i, nx = x + j;
         if (ny < 0 || ny >= n || nx < 0 || nx >= m) continue;
         b[ny][nx] = !b[ny][nx];
      }
   }
}

void t(bool ok) {
   if (ok) cout << 'o';
   else cout << 'x';
}

void print() {
   rep (i, n) {
      rep (j, m) {
         t(b[i][j]);
      }
      puts("");
   }
}

int main() {
   cin >> n >> m;
   if (n > m) swap(n, m);
   // rep (i, n) { rep (j, m) { f(i, j); } }
   // print();
   if (n == 1 && m == 1) {
      cout << 1 << endl;
      return 0;
   }

   if (n >= 3) {
      cout << max(0LL, n*m - 2*n - 2*m + 4) << endl;
   } else if (n == 1) {
      cout << max(0LL, m - 2) << endl;
   } else if (n == 2) {
      cout << 0 << endl;
   }

   return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
X = int(input().strip())


def solve():
    nums = [i ** 5 for i in range(-1000, 1000)]
    ans = set()
    for A in nums:
        for B in nums:
            if A - B == X:
                a = 0 if A == 0 else int(A / abs(A) * (abs(A) ** 0.2))
                b = 0 if B == 0 else int(B / abs(B) * (abs(B) ** 0.2))
                print(a, b)
                exit()

solve()


Measured memory_bytes: 9516
import sys
import bisect
input = sys.stdin.readline

class Bisect(object):
    def bisect_max(self, reva, func,M):
        ok = 0 # exist
        ng = 2*(10**5)+1 # not exist
        while abs(ok-ng) > 1:
            cnt = (ok + ng) // 2
            if func(cnt,reva,M):
                ok = cnt
            else:
                ng = cnt
        return ok

def solve1(tgt,reva,M):
    res=0
    n = len(reva)
    if (n - bisect.bisect_left(reva,tgt-reva[n-1]))*n < M:
        return False
    for i in range(n):
        res += n - bisect.bisect_left(reva,tgt-reva[n-i-1])
        if M <= res:
            return True
    return False

N,M = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
reva = a[::-1]
bs = Bisect()
Kmax = (bs.bisect_max(reva,solve1,M))

r=[0]
for i in range(N):
    r.append(r[i]+a[i])

res = 0
cnt = 0
t = 0
for i in range(N):
    tmp = bisect.bisect_left(reva,Kmax-reva[N-i-1])
    tmp2 = bisect.bisect_right(reva,Kmax-reva[N-i-1])
    if tmp!=tmp2:
        t = 1
    tmp = N - tmp
    cnt += tmp
    res += tmp*a[i]+r[tmp]
if t==1:
    res -= (cnt-M)*Kmax
print(res)


Measured memory_bytes: 58932
from collections import deque
N, M = map(int, input().split())
X = list(map(int, input().split()))
sortX = sorted(X)
dist = []
if N-M>=0:
    print(0)
else:
    for i in range(M-1):
        dist.append(sortX[i + 1] - sortX[i])
    dist.sort()
    print(sum(dist[:M-N]))

Measured memory_bytes: 14216
/**
 * Range.cpp
 * Create:20180417
 * Description:三つの数値a,b,cを読み込み、
 * a<b<cを満たす場合のみYes、それ以外をNoと表記するプログラム
 */
#include <iostream>

int main(int argc, char* argv[]){
  int a, b, c;

  std::cin >> a >> b >> c;

  if (a < b && b < c){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string S;
  cin >> S;
  set<char> H;
  rep(i, S.size())
  {
    if (H.count(S.at(i)) == 0) {
      H.insert(S.at(i));
      continue;
    }
    cout << "no" << endl;
    return 0;
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s, t = map(int, input().split())

l = [[] for u in range(n + 1)]
for u, v in uv:
    l[u].append(v)

def bfs(v):
    q = [(x, 0) for x in list(v)]
    index = 0
    ret = set()
    while len(q) > index:
        x, step = q[index]
        index += 1
        if step == 3:
            ret.add(x)
            continue
        for y in l[x]:
            next = (y, step + 1)
            if next not in visited:
                visited.add(next)
                q.append(next)
    return ret

v = set([s])
visited = set([(s, 0)])
ret = 0
while True:
    v2 = bfs(v)
    if len(v2) == 0:
        ret = -1
        break
    ret += 1
    if t in v2:
        break
    v = v2

print(ret)

Measured memory_bytes: 95064
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#define pb push_back
#define INF 999999;

using namespace std;

typedef long long ll;

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

	int linhas, colunas;
	cin >> linhas >> colunas;
	char matrix[linhas][colunas];
	ll dp[linhas][colunas];

	for(int i = 0; i < linhas; i++){
		for(int j = 0; j < colunas; j++){
			cin >> matrix[i][j];
			dp[i][j] = 0;
			if(matrix[i][j] == '#'){
				dp[i][j] = 0;
			}
		}
	}
	dp[0][0] = 1;
	//preprocessou a primeira linha...
	for(int i = 1; i < colunas; i++){
			if(matrix[0][i] == '#') continue;
			else{
				dp[0][i] = (dp[0][i - 1])%(1000000007);
			}
	}
	//preprocessou a primeira coluna
	for(int i = 1; i < linhas; i++){
		if(matrix[i][0] == '#') continue;
		else{
			dp[i][0] = (dp[i - 1][0])%(1000000007);
		}
	}
	for(int i = 1; i < linhas; i++){
		for(int j = 1; j < colunas; j++){
			if(matrix[i][j] != '#'){
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%(1000000007);
			}
		}
	}
	printf("%lld\n", dp[linhas - 1][colunas - 1]);
	return 0;
}

Measured memory_bytes: 9088
#include<cstdio>
#define N 150
#define p 1000000007
#define ll long long
int a[N],b[N],c[N],d[N],e[N],m,n,x,y;char s[N];bool t[N];
inline bool solve(int z)
{
    int i,j,k;
    for(i=1;i<=m;i++)t[i]=false;
    for(i=j=1;i<=y;d[i]=c[i]<2?0:c[i]-2,i++)i==y||c[i]!=c[i+1]?z=(ll)b[i-j+1]*z%p,j=i+1:0;
    for(i=1,j=k=y;i<=m;i++)
    if(s[i]=='r'&&c[j]>1)t[i]=true,j--;
    else if(s[i]=='b'&&j<k&&c[k]>1)t[e[k--]=i]=true;
    else if(s[i]=='r'&&c[j]==1)t[e[j--]=i]=true;
    if(j||c[k]>1)return false;
    for(i=1,j=y;i<=m&&j;!t[i]&&e[j]<i?d[j]--:0,i++)while(j&&!d[j])j--;
    while(j&&!d[j])j--;
    if(j)return false;
    return x=(x+(ll)z*a[y])%p,true;
}
void dfs(int u,int v,int w){if(solve((ll)a[v]*b[w]%p*b[v-w]%p))for(int i=u;0<=v-w-(i==1?2:i-1<<1);i++)dfs(c[++y]=i,v+(i==1?0:2),w+(i<<1)),y--;}
int main()
{
    scanf("%d%d%s",&n,&m,s+1),*a=a[1]=*b=b[1]=1;
    for(int i=2;i<N;i++)a[i]=(ll)a[i-1]*i%p,b[i]=(ll)(p-p/i)*b[p%i]%p;
    for(int i=2;i<N;i++)b[i]=(ll)b[i]*b[i-1]%p;
    dfs(1,n+1,0),printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((B * 10 + C) % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

vector<unsigned long> sosuu;
vector<long> cnt;
int num;

void calc(unsigned long n)
{
	unsigned long a;
	a = 2;
	num = -1;
	while (n >= a * a) {
		if (n % a == 0) {
//			printf("%d * ", a);
			if (num == -1) {
				sosuu.push_back(a);
				cnt.push_back(1);
				num++;
			}
			else {
				if (sosuu[num] == a) {
					cnt[num]++;
				}
				else {
					sosuu.push_back(a);
					cnt.push_back(1);
					num++;
				}
			}
			n /= a;
		}
		else {
			a++;
		}
	}
	if (num == -1) {
		sosuu.push_back(a);
		cnt.push_back(1);
		num++;
	}else if (sosuu[num] == n) {
		cnt[num]++;
	}
	else {
		sosuu.push_back(n);
		cnt.push_back(1);
		num++;
	}
//	cout << n << endl;
}

int main()
{
	unsigned long n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	calc(n);
	int ans = 0, i, j;
	for (i = 0; i <= num; i++) {
		for (j = 1; cnt[i] > 0; j++) {
			cnt[i] -= j;
			ans++;
		}
		if (cnt[i] < 0) {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
N, sum = [int(i) for i in input().split()]

for x in range(N+1):
	for y in range(N+1 - x):
		z = N - x - y
		if 10000*x + 5000*y + 1000*z == sum:
			print(x, y, N - x - y)
			exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const double eps=1e-16;
const int N=105;
int n,a[N],b[N];
using namespace std;

/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>n;
	int i;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1;i<=n;i++) cin>>b[i];
	for (i=1;i<=n;i++) a[i]+=a[i-1];
	for (i=n;i>=1;i--) b[i]+=b[i+1];
	int ans=0;
	for (i=1;i<=n;i++) ans=max(ans,a[i]+b[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
// atcoder/abc160/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  lli k, n;
  while (cin >> k >> n) {
    vec<lli> a(n);
    cin >> a;
    lli mn = 1LL << 60;
    for (int i = 0; i + 1 < n; ++i) {
      setmin(mn, k - (a[i + 1] - a[i]));
    }
    setmin(mn, k - (k - a.back()) - a.front());
    cout << mn << endl;
  }

  return 0;
}


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

int main() {
	int n, x; cin >> n >> x;
	int a[110];
	for (int i = 0; i < n; i ++) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n-1; i ++) {
		if (x >= a[i]) {
			ans ++; x -= a[i];
		} else {
			break;
		}
	}
	if (a[n-1] == x) ans ++;
	cout << ans << endl;
	
	return 0;
}

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

int info[4][4];
int main(){
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      cin>>info[i][j];
    }
  }
  int a[4],b[4];
  a[1]=0;
  for(int i=1;i<=3;i++){
    b[i]=info[1][i];
  }
  a[2]=info[2][1]-b[1];
  a[3]=info[3][1]-b[1];

  if(a[2]+b[2]==info[2][2]&&a[2]+b[3]==info[2][3]&&a[3]+b[2]==info[3][2]&&a[3]+b[3]==info[3][3])
   cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void move1(int disx, int disy) {
	int i;
	for (i = 0; i < disy; i++) 
		cout << 'U';
	for (i = 0; i < disx; i++)
		cout << 'R';
}

void move2(int disx, int disy) {
	int i;
	for (i = 0; i < disy; i++)
		cout << 'D';
	for (i = 0; i < disx; i++)
		cout << 'L';
}

int main()
{
	int sx, sy, tx, ty,disx,disy;
	cin >> sx >> sy >> tx >> ty;

	disx = tx - sx;
	disy = ty - sy;
	move1(disx, disy); 
	move2(disx, disy); cout << 'L';
	move1(disx + 1, disy + 1);cout << "DR";
	move2(disx + 1, disy + 1); cout << 'U' <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){

	while(1){
		char c = 'A';
		int maxi = 0;
		bool flag = 0;
		rep(i, 5){
			int a, b;
			cin >> a >> b;
			if(a == b && a == 0){flag = 1;break;}
			if(maxi <= (a+b)){
				maxi = a+b;
				c = 'A'+i;
			}
		}
		if(flag)break;
		cout << c << " " << maxi << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var n = lines[0];
  var as = lines[1].split(' ');
  var result = 0;
  for (a of as) {
    result += 1.0/a;
  }
  result = 1.0/result;
  console.log(result);
})

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF= 1LL << 62;

int main(){
    int N;
    cin >> N;
    LL a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }
    LL cnt=0;
    for(int i=N-1;i>=0;i--){
        if((a[i]+cnt)%b[i]==0) continue;
        cnt+=b[i]-(a[i]+cnt)%b[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      int[] data = new int[n];
      int sum = 0;
      int max = 0;
      for (int i = 0;i<n ;i++ ) {
        data[i] = sc.nextInt();
        max = Math.max(max,data[i]);
        sum += data[i];
      }
      System.out.println(sum-max+max/2);



}
}


Measured memory_bytes: 23252
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.11 20:50:26
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
	int n, k;
	scanf("%d%d",&n,&k);
	printf("%d\n",n-k+1);





    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main (void){
 char S[2*10*10*10*10*10+1];
 char T[2*10*10*10*10*10+1];
 int len;
 int i,j;
 j=0;
 scanf("%s", S);

 scanf("%s", T);
len = strlen(S);
for(i = 0;i <= len;i++){
     if(S[i] != T[i]){
         j++;
     }
     
}
     printf("%d",j);
     return 0;
}
 

Measured memory_bytes: 2036
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  for (int n, m; n = in(), n; ) {
    vector<pii> v;
    REP(i, n) v.pb(mp(in(), in()));
    m = in();
    REP(i, m) v.pb(mp(in(), in()));
    vi dp(v.size(), 0);

    sort(ALL(v));
    int ans = -INF;
    REP(i, v.size()) {
      dp[i] = 1;
      REP(j, i) {
        if (v[j].Fi < v[i].Fi && v[j].Se < v[i].Se) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
      }
      ans = max(ans, dp[i]);
    }
    print(ans);
  }

  return 0;
}

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    i64 a, b, k;
    cin >> a >> b >> k;

    if (a >= k)
        a -= k;
    else if (b >= k - a)
    {
        b -= k - a;
        a = 0;
    }
    else
    {
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define eb emplace_back
#define pb push_back
#define ll long long
#define mp make_pair
#define x first
#define y second
//# define INF 99999999999999999
#define mod 1000000007
#define mod1 1000000006
#define sc(a) scanf("%d",&a);
#define pc(x) putchar_unlocked(x)
#define PI  3.141592653589793
#define pp pair < ll , ll >
using namespace std;

int min(int a ,  int b)
{
  if(a<b) return a;
  else return b;
}
int max(int a ,  int b)
{
  if(a>b) return a;
  else return b;
}
int a[100005];

int cn[1000005];
int main()
{
	int a,b;
	cin >> a >> b;
	int ans = 1;int cn = 0;
	while(ans < b ){
		cn++;
		ans--;
		ans+=a;
	}
	cout << cn;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
testimony = [[] for _ in range(N)]
#print(testimony)
for i in range(N):
 num = int(input())
 for j in range(num):
  person, state = map(int, input().split())
  testimony[i].append([person-1, state])

#print(testimony)

honest = 0
for i in range(1, 2**N):
 flag = 0
 for j in range(N):
  if (i>>j)&1 == 1:
   for x, y in testimony[j]:
    if (i>>x)&1 != y:
     flag = 1
     break
 if flag == 0:
  honest = max(honest, bin(i)[2:].count('1'))

print(honest)











Measured memory_bytes: 3064
fun main() {
    // 文字列
//    var n = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
    var (x, k, d) = readLine()!!.split(" ").map(String::toLong)
//    val xys = List(n) {
////        readLine()!!.split(" ").map(String::toLong)
//        readLine()!!.toDouble()
//    }
    
    x=Math.abs(x)
    var ans=0L
    if (x / d >= k) {
        ans=x - k * d
    } else {
        val street_step = (x / d).toLong()
        val remainder_step = k - street_step
        if (remainder_step % 2 == 0L) {
            ans=x-(street_step*d)
        }else{
            ans=Math.abs(x-(street_step*d)-d)
        }
    }
    print(ans)

}

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

int Calc(string S, int P, int Q, int R) {
	//if (P == 0 && Q == 0 && R == 0) cout << S << endl;
	if (S[0] == '-') return 2 - Calc(S.substr(1, S.size() - 1), P, Q, R);
	if (S.size() == 1) {
		if (S[S.size() - 1] == 'P') return P;
		if (S[S.size() - 1] == 'Q') return Q;
		if (S[S.size() - 1] == 'R') return R;
		return S[S.size() - 1] - '0';
	}
	int Depth = 0;
	for (int i = 0; i < S.size(); i++) {
		if (Depth == 1 && S[i] == '+') return max(Calc(S.substr(1, i - 1), P, Q, R), Calc(S.substr(i + 1, S.size() - i - 2), P, Q, R));
		if (Depth == 1 && S[i] == '*') return min(Calc(S.substr(1, i - 1), P, Q, R), Calc(S.substr(i + 1, S.size() - i - 2), P, Q, R));
		if (S[i] == '(') Depth++;
		if (S[i] == ')') Depth--;
	}
}

int main() {
	string S;
	while (cin >> S) {
		if (S == ".") return 0;
		int ANS = 0;
		for (int P = 0; P < 3; P++) {
			for (int Q = 0; Q < 3; Q++) {
				for (int R = 0; R < 3; R++) {
					if (Calc(S, P, Q, R) == 2) ANS++;
				}
			}
		}
		cout << ANS << endl;
	}
}


Measured memory_bytes: 3172
let () =
  let n, m = Scanf.scanf "%d %d" (fun n m -> n, m) in
  let es = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun a b -> a-1, b-1)) in
  Array.init n (fun i ->
    Array.map (fun (a, b) -> if i = a || i = b then 1 else 0) es |> Array.fold_left (+) 0)
  |> Array.iter (Printf.printf "%d\n")


Measured memory_bytes: 384
import sys

S_dash = input()
T = input()

for i in range(len(S_dash) - len(T), -1, -1):
    for idx, s in enumerate(T):
        if S_dash[i + idx] != s and S_dash[i + idx] != '?':
            break
    else:
        S = S_dash[:i] + T + S_dash[i + len(T):]
        S = S.replace('?', 'a')
        print(S)
        sys.exit()
print('UNRESTORABLE')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////
class abc
{
    public:
    ll x;
    ll y;
};
bool fun1( abc &a , abc &b )
{
    return (a.x-b.x) - (a.y-b.y) < ( b.x - a.x) -( b.y - a.y) ;
}
// bool fun2( abc &a , abc &b )
// {
//     return a.x-a.y < b.x-b.y ;
// }
// bool fun3( abc &a , abc &b )
// {
//     return -a.x-a.y < -b.x-b.y ;
// }
// bool fun4( abc &a , abc &b )
// {
//     return -a.x-+a.y < -b.x+b.y ;
// }
////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
    //cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        abc a[n];
        ll ans=-1e12;
        ll mx1=-1e12;
        ll mn1=1e12;
        ll mx2=-1e12;
        ll mn2=1e12;
        ll mx3=-1e12;
        ll mn3=1e12;
        ll mx4=-1e12;
        ll mn4=1e12;
        rep(i,0,n)
        {
            cin>>a[i].x>>a[i].y;

            mx1=max(mx1,a[i].x+a[i].y);
            mn1=min(mn1 , a[i].x+a[i].y);

            mx2=max(mx2,a[i].x-a[i].y);
            mn2=min(mn2,a[i].x-a[i].y);
            ans = max( { ans , mx1-mn1 , mx2-mn2 , mn2-mx2 , mn1-mx1 });
        }
        
        cout<<ans;
    }
}

Measured memory_bytes: 6696