akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n),b(n);
  	for (int i=0;i<n;i++){
    	cin >> a[i];
      	b[i]=a[i];
    }
    sort(b.begin(),b.end());
  	for(int i=0;i<n;i++){ 
    	if(a[i]<=b[n/2-1]) cout << b[n/2] <<endl;
        else cout << b[n/2-1] <<endl;
    }
}

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

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  int sum = 0, count = 0;
  if(H <= W){
    for(int i=1;i<=H;i++){
      sum = i*W;
      count++;
      if(sum >= N) break;
    }
  }
  if(W < H){
    for(int i=1;i<=W;i++){
      sum = i*H;
      count++;
      if(sum >= N) break;
    }
  }
  
  cout << count << endl;
  
}
    
  
  

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
static const int INFTY=(1<<30);

int main()
{

    int N, M;
    scanf("%d %d", &N, &M);
    int trip[M+1][N+1], d[N+1], C[M+1];
    for (int i = 0; i <= M; i++) {
        for (int j = 1; j <= N; j++) trip[i][j] = INFTY;
    }
    for (int i = 0; i <= M; i++) trip[i][0] = 0;
    for (int i = 1; i <= N; i++) scanf("%d", &d[i]);
    for (int i = 1; i <= M; i++) scanf("%d", &C[i]);

    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= N; j++) {
            if (trip[i-1][j-1] == INFTY) continue;
            trip[i][j] = min(trip[i][j], min(trip[i-1][j], trip[i-1][j-1]+d[j]*C[i]));
        }
    }

    /*for (int i = 0; i <= M; i++) {
        for (int j = 0; j <= N; j++) printf("%d ", trip[i][j]);
        printf("\n");
    }*/

    printf("%d\n", trip[M][N]);


return 0;
}



Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll SigumaN(ll num)
{
    return num * (num + 1) / 2;
}

int main()
{
    int N;
    ull ans = 0;
    cin >> N;

    repi(i, 1, N + 1){
        ans += SigumaN((int)N / i) * i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, l[100000], r[100000], a[100000],res=0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  l[0] = r[n-1] = 0;

  for (int i = 0; i < n-1; i++)
  {
    l[i + 1] = __gcd(l[i], a[i]);
    r[n - 1 - i - 1] = __gcd(r[n - 1 - i], a[n - 1 - i]);
  }
  for (int i = 0; i < n; i++) res = max(res, __gcd(l[i], r[i]));
  cout << res;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
#define mk(arr,n,type) type *arr=new type[n]; 
#define sl s1.length(); 
#define yes cout<< "Yes"<<endl 
#define no cout<< "No"<<endl 
#define all(v) (v).begin(),(v).end() 
#define mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
    
} 

signed main() 
{ 
    fastio(); 
    int t=1;
    //cin>>t;
    while(t--)
    {
        // int n,m;
        // cin>>n>>m;
        // int a[n],b[n];
        // for(int i=0;i<n;i++)
        // {cin>>a[i];b[i]=a[i]%m;}
        // int c[m]={},d[m]={};
        // int k=n/m;
        // for(int i=0;i<n;i++)
        // {
        //     c[b[i]]++;
        // }
        // for(int i=0;i<m;i++)
        // {
        //     x+=abs(c[i]-k);
        // }
        // cout<<x<<"\n";
        // for(int i=0;i<n;i++)
        // {
        //     if(d[a[i]]<=k)
            // {cout<<a[i]<<" ";
            // d[a[i]]++;}
            string s;
            cin>>s;
            int c=0,m=0,d=0;
            int n=s.length();
            for(int i=0;i<n;i++)
            {
                if(s[i]=='R')
                d++;
                if(s[i]==s[i+1]&&s[i]=='R')
                c++;
                else
                {
                    m=max(m,c);
                    c=0;
                }
            }
             m=max(m,c);
             if(d==0)
             cout<<0;
             else
             cout<<m+1;
        }
    
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

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

    unordered_map<int, int> dp[2];
    dp[0][0] = 0;
    int a, b, c;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;

        int pre = i % 2;
        int cur = (i + 1) % 2;
        int state = 0;
        for (int j = 0; j < b; ++j) {
            cin >> c;
            c--;
            state |= (1 << c);
        }

        for (auto& e : dp[pre]) {
            auto p = dp[cur].find(e.first);
            if (p!=dp[cur].end()) {
                dp[cur][e.first] = min(p->second, e.second);
            } else {
                dp[cur][e.first] = e.second;
            }

            int combined = e.first | state;
            p = dp[cur].find(combined);
            if (p != dp[cur].end()) {
                p->second = min(p->second, a + e.second);
            } else {
                dp[cur][combined] = a + e.second;
            }
        }
    }

    int check = (1 << n) - 1;
    auto it = dp[m%2].find(check);
    if (it != dp[m%2].end()) {
        cout << it->second << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
import numpy as np

n = int(input())
a = list(map(int, input().split()))

ind_B = []
for i in range(n):
  B = a[i] - (i + 1)
  ind_B.append(B)

ind_B.sort()
b = ind_B[len(ind_B)//2]

ABS = []
for j in ind_B:
  abs = np.abs(j - b)
  ABS.append(abs)

sum = sum(ABS)
print(sum)

Measured memory_bytes: 37792
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
string s;
int n,p1[100001],maxn=-INF,c[2]={0,1},ans,rk,pp;
void dfs(int t){
	if(t>n){
		maxn=maxn>ans?maxn:ans;
		return;
	}
	if(s[t]=='p'){
		if(rk>pp){
			pp++;
			dfs(t+1);
			pp--;
		}
		else {
			rk++;
			ans--;
			dfs(t+1);
			rk--;
		}
	}
	if(s[t]=='g'){
		if(rk>pp){
			pp++;
			ans++;
			dfs(t+1);
			pp--;
			ans--;
		}
		else {
			rk++;
			dfs(t+1);
			rk--;
		}
	}
}
int main(){
	cin>>s;
	n=s.size();
	s=' '+s;
	dfs(1);
	printf("%d",maxn);
	return 0;
}

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

int main() {
  int x,y;
  cin>>x>>y;
  bool a=false;
  for(int i=0;i<(x+1);i++){
    if(2*i+4*(x-i)==y){
      a=true;
      break;
    }
  }
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using ll=long long int;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> food(m+1, 0);

    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;

        while (k--) {
            int a;
            cin >> a;
            food[a]++;
        }
    }

    cout << count(food.begin(), food.end(), n) << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

const ll MOD = 1000000007;
//const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n; cin >> n;

    vector<int> nc2;
    nc2.pb(0);
    int i = 1;
    while(nc2.back() <= 1e5) {
        nc2.pb(i * (i + 1) / 2);
        ++i;
    }

    auto it = find(ALL(nc2), n);
    if(it == nc2.end()) {
        print("No");
        return 0;
    }

    int s = it - nc2.begin();

    vector<vi> ans(s + 1);

    int cur = 1;
    REP(i, s + 1) {
        REP(j, i) ans[i].pb(ans[j][i - 1]);

        REP(j, s - i) ans[i].pb(cur++);
    }

    print("Yes");
    print(s + 1);
    REP(i, s + 1) {
        cout << s << " ";
        REP(j, s) {
            if (j > 0) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }
}


Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;

vector<ll> dx={0,1,0,-1};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w;cin>>h>>w;
  vector<string>hw(h);
  rep(i,h){
    cin>>hw[i];
  }
  auto isin=[&](ll hh,ll ww){
    if(hh>=0&&hh<h&&ww>=0&&ww<w)return 1;
    return 0;
  };
  ll res=0;
  rep(sh,h)rep(sw,w)rep(gh,h)rep(gw,w){
    if(hw[sh][sw]=='#'||hw[gh][gw]=='#')continue;
    queue<ll> q;
    vector<vector<ll>>used(h,vector<ll>(w));

    q.push(sh*100+sw);
    used[sh][sw]++;
    while(!q.empty()){
      auto tq=q.front();q.pop();
      ll nh=tq/100,nw=tq%100;
      rep(i,4){
        ll y=nh+dx[i^1],x=nw+dx[i];
        if(!isin(y,x)||hw[y][x]=='#')continue;
        if(used[y][x])continue;
        q.push(y*100+x);
        used[y][x]=used[nh][nw]+1;
      }
    }
    chmax(res,used[gh][gw]);

  }
  cout<<res-1<<endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b; cin >> a >> b;
    if(a == b)
      cout << 0 << "\n";
    else if((a+b)%2 == 0){
      cout << (a+b)/2 << "\n";
    }
    else
    cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int X, N;
    cin >> X >> N;
    bool used[101];
    memset(used, 0, sizeof(bool) * 101);
    for(int i = 0; i < N; ++i) {
        int P;
        cin >> P;
        used[P] = true;
    }
    int l = 0;
    while(true) {
        if(X - l < 1) {
            cout << 0 << endl;
            break;
        }
        else if(!used[X - l]) {
            cout << (X - l) << endl;
            break;
        }
        else if(X + l > 100) {
            cout << 101 << endl;
            break;
        }
        else if(!used[X + l]) {
            cout << (X + l) << endl;
            break;
        }
        else {
            ++l;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
n, ma, mb = map(int, input().split())
U = 400
dp = [[[float("inf")]*(U+1) for _ in range(U+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
  a, b, c = map(int, input().split())
  for j in range(U+1):
    for k in range(U+1):
      if j<a or k<b:
        dp[i+1][j][k] = dp[i][j][k]
      else:
        dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b]+c)
ans = float("inf")
for i in range(1, 1+U//max(ma, mb)):
  na, nb = i*ma, i*mb
  ans = min(ans, dp[-1][na][nb])
if ans == float("inf"):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 142428
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for y in range(n-m+1):
    for x in range(n-m+1):
        failed = False
        for by in range(m):
            for bx in range(m):
                if a[x+bx][y+by] != b[bx][by]:
                    failed = True
        if failed == False:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 91412
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main() {
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	
	if (m <= 4 && y == 2019) {
		cout << "Heisei" << endl;
	}
	else if(m > 4 && y == 2019) {
		cout << "TBD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int *stack=(int*) malloc(sizeof(char)*100);
int *sp=stack;
int pop(void){
	sp--;
	int back=*sp;
	return back;
} 

void push(int indata)
{
	*sp=indata;
	sp++;
	return;
}

int main()
{
	char a[100];;
	
	while(scanf("%s", a)!=EOF){

	if(*a=='+'){
			int a1=pop();
			int a2=pop();
			push(a1+a2);
		}else if(*a=='-'){
			int a2=pop();
			int a1=pop();
			push(a1-a2);
		}else if(*a=='*'){
			int a1=pop();
			int a2=pop();
			push(a1*a2);
		}else{
			push(atoi(a));
		}
	}

	cout<<pop()<<endl;
		

	return 0;

}


Measured memory_bytes: 3252
import java.util.Scanner;

/**
 * 2019/06/16
 * AtCoder Beginner Contest 130
 * 
 * C - Rectangle Cutting
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		double W = sc.nextDouble();
		double H = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();

		double result1 = W * H / 2;
		int result2;
		if((W / 2 == x) && (H / 2) == y) {
			result2 = 1;
		} else {
			result2 = 0;
		}
		
		System.out.println(result1 + " " + result2);
	}
	
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define MOD = 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << n * 800 - (200 * (n / 15)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
int main() {
    int N, K; cin >> N >> K;
    vector<Int> plus, minus;
    for (int i = 0; i < N; i++) {
        Int a; cin >> a;
        if (a >= 0) plus.push_back(a);
        else minus.push_back(a);
    }
    if (plus.size() == 0 && K % 2 == 1) {
        sort(rbegin(minus), rend(minus));
        Int ans = 1;
        for (int i = 0; i < K; i++) {
            ans = ans * (MOD + minus[i]) % MOD;
        }
        cout << ans << '\n';
    } else if (N == K) {
        Int ans = 1;
        for (auto x : plus) ans = ans * x % MOD;
        for (auto x : minus) ans = ans * (MOD + x) % MOD;
        cout << ans << '\n';
    } else {
        sort(rbegin(plus), rend(plus));
        sort(begin(minus), end(minus));
        Int ans = 1;
        int n = 0, m = 0;
        if (K % 2) ans = ans * plus[0] % MOD, n++;
        while (n + m < K) {
            Int a = (n + 1 < plus.size() ? plus[n] * plus[n + 1] : -1);
            Int b = (m + 1 < minus.size() ? minus[m] * minus[m + 1] : -1);
            if (a > b) {
                ans = ans * (a % MOD) % MOD;
                n += 2;
            } else {
                ans = ans * (b % MOD) % MOD;
                m += 2;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 5464
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;
 
void task(){
 	int n; cin >> n;
 	map<int,int>mp;
 	for(int i = 0; i<n; i++){
 		int a;cin >> a;
 		mp[a]++;
 	}
 	int ans = 0;
 	for(auto x:mp){
 		int F = x.ff;
 		int S = x.ss;
 		if(S>=F)ans+=S-F;
 		else ans+=S;
 	}
 	cout << ans << endl;
}

int main(){
        _
        #ifdef OJ
        freopen("inputf.in", "r", stdin);
        freopen("outputf.in", "w", stdout);
        #endif

        int T = 1; //cin >> T;
        while(T--){
            task();
        }
        
return 0;
}




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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N, 0);
  
  for(int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    road.at(a-1)+=1;
    road.at(b-1)+=1;
  }
  
  for(int i=0; i<N; i++)
    cout << road.at(i) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
	static int[] breaks;
	static int num;
	static BigInteger[] patterns;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		int m = sc.nextInt();
		breaks = new int[m];
		patterns = new BigInteger[num + 3];
		for(int i = 0; i < m; i++){
			breaks[i] = sc.nextInt();
		}
		BigInteger devider = new BigInteger("1000000007");
		System.out.println(pattern(0).remainder(devider).longValue());
	}
	static BigInteger pattern(int p){
		if(patterns[p] != null){
			return patterns[p];
		}
		if(p == num){
			patterns[p] = BigInteger.ONE;
			return patterns[p];
		}
		if(p > num){
			patterns[p] = BigInteger.ZERO;
			return patterns[p];
		}
		for(int i = 0; i < breaks.length; i++){
			if(p == breaks[i]){
				patterns[p] = BigInteger.ZERO;
				return patterns[p];
			}
		}
		patterns[p] = pattern(p + 1).add(pattern(p + 2));
		return patterns[p];
	}
}


Measured memory_bytes: 720272
isExist = [0]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in A:
	for j in range( 2000-i, 0, -1 ):
		if 1 == isExist[j]:
			isExist[ i+j ] = 1
	isExist[i] = 1

q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in range( 0, q ):
	if 1 == isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

Measured memory_bytes: 6724
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,t,a[200005],b[200005];
signed main() {
	cin>>n>>m>>t;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	int qwq=0,sum=0;
		for(int i=0;i<=n;i++)
		{
			int r=0,f=m;
			qwq=t-a[i];
			if(qwq<0){
				break;
			}
			while(r<f-1){
				int mid=(r+f)/2;
				if(qwq>=b[mid]){
					r=mid;
				}
				else{
					f=mid;
				}
			}
			if(qwq>=b[f]){
				sum=max(sum,f+i);
			}
			else{
				sum=max(sum,r+i);
			}
		}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 6748
#include<bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define z 10005
using namespace std;
int d[z+1],n,m,k,r,l;
int main(){while(1){cin>>n>>k>>m>>r;if(!(n+m+k+r))break;rep(i,0,z)d[i]=0;k=1,l=n;rep(i,0,z)d[i]+=k/l,k%=l,k*=10;if(m)rep(i,1,n){k=1,l=i*n;rep(j,0,z)d[j]+=k/l,k%=l,k*=10;}for(int i=z;i>0;i--)d[i-1]+=d[i]/10,d[i]%=10;cout<<d[0]<<".";rep(i,1,r+1)cout<<d[i];cout<<endl;}return 0;}

Measured memory_bytes: 2996
#include <stdio.h>
#include <math.h>

int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%lf\n",hypot(x1-x2,y1-y2));
    return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL used[200005] = {0};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,m;
    cin>>n>>m;
    LL x = 1;
    LL y = n;
    REP(i,m){
        while(true){
            LL a = y - x;
            LL b = n - a;
            if(a != b && (used[a] == 0 && used[b] == 0)){
                used[a]++;
                used[b]++;
                break;
            }
            y--;
            if(x >= y){
                // 通らないはず
                PUTS("????");
                break;
            }
        }
        cout<< x << " " << y <<endl;
        x++;
        y--;
    }
}
/*
n = 10
1 9 | 8 2
2 8 | 6 4
3 6 | 3 7
4 5 | 1 9

1 10 | 9 1
2 9  | 7 3
3 7  | 4 6
4 6  | 2 8
*/

/*
1 6 | 5 2 
2 5 | 3 4
3 4 | 1 6

1 7 | 6 1
2 6 | 4 3
3 5 | 2 5

r1
a b c d e f g
1 2 3 4 5 6 7
a f
b e
c d

r2
a b c d e f g
2 3 4 5 6 7 1
e g
a d
b c

r3
a b c d e f g
3 4 5 6 7 1 2
d f
c g
a b

r4
a b c d e f g
4 5 6 7 1 2 3
c e
b f
a g

r5
a b c d e f g
5 6 7 1 2 3 4
d b
a e
f g

r6
a b c d e f g
6 7 1 2 3 4 5
a c
d g
e f

r7
a b c d e f g
7 1 2 3 4 5 6
b g
c f
d e
*/



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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> a;
  for (int i=0 ; i<n ; i++){
    cin >> k.at(i);
    vector<int> b(k.at(i));
    for (int j=0 ; j<k.at(i) ; j++)
      cin >> b.at(j);
    a.push_back(b);
  }
  
  vector<int> like(m, 0);
  
  for (int i=0 ; i<n ; i++){
    for (int j=0 ; j<k.at(i) ; j++){
      like.at(a.at(i).at(j) - 1)++;
    }
  }
  
  int ans = 0;
  for (int i=0 ; i<m ; i++){
    if (like.at(i) == n)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
for i in range(1,3500+1):
    for j in range(1,3500+1):
        divided=n*i*j
        divider=4*i*j-n*(i+j)
        if divider>0 and divided%divider==0:
            print(i,j,divided//divider)
            sys.exit()


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;

	int ans = abs(abs(y) - abs(x));
	if (x > 0)
	{
		if (0 < y&&y < x)
		{
			ans += 2;
		}
		else if (y <= 0)
		{
			ans += 1;
		}
	}
	else if (x < 0)
	{
		if (y < x)
		{
			ans += 2;
		}
		else if (y > 0)
		{
			ans += 1;
		}
	}
	else
	{
		if (y < 0)
		{
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, abs(n - k)) << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N, X, Y,x;
	cin >> N >> X >> Y;
	vector <int>ans(N + 1);
	REP(i, N) {
		REP(j, N) {
			if (j > i) {
				x = min({ j - i, abs(i - Y) + 1 + abs(X - j), abs(i - X) + 1 + abs(Y - j) });
				ans[x]++;
			}
		}
	}
	REP(i, N - 1)
		cout << ans[i] << endl;
}

Measured memory_bytes: 256
main :: IO ()
main = interact $ pickOdds

pickOdds, pickOdds'
  :: [a] -> [a]
pickOdds []       = []
pickOdds [a]      = [a]
pickOdds (a:b:bs) = a : pickOdds bs 

pickOdds' = map snd . filter (odd . fst) . zip [1..]

pickOdds2 = map snd . filter fst . zip (cycle [True, False])

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	int num = N;
  	int sum = 0;
  	while(num){
    	sum = sum + (num % 10);
      	num = num / 10;
    }
  	if(N % sum == 0){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 110;

int n;
int A[3][MAXN];
int f[3][MAXN];

int main()
{
	in(n);
	FOR(j, 1, 2) FOR(i, 1, n) in(A[j][i]);

	f[1][1] = A[1][1];
	FOR(i, 1, 2) FOR(j, 1, n) f[i][j] = Max(f[i - 1][j], f[i][j - 1]) + A[i][j];

	printf("%d\n", f[2][n]);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if(R < 1200){
    cout << "ABC" << endl;
  } else if(R < 2800){
    cout << "ARC" << endl;
  } else{
    cout << "AGC" << endl;
  }
  
  return 0;
}


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

#define MAX_V 100000
#define MAX_E 500000
#define INF 1e18

struct Edge {
  int to, cost;
};

class Node {
public:
  int v;
  int cost;
  Node(int v, int cost) : v(v), cost(cost) {}
  bool operator < (const Node& node) const { return cost < node.cost; }
  bool operator > (const Node& node) const { return cost > node.cost; }
};

pair<vector<long long>,vector<long long>> Dijkstra(const vector<vector<Edge>>& es, int s) {
  vector<long long> dir(MAX_V, -1);
  vector<long long> dist(MAX_V, INF);
  vector<int> visited(MAX_V, 0);
  priority_queue<Node, vector<Node>, greater<Node>> pq;

  pq.emplace(s, 0);
  dist[s] = 0;

  while (!pq.empty()) {
    const Node node = pq.top(); pq.pop();
    int v = node.v;
    int cost = node.cost;
    if (visited[v]) continue;
    visited[v] = true;

    for (const auto& next_node : es[v]) {
      int nv = next_node.to;
      int node_cost = next_node.cost;
      if (visited[nv]) continue;
      long long next_cost = cost + node_cost;
      if (next_cost < dist[nv]) {
        dir[v] = nv;
        dist[nv] = next_cost;
        pq.emplace(nv, next_cost); // 最短経路更新出来れば更新
      }
    }
  }
  return make_pair(dist, dir);
}

int main(void) {
  int V, E, r;
  cin >> V >> E >> r;

  vector<vector<Edge>> es(V);
  for (int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    es[s].push_back({t, d});
    // es[t].push_back({t, d});
  }

  vector<long long> dist, dir;
  tie(dist, dir) = Dijkstra(es, r);
  for (int t = 0; t < V; t++) {
    long long d = dist[t];
    if (d == INF) cout << "INF" << endl;
    else cout << d << endl;
  }

  return 0;
}


Measured memory_bytes: 15940
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "-1" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,K; cin>>N>>K;
    vector<ll> A(N);
    vector<ll> sum(N+1,0);
    rep(i,N) cin>>A[i];
    vector<ll> B;
    rep(i,N){
        sum[i+1]=sum[i]+A[i];
    }
    rep(i,N){
        reps(j,i+1,N+1){
            B.emplace_back(sum[j]-sum[i]);
        }
    }
    ll X=B.size();
    vector<bool> desu(X,true);
    ll ans=0;
    repr(i,60,0){
        ll ct=0;
        rep(j,X){
            if((B[j]>>i&1) and desu[j]==true) ++ct;
        }
        if(ct>=K){
            ans+=(1LL<<i);
            rep(j,X){
                if(!(B[j]>>i&1)) desu[j]=false; 
            }
        }
    }
    cout<< ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 6384
#include <stdio.h>
#include <string.h>

int main(){
    char str[10100];
    int n;
    scanf("%d%s", &n, str);
    n %= 26;
    int sz = strlen(str);
    for(int i = 0; i < sz; i++){
        str[i] = ((str[i] - 'A') + n) % 26 + 'A';
    }
    printf("%s\n", str);
}

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

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

    int cnt[27];
    for(char i='a';i<='z';i++) cnt[i-'a']=0;

    long long ptn=1;
    for(int i=0;i<A.size();i++){
        ptn+=i-cnt[A[i]-'a'];
        cnt[A[i]-'a']++;
    }

    cout << ptn << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x, ans;
	cin >> n;
	map<int, int> ct;
	while (n--) {
		cin >> x;
		ct[x]++;
	}
	ans = 0;
	for (auto p : ct) {
		if (p.second % 2 == 1) ans++;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<bits/stdc++.h>
#define rep(a,b) for(int a=0;a<b;i++)
typedef long long ll;
using namespace std;
const int maxn=1000+5;
const int INF=1e9;
int a[maxn];
int b[maxn];
int dp[10005];
int main()
{
    int h,n;
    cin>>h>>n;
    rep(i,n)
    {
        cin>>a[i]>>b[i];
    }
    dp[0]=0;
    for(int i=1;i<=h;i++){
        dp[i]=INF;
        for(int j=0;j<n;j++){
            int pre=a[j]<=i?dp[i-a[j]]:0;
            dp[i]=min(dp[i],pre+b[j]);
        }
    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 256
// 考え方あってるのになぜかミスってると思ってしまった(制約の読み間違いが一因)
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  int ans = 1000000010;
  for (int i = k - 1; i < n; i++) ans = min(ans, h[i] - h[i - k + 1]);
  cout << ans << endl;
}

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

int main() {
	int N, M, CardNUM=0,ans=0;
	int A[1001], B[1001];
	vector<int> Price;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 0; i < M; i++) {
		if (A[i] >= N) {
			CardNUM++;
		}
		else if (A[i] < N) {
			Price.push_back(N - A[i]);
		}
	}

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

	for (int i = 0; i < M - CardNUM-1; i++) {
		if (i >= 0) {
			ans += Price.at(i);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int res = 0;

		String result = "";

		res = a*(a-1)+b*(b-1);
		res/= 2;


		System.out.printf("%d\n", res);
		//System.out.printf("%d", result);
	}
}


Measured memory_bytes: 23764
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int N;
int W[200];
int V[200];

int dp[201][201];

int dfs(int i,int j){
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int res;
    if(i==N) return 0;
    if(j<W[i]){
        res = dfs(i+1,j);
    }
    else{
        res = max(dfs(i+1,j), dfs(i+1,j-W[i])+V[i]);
    }
    return dp[i][j]=res;
}

int main(int argc, const char * argv[]) {
    
    int S,W;
    cin >> S >> W;

    if(S<=W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
    
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int solve(int n)
{
	if(n==1) return 1;
	return 2*solve(n/2)+1;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	cout<<solve(n)<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		String[] lo = reader.readLine().split(" ");
		int n = Integer.parseInt(lo[0]);
		int k = Integer.parseInt(lo[1]);	
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		for(int i = k;i<n;i++){
			if(list[i]>list[i-k]) writer.write("Yes"+"\n");
			else writer.write("No"+"\n");
		}
		writer.flush();
	}
}


Measured memory_bytes: 63552
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second

void Max(int &x, int y) {
    if (x < y) x = y;
}

void Min(int &x, int y) {
    if (x > y) x = y;
}


int a[100010], c[100010];
int main(void) {

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i) {
        int x;
        cin >> x;
        ++ a[x % m];
        c[i] = x;
    }

    int ans = 0;
    for (int i = 0; i < m; ++ i) {
        if (i == (m - i) % m) {
            ans += a[i] / 2;
            a[i] %= 2;
            continue;
        }
        int x = min(a[i], a[m - i]);
        ans += x;
        a[i] -= x; a[m - i] -= x;
    }

    sort(c + 1, c + n + 1);
    for (int i = 2; i <= n; ++ i) {
        int x = c[i] % m;
        if (a[x] >= 2 && c[i - 1] == c[i]) {
            ++ ans;
            a[x] -= 2;
            ++ i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int [] ans = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            ans[a[i] - 1] = i + 1;
        }
        for (int i : ans) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 65352
object Main extends App {
  @scala.annotation.tailrec
  def loop(s: Int, count: Int): Int = s match {
    case 4 | 2 | 1 => count + 3
    case n if n % 2 == 0 => loop(n / 2, count + 1)
    case n => loop(3 * n + 1, count + 1)
  }
  val sc = new java.util.Scanner(System.in)
  val s = sc.nextInt()
  println(loop(s, count = 1))
}


Measured memory_bytes: 55236
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    double m;
    cin>>n>>m;
    if(n<m){
        cout<<"No"<<endl;
        return 0;
    }
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int sum=0;
    rep(i,n) sum+=v[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        if(v[i]>=sum/(4*m)){
            cnt++;
        }
    }
    if(cnt>=m){
                cout<<"Yes"<<endl;
                return 0;
            }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define scns(s) scanf("%s", &s)
#define pri(n) printf("%d", n)
#define priln(n) printf("%d\n", n)
#define pris(s) printf("%s", s)
#define prisln(s) printf("%s\n", s)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  ll N, A, B;
  cin >> N >> A >> B;

  ll cnt = N / (A + B);
  ll remain = N % (A + B);
  chmin(remain, A);

  cout << cnt * A + remain << endl;

  return 0;
}


Measured memory_bytes: 256