akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 305;
int n, m, l, q, G[N][N], G2[N][N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m >> l;
 	for(int i=1;i<=n;i++)
 		for(int j=1;j<=n;j++)
 			G2[i][j] = G[i][j] = (i==j ? 0 : INF); 
 	for(int i=1;i<=m;i++)
 	{
 		int u, v, w;
 		cin >> u >> v >> w;
 		G[u][v] = G[v][u] = w;
 	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++) 
			for(int j=1;j<=n;j++)
				if(G[k][j]<INF&&G[i][k]<INF&&G[i][k]+G[k][j]<G[i][j]) G[i][j] = G[i][k] + G[k][j];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(G[i][j]<=l) G2[i][j] = G2[j][i] = 1;
 	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++) 
			for(int j=1;j<=n;j++)
				if(G2[k][j]<INF&&G2[i][k]<INF&&G2[i][k]+G2[k][j]<G2[i][j]) G2[i][j] = G2[i][k] + G2[k][j];
	cin >> q;
	while(q--)
	{
		int s, t;
		cin >> s >> t;
		if(G2[s][t]>=INF) cout << -1 << '\n';
		else cout << G2[s][t]-1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

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

	int d = -1;
	vector<int> h;
	for (int i = 0; i < N; i++) {
		cin >> d;
		h.push_back(d);
	}

	vector<int> dp(N, INT_MAX);
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i]);
		if (i > 1)
			dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i]);
	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 3964
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int A[100001];
	priority_queue<int> Q;
	scan(N>>M);
	rep(i,N){
		int A;
		scan(A);
		Q.push(A);
	}
	rep(i,M){
		int Qtop=Q.top();
		Q.pop();
		Q.push(Qtop>>1);
	}
	ll sum=0;
	rep(i,N){
		sum+=Q.top();
		Q.pop();
	}
	prin(sum);
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

ll count(ll n, ll m) {
  ll ret = n % m;
  ret -= m / 2;
  if (ret < 0) return 0;
  return ret + 1;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll mod = 4;
  ll ans = 0;
  while (b * 10 >= mod) {
    ll n1 = count(a, mod);
    ll n2 = count(b, mod);

    ll num;
    if (a / mod == b / mod) {
      num = n2 - n1;
      if (n1 > 0) num++;
    } else {
      num = mod / 2 - n1 + n2;
      if (n1 > 0) num++;
    }

    if (num % 2 != 0) ans += mod / 2;
    mod *= 2;
  }

  ll num = (b - a + 1) / 2;
  if ((b - a + 1) % 2 != 0) {
    if (a % 2 != 0) num++;
  }
  if (num % 2 != 0) ans++;

  cout << ans << endl;
}


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

namespace ConsoleApp1
{
    static class BTaxRate
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());

            double x = Math.Ceiling(n / 1.08);
            int n2 = (int)(x * 1.08);

            Console.WriteLine(n == n2 ? x.ToString() : ":(");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
# coding: utf-8
import sys,pprint, math
from fractions import Fraction
from collections import defaultdict

MOD = 1000000007
N = int(input())
params =[]
hatemasks = []
tilts = defaultdict(lambda: [0,0])
zerozero = 0
zerodiv = 0
for i in range(N):
    (ai, bi) = map(int,input().split())
    if ai == 0 and bi == 0:
        zerozero += 1
        continue
    if (ai < 0) or (ai == 0 and bi < 0):
        ai *= -1
        bi *= -1
    g = math.gcd(ai,bi)
    ai = ai // g
    bi = bi // g
    if bi > 0:
        tilts[(ai,bi)][0] += 1
    else:
        tilts[(-bi,ai)][1] += 1
print(tilts,file=sys.stderr)

#sys.exit()
ans = 1
for(v1,v2) in tilts.values():
    ans *= 1 +pow(2,v1,MOD)-1 +pow(2,v2,MOD)-1
    ans %= MOD
ans = (ans+zerozero-1) % MOD
print(ans)

Measured memory_bytes: 85436
while input = gets
  w = input.to_f
  if w <= 48.0
    puts "light fly"
  elsif w <= 51.0
    puts "fly"
  elsif w <= 54.0
    puts "bantam"
  elsif w <= 57.0
    puts "feather"
  elsif w <= 60.0
    puts "light"
  elsif w <= 64.0
    puts "light welter"
  elsif w <= 69.0
    puts "welter"
  elsif w <= 75.0
    puts "light middle"
  elsif w <= 81.0
    puts "middle"
  elsif w <= 91.0
    puts "light heavy"
  else
    puts "heavy"
  end
end

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

int main() {
  int D; cin >> D;
  long long G; cin >> G;
  vector<int> P(D), C(D);
  for (int i = 0; i < D; i++) cin >> P.at(i) >> C.at(i);

  int ans = 1000000007;
  // どれをコンプするか
  for (int bit = 0; bit < (1 << D); bit++) {
    long long point = 0;
    int cnt = 0;
    for (int i = 0; i < D; i++) {
      if ((bit >> i) & 1) {
        point += P.at(i) * (i+1) * 100 + C.at(i);
        cnt += P.at(i);
      }
    }
    if (point >= G) {
      ans = min(ans, cnt);
      continue;
    }
    // 残りのうち最も配点の高い問題だけ解く
    for (int i = D-1; i >= 0; i--) {
      if ((bit >> i) & 1) continue;
      for (int j = 0; j < P.at(i); j++) {
        point += (i+1) * 100;
        cnt++;
        if (point >= G) break;
      }
      break;
    }
    if (point >= G) ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  ll N = S.size();
  if(N < 3){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll acount = 0;
  for(int i = 0; i < N-2; i++){
    if(S.at(i) == 'A') acount++;
    else acount = 0;

    if(S.substr(i, 3) == "ABC"){
      ans += acount;
      S.at(i+2) = 'A';
      i++;
      acount--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=101101;
char s[N];
int n,m;
double l;
int main(){
	scanf("%lf",&l);
	printf("%.12lf\n",1.0*l*l*l/27);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
arr = list(map(int, input().split()))

answer = 0
for idx1 in range(0, len(arr) - 2):
    for idx2 in range(idx1+1, len(arr) - 1):
        for idx3 in range(idx2+1, len(arr)):
            if arr[idx1] == arr[idx2] or arr[idx1] == arr[idx3] or arr[idx2] == arr[idx3]:
                continue
            if arr[idx1] + arr[idx2] > arr[idx3] and arr[idx1] + arr[idx3] > arr[idx2] and arr[idx2] + arr[idx3] > arr[idx1]:
                answer += 1

print(answer)

Measured memory_bytes: 74024
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Double> input = new ArrayList<Double>();

		//üÍ³ê½lðXgÉÇÁ·é
		try{
			while(true){
				input.add(sc.nextDouble());
			}
		}catch(NoSuchElementException e){
			//½àµÈ¢ÅÌÉÚé
		}
		
		//Åá¬x©çKðßAoÍ·é
		for(int i = 0; i < input.size(); i++){
			System.out.println(getFloorNumber(getTime(input.get(i))));
		}
	}
	
	//ZÌ½ßÉêIÉdÍÁ¬xð98Æ·é
	private static final double GRAVITY = 98;
	public static double getTime(double velocity){
		//dÍÁ¬xð9.8Æ·é½ßAÅãÉ10ð©¯é
		return velocity / GRAVITY * 10;
	}

	public static int getFloorNumber(double time){
		//dÍÁ¬xð9.8Æ·é½ßAÅãÉPOÅé
		double y = time * time * GRAVITY / 2 / 10;
		int i;
		for( i = 1; (i * 5 - 5) < y; i++);
		return i;
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    int[] B = new int[N];
	    
	    for (int i = 0; i < N - 1; i++) {
	    	B[i] = Integer.parseInt(scanner.next());
	    }
	    
	    int sum = 0;
	    
	    for (int i = 0; i < N; i++) {
	    	if (i == 0) {
	    		sum += B[i];
	    	} else if (i == N-1) {
	    		sum += B[N-2];
	    	} else {
	    		sum += Math.min(B[i], B[i-1]);
	    	}
	    }

        System.out.print(sum);
	}
}


Measured memory_bytes: 35708
n=[int(x) for x in list(input().split())]
A=n[0]
B=n[1]
C=n[2]
X=n[3]
Y=n[4]

ans=max(A,B,C)*(X+Y)
t=0
for i in range(max(X,Y)*2+1):
    if A*max(0, X-int(i/2))+B*max(0,Y-int(i/2))+C*i < ans:
        ans=A*max(0, X-int(i/2))+B*max(0,Y-int(i/2))+C*i
        t=i

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

using pi = pair<int,int>;

int solve(){
    int w,h,k;
    cin >>w >>h >>k;

    vector<pi> p(k);
    map<pi,int> m;
    rep(i,k){
        int x,y;
        scanf(" %d %d", &x, &y);
        p[i] = {y,x};
        m[p[i]] = i;
    }

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    auto isS = [&](pi t){
        if(t.fi == h-1) return t.se != w-1;
        if(t.se == 0) return t.fi != 0;
        return false;
    };

    auto isT = [&](pi t){
        if(t.fi == 0) return t.se != 0;
        if(t.se == w-1) return t.fi != h-1;
        return false;
    };

    queue<int> que;

    vector<bool> viss(k);
    rep(i,k){
        if(isS(p[i])){
            viss[i] = true;
            que.push(i);
        }
    }
    while(!que.empty()){
        int now = que.front();
        que.pop();
        rep(i,8){
            int ny = p[now].fi+dy[i], nx = p[now].se+dx[i];
            if(!IN(ny,nx)) continue;

            if(m.count({ny,nx})){
                int idx = m[{ny,nx}];
                if(!viss[idx]){
                    viss[idx] = true;
                    que.push(idx);
                }
            }
        }
    }

    vector<bool> vist(k);
    rep(i,k){
        if(isT(p[i])){
            vist[i] = true;
            que.push(i);
        }
    }
    while(!que.empty()){
        int now = que.front();
        que.pop();
        rep(i,8){
            int ny = p[now].fi+dy[i], nx = p[now].se+dx[i];
            if(!IN(ny,nx)) continue;

            if(m.count({ny,nx})){
                int idx = m[{ny,nx}];
                if(!vist[idx]){
                    vist[idx] = true;
                    que.push(idx);
                }
            }
        }
    }

    rep(i,k)if(viss[i] && vist[i]) return 0;

    rep(i,k)rep(j,8){
        int ny = p[i].fi+dy[j], nx = p[i].se+dx[j];
        if(!IN(ny,nx)) continue;

        bool ss = false, tt = false;
        rep(d,8){
            int Y = ny+dy[d], X = nx+dx[d];
            if(!IN(Y,X)) continue;
            if(m.count({Y,X})){
                int idx = m[{Y,X}];
                if(viss[idx]) ss = true;
                if(vist[idx]) tt = true;
            }
        }
        if(ss && tt) return 1;

        if(viss[i] && isT({ny,nx})) return 1;
        if(vist[i] && isS({ny,nx})) return 1;
    }

    return 2;
}

int main(){
    cout << solve() << endl;
    return 0;
}



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

int main()
{
    char s[101], t[101], tmp;
    int i, j;
    scanf("%s %s", s, t);
    for (i=strlen(s)-2; i>=0; i--)
    {
        for (j=0; j<=i; j++)
        {
            if (s[j] > s[j+1]) {
                tmp = s[j+1];
                s[j+1] = s[j];
                s[j] = tmp;
            }
        }
    }
    for (i=strlen(t)-2; i>=0; i--)
    {
        for (j=0; j<=i; j++)
        {
            if (t[j] < t[j+1]) {
                tmp = t[j+1];
                t[j+1] = t[j];
                t[j] = tmp;
            }
        }
    }
    if (strcmp(s,t) < 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

int main()
{
  char x,y;
  cin >> x >> y;
  if(x < y) cout << "<" << endl;
  else if(x == y) cout << "=" << endl;
  else if(x > y) cout << ">" << endl;
}


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

long long third(long x){
  return x*x*x;
}

int main() {
  int n, k;
  cin >> n >> k;
  long long ans;
  if (k%2 == 1){
    ans = third(n/k);
  }
  else ans = third(n/k) + third((n/(k/2))-(n/k));
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(3);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[j];
			a[j] = pow((double)a[j], 2);
		}
		sort(a.begin(), a.end());			
		if (a[0] + a[1] == a[2]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		for (int j = 0; j < 3; j++) {
			a[j] = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();
        
        int previous = x;
        for (int index=0; index<10; index++){
            previous = r*previous-D;
            System.out.println(previous);
        }
    }
}

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

using namespace std;

long L, x[222222], d[222222], e[222222];
long f(int a, int b) {
	long y = x[b] - x[a];
	return y < 0 ? y + L : y;
}
int main() {
	int n;
	cin >> L >> n;
	for (int i = 0; i < n; i++)
		scanf("%ld", x + i);
	for (int m = n - 1; m--;)
		d[m] = d[m + 1] - f(m + 1, (n - m) / 2 + m) + f((n - m + 1) / 2 + m, m);
	for (int m = 1; m < n; m++)
		e[m] = e[m - 1] - f(m / 2, m - 1) + f(m, (m - 1) / 2);
	long r = 0;
	for (int m = 0; m < n; m++) {
		r = max(r, x[m] + d[m]);
		r = max(r, L - x[m] + e[m]);
	}
	cout << r << endl;
	return 0;
}


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

bool isprime(int x){
  if(x==2) return true;
  else if(x<2||x%2==0) return false;

  for(int i=3;i<=sqrt(x);i+=2){
    if(x%i==0) return false;
  } 
  return true;
}

int main(){

  int n, x, cnt=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    if(isprime(x)) cnt++;
  }

  cout<<cnt<<endl;

  return 0;
}



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

long long A[10];

int main() {
    int H, W, N, a, b;
    map<pair<int, int>, int> mp;
    scanf("%d %d %d", &H, &W, &N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &a, &b);
        a--; b--;
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                if (a+j > 0 && a+j < H-1 && b+k > 0 && b+k < W-1) {
                    mp[make_pair(a+j, b+k)]++;
                }
            }
        }
    }
    A[0] = (long long)(H-2) * (W-2);
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        A[itr->second]++;
        A[0]--;
    }
    for (int i = 0; i < 10; i++) {
        printf("%lld\n", A[i]);
    }
    return 0;
}

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

int main() {
	int n;
	int ara[100];
	int a[100][2];
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>ara[i];
	}
	sort(ara,ara+n);
	int cnt=1;
	int k=0;
	for (int i=0;i<n-1;i++){
		if (ara[i]==ara[i+1]){
			cnt++;
		}
		else{
			a[k][0]=ara[i];
			a[k][1]=cnt;
			cnt=1;
			k++;
		}
	}
	a[k][0]=ara[n-1];
	a[k][1]=cnt;
	k++;
	int s=0;
	for (int i=0;i<k-2;i++){
		for (int j=i+1;j<k-1;j++){
			int cnt=0;
			for (int l=j+1;l<k;l++){
				if (a[l][0]>=(a[i][0]+a[j][0])){
					break;
				}
				else{
					cnt=cnt+a[l][1];
				}
			}
			s=s+(a[i][1]*a[j][1]*cnt);
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back

using namespace std;
using ll=long long;
// using ll=int;

const ll mod = (ll)(1e9+7);

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){

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

    fast;
    ll t = 1;
    // cin >> t;
    while(t--){
        ll n; cin >> n;
        bool flag = 1;
        for(ll i = 0; i < n; i++){
            ll a; cin >> a;
            if(a%2 == 0){
                if(a%3 == 0 || a%5 == 0) continue;
                else {flag = 0; break;}
            }
        }

        if(flag) cout << "APPROVED\n";
        else cout << "DENIED\n";
    }
    // cerr << (double)clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,a[101];
	int b[9]={};
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		int h=a[i]/400;
		if(h>8)h=8;
		b[h]++;
	}
	int r=0,f=0;
	for(int i=0;i<8;++i){
		if(b[i]){
			++r;
		}else f++;
	}
	if(!r&&b[8])cout<<1<<" "<<b[8]<<endl;
	else {
		cout<<r<<" "<<r+b[8]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
N,K = inputlist()
print(len(base10to(N,K)))

Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {
			pool.addAll(jobs[today]);
			total += (long)pool.poll();
		}

		System.out.println(total);
		in.close();
	}
}

Measured memory_bytes: 100568
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#define int long long
#define N 200010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,tot,phi,a[N],b[N];
map<int,int> vis;
signed main()
{
	n=read();int X=read();int M=read();
	int g=X;vis[g]=1;
	int ans=g,sum=0,len=0;
	a[tot=1]=g;
	for(int i=2;i<=n;i++)
	{
		g=(g*g)%M;
		if(vis[g])
		{
			n-=tot;
			len=tot-vis[g]+1;
			sum=a[tot]-a[vis[g]-1];
			for(int j=1;j<=len;j++)b[j]=a[vis[g]+j-1]-a[vis[g]+j-2];
			break;
		}
		a[tot+1]=a[tot]+g;
		tot++;
		vis[g]=i;
		ans+=g;
	}
	if(len)ans=ans+sum*(n/len);
	if(len)for(int i=1;i<=n%len;i++)ans+=b[i];
	printf("%lld\n",ans);
	return 0;
}
//7 2 1001


Measured memory_bytes: 7480
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{   int n,m;
    cin>>n>>m;
    for(int i=n/2,j=i+1,k=1;k<=m;k++,i--,j++)
    {   if(n%2==0&&(j-i==n/2||j-i==n/2+1))j++;
        cout<<i<<' '<<j<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n == m){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

int N,k[1000];
int v[1000][1000];
int found[1000] = {0},ended[1000] = {0};
int keep;
int checking=0;

void dfs(int cur);

int main() {
	cin >> N;
	for(int i=1;i<N+1;i++) {
		cin >> keep >> k[i];
		for(int j=1;j<k[i]+1;j++) {
			cin >> v[i][j];

		}
	}
	dfs(1);
	while(true) {
		//cout << "processing..." << endl;
		bool flag = false;
		int key = 1;
		for(int i=1;i<N+1;i++) {
			if(found[i] == 0) {
				flag = true;
				key = i;
				break;
			}
		}
		if(flag) {
			dfs(key);
		} else {
			break;
		}
	}
	
	
	for(int i=1;i<N+1;i++) {
		cout << i << " " << found[i] << " " << ended[i] << endl;
	}
	

}

void dfs(int cur) {
	//cout << "process ended" << endl;
	if(!found[cur]) {
		checking++;
		//cerr << "visiting: " << cur << " " << "time: " << checking << endl;
		found[cur] = checking;

	}
	for(int dst=1;dst<N+1;dst++) {
		bool flag = false;
		for(int i=1;i<k[cur]+1;i++) {
			if(v[cur][i] == dst) flag = true;
		}
		if((flag) && (dst != cur) && (!found[dst])) dfs(dst);
	}
	if(!ended[cur]) {
		checking++;
		//cerr << "ended: " << cur << " " << "time: " << checking << endl;
		ended[cur] = checking;
	}
}
/*
????????£????????????40?????????????????????????????????????????????????°?????????????????????????
*/

Measured memory_bytes: 3404
x,k,d=map(int,input().split())
if k%2==0:
    ans=min(abs(x),abs(x+2*d),abs(x-2*d),abs(x+4*d),abs(x-4*d),abs(x+k*d),abs(x-k*d),abs(x+(k-2)*d),abs(x-(k-2)*d),abs(x+(k-4)*d),abs(x-(k-4)*d))
else:
    if k==1:
        ans=min(abs(x+d),abs(x-d))
    else:
        ans=min(abs(x+d),abs(x-d),abs(x+3*d),abs(x-3*d),abs(x+k*d),abs(x-k*d),abs(x+(k-2)*d),abs(x-(k-2)*d),abs(x+(k-4)*d),abs(x-(k-4)*d))
if k>=abs(x)//d:
    if (k-(abs(x)//d))%2==0:
        ans=min(ans,abs(x+(abs(x)//d)*d),abs(x-(abs(x)//d)*d))
    else:
        ans=min(ans,abs(x+(abs(x)//d)*d+d),abs(x-(abs(x)//d)*d+d),abs(x+(abs(x)//d)*d-d),abs(x-(abs(x)//d)*d-d))
print(ans)


Measured memory_bytes: 9172
package main

import (
	"fmt"
)

func printboard(h, w int) {
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i%2 == j%2 {
				fmt.Printf("#")
			} else {
				fmt.Printf(".")
			}
		}
		fmt.Println()
	}
	fmt.Println()
}

func main() {
	var h, w int
	for {
		fmt.Scan(&h, &w)
		if h == w && h == 0 {
			break
		}
		printboard(h, w)
	}
}



Measured memory_bytes: 1092
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()

MOD = 10 ** 9 + 7


def modinv(x):
    return pow(x, MOD - 2, MOD)


def main():
    s = sum(A) % MOD
    ans = s * s % MOD
    for a in A:
        ans = (ans - a ** 2) % MOD
    ans = ans * modinv(2) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31432
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int A = Math.abs(Math.abs(x)-Math.abs(y));
    int B = 0;
    if (x <= y) {
      B = (long)x*y >= 0 ? 0 : 1;
    } else {
      B = (long)x*y > 0 ? 2 : 1;
    }
    System.out.println(A+B);
  }
}

Measured memory_bytes: 22740
s = input()

if s == "SAT":
    print(1)
if s == "FRI":
    print(2)
if s == "THU":
    print(3)
if s == "WED":
    print(4)
if s == "TUE":
    print(5)
if s == "MON":
    print(6)
if s == "SUN":
    print(7)

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

typedef long long ll;

int main()
{
    ll i,n;
    cin>>n;
    if(n==1)
    {
        return cout<<"Yes" , 0;
    }
    ll ar[n];
    for(i=0;i<n;i++)
    cin>>ar[i];
    ll m = ar[0];
    ll flag=0;
    for(i=1;i<n;i++)
    {
        if(ar[i]>m)
        m=ar[i];
        else
        {
            if(m-ar[i]>=2)
            {
                flag=1;
                break;
            }
        }
    }
    if(!flag)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
  long long n; cin>>n;

  if(n==1) cout<<0<<endl;
  else{
    cout<<(n-1)*(n)/2<<endl;
  }


}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorString(vector<string> * p, long long a){
    rep(i, a){
        string input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    
    ll X =  inputValueLongLong();

    int shita = -200;
    int ue = 200;

    for(ll i=0;i<300;i++){
        for(ll j=0;j<300;j++){
            ll ix = i - 150;
            ll jx = j - 150;
            if(X==ix*ix*ix*ix*ix - jx*jx*jx*jx*jx){
                cout << ix << " " << jx << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<deque>
#include<vector>
using namespace std;
class Node{
    public:
    Node(){next = nullptr;}
    Node(char v,Node* n){val = v; next = n;}
    char val;
    Node* next;
    int lstSize = 0;
};
int main()
{
    string s;
    Node *lst = nullptr;

    cin>>s;
    for(int i=s.size()-1;i>=0;i--)
    {
        lst = new Node(s[i],lst);

    }
    int lstSize = s.size();
    int turn=1;
    for(Node *i=lst;i->next->next!=nullptr;)
    {
        if(i->val != i->next->next->val)
        {   //cout<<i->val<<" "<<i->next->next->val<<endl;
            turn = turn==1?2:1;
            i->next=i->next->next;
            lstSize--;
            i=lst;
        }
        else
        {   //cout<<"check"<<endl;
            i=i->next;
        }
    }
    //cout<<lstSize<<endl;
    if(lstSize==2)
    {
        cout<<(turn==1?"Second":"First");
    }
    else if(lstSize>2)
    {
        cout<<(turn==1?"Second":"First");
    }
    return 0;

}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,m;
  cin>>n>>m;
  ll a[n],i;
  float s=0;
  for(i=0;i<n;i++)
  {cin>>a[i];
   s+=a[i];}
 // cout<<s;
  float p=m*4;
  ll f=0;
  float z=s/p;
//  cout<<z;
  for(i=0;i<n;i++)
  {if(a[i]<z)
  {
    f++;
    }}
 // cout<<f;
  f=n-f;
  if(f>=m)
  {cout<<"Yes";}
  else
  {cout<<"No";}
  
return 0;}

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

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

using namespace std;


int main() {

	
	string S;
	cin >> S;

	if (S == "SUN")
		cout << 7 << endl;
	else if (S == "SAT")
		cout << 1 << endl;
	else if (S == "FRI")
		cout << 2 << endl;
	else if (S == "THU")
		cout << 3 << endl;
	else if (S == "WED")
		cout << 4 << endl;
	else if (S == "TUE")
		cout << 5 << endl;
	else if (S == "MON")
		cout << 6 << endl;
	return 0;
}

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

class State{
public:
  int id, rem, cost;

  State(int _id, int _rem, int _cost){
    id = _id;
    rem = _rem;
    cost = _cost;
  }

  bool operator<(const State &st)const{
    return cost > st.cost;
  }
};

int c, n, m, s, d;
bool closed[102][12];
int t[102][102];

void solve(){
  priority_queue<State> open;
  memset(closed, 0, sizeof(closed));
  open.push(State(s, c, 0));

  while(!open.empty()){
    State st = open.top(); open.pop();
    if(closed[st.id][st.rem]) continue;
    closed[st.id][st.rem] = true;

    if(st.id == d){
      cout << st.cost << endl;
      return;
    }

    for(int i = 0; i < n; i++){
      if(t[st.id][i] != -1){
        open.push(State(i, st.rem, st.cost + t[st.id][i]));
        if(st.rem > 0){
          open.push(State(i, st.rem - 1, st.cost + t[st.id][i] / 2));
        }
      }
    }
  }
}

int main(){
  while(cin >> c >> n >> m >> s >> d, c || n || m || s || d){
    s--;
    d--;

    memset(t, -1, sizeof(t));

    for(int i = 0; i < m; i++){
      int a, b, f;
      cin >> a >> b >> f;
      a--;
      b--;
      t[a][b] = t[b][a] = f;
    }

    solve();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    vector<ll> arr(n);

    ll lo = 0;
    ll hi = 0;
    ll ans = 1e9;
    for (ll &x : arr)
        cin >> x;

    arr.push_back(k + arr[0]);

    arr.insert(arr.begin(), -(k - arr[n - 1]));

    for (int i = 0; i <= n; i++)
    {
        ll curr = abs(arr[i] - arr[i + 1]);
        ans = min({ans, k - curr});
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int cnt[51][30];
int main(){
  int n;
  string s,ans;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<s.size();j++){
      cnt[i][s[j]-'a']++;
    }
  }
  for(int i=0;i<26;i++){
    int t=1000000;
    for(int j=0;j<n;j++){
      t=min(t,cnt[j][i]);
    }
    for(int j=0;j<t;j++){
      ans+=('a'+i);
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                #define int long long
                #define fi first
                #define se second
                #define pi pair<int,int>  
                #define pb push_back

                // dont forget to initialize global variables inside main() ;
                int mod = 1e9 + 7;
                
                int func(string &s,string &t,int k){
                    int ans=0;
                    for(int i=k;i<k+(int)t.size();i++){
                        if( s[i]!=t[i-k] )
                            ans++;
                    }
                    return ans;
                }
                int32_t main() {
                
                ios::sync_with_stdio(false);
                cin.tie(0);
                cout.tie(0);

                int tt=1;//;cin>>tt; 
                
                
                while( tt-- ){

                    string s,t;
                    cin>>s>>t;
                    int ans = INT_MAX;
                    for(int i=0;i<=(int)s.size()-(int)t.size();i++){
                        int k = func(s,t,i);
                      //  cout<<k<<endl;
                        ans = min(ans,k);

                    }
                    cout<<ans<<endl;
                }
                return 0;
            }

                        


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

const int MOD = 998244353;

long long modpow(long long x, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return x * modpow(x, p - 1) % MOD;
	
	long long r = modpow(x, p / 2);
	return r * r % MOD;
}
long long modinv(long long x){
	return modpow(x, MOD - 2);
}

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	
	int k = 3 * m + n;
	vector <long long> fact(k + 1), invfact(k + 1);
	
	fact[0] = 1;
	for(int i = 1; i <= k; i++)
		fact[i] = i * fact[i - 1] % MOD;
		
	invfact[k] = modinv(fact[k]);
	for(int i = k - 1; i >= 0; i--)
		invfact[i] = invfact[i + 1] * (i + 1) % MOD;

	auto C = [&](int n, int r) -> long long{
				return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
			};
	
	long long res = 0;
	
	for(int odd = 0; odd <= min(n, m); odd++){
		if(odd % 2 != m % 2)continue;
		res = (res + C(n, odd) * C((3 * m - odd) / 2 + n - 1, n - 1)) % MOD;
	}

	for(int mx = 2 * m + 1; mx <= 3 * m; mx++)
		res = (res + (MOD - n) * C(3 * m - mx + n - 2, n - 2)) % MOD;
	
	printf("%lld\n", res);
	
	return 0;
}


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

int main(){

  int n, m;
  int a[1111], b;
  int tmp[1111] = {};
  int max = 0, ans;

  cin >> n >> m;
  for(int i=0;i<n;i++) cin >> a[i];

  for(int i=0;i<m;i++){
    cin >> b;
    
    for(int j=0;j<n;j++)
      if(a[j] <= b){
	if(max < ++tmp[j]) max = tmp[j], ans = j+1;
	break;
      }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1168
#include <stdio.h>

int binary_search(int *data, int n, int key)
{
    int left, right, center;
    int cnt;
    
    cnt = 0;
    left = 0;
    right = n - 1;
    
    while (left <= right){
        cnt++;
        center = (left + right) / 2;

        if (data[center] == key){
            return (cnt);
        }
        if (data[center] > key){
            right = center - 1;
        }
        else {
            left = center + 1;
        }
    }
    
    return (cnt);
}


int main(void)
{
    int i, n;
    int array[100];
    int key;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &array[i]);
        }
        scanf("%d", &key);
        
        printf("%d\n", binary_search(array, n, key));
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <cstdio>

void print_array(int* a, int n) {
    printf("%d", a[0]);
    for (int i=1; i<n; i++) { printf(" %d", a[i]); }
    printf("\n");
}

int main() {
    int n;
    scanf("%d", &n);

    int* a = new int[n];
    scanf("%d", &a[0]);
    for (int i=1; i<n; i++) { scanf(" %d", &a[i]); }

    print_array(a, n);
    for (int i=1; i<n; i++) {
        int v = a[i];
        int j = i-1;
        while (j >= 0 and a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        print_array(a, n);
    }

    return 0;
}

Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    int big = 0;
    int small = 0;
    sort(a, a+N);
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            small += a[i];
        } else {
            big += a[i];
        }
    }

    cout << abs(big - small) << endl;
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
int partition(int a[],int l,int r)
{
	int i,j,t,p=l-1,q=l,k=a[r];
	for(;q<r;q++)
	if(a[q]<=k)
	{
		p++;
		t=a[q];
		a[q]=a[p];
		a[p]=t;
	}
	t=a[q];
	a[q]=a[++p];
	a[p]=t;
	return p;
}

int main(int argc, char *argv[])
{
	int n,i,a[100000],s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	s=partition(a,0,n-1);
	for(i=0;i<n;i++)
	{
		if(i==s)
		printf("[%d]",a[i]);
		else
		printf("%d",a[i]);
		if(i+1==n)
		printf("\n");
		else 
		printf(" ");
	}
	return 0;
}


Measured memory_bytes: 2100
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int sx = sc.nextInt();
	int sy = sc.nextInt();
	int tx = sc.nextInt();
	int ty = sc.nextInt();
	for(int i = 0; i < (tx - sx); i++) {
		System.out.print("R");
	}
	for(int i = 0; i < (ty - sy); i++) {
		System.out.print("U");
	}
	for(int i = 0; i < (tx - sx); i++) {
		System.out.print("L");
	}
	for(int i = 0; i < (ty - sy); i++) {
		System.out.print("D");
	}
	System.out.print("D");
	for(int i = 0; i < (tx + 1 - sx); i++) {
		System.out.print("R");
	}
	for(int i = 0; i < (ty - (sy - 1)); i++) {
		System.out.print("U");
	}
	System.out.print("L");
	System.out.print("U");
	for(int i = 0; i < (tx - (sx - 1)); i++) {
		System.out.print("L");
	}
	for(int i = 0; i < (ty + 1 - sy); i++) {
		System.out.print("D");
	}
	System.out.println("R");
}
}

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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,a,ans=0;
    cin >> n;
    for(ll i=1;i<=n;i++)
    {
        a=n/i;
        ans+=((a*(a+1)*i)/2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main (){
  int res=0 , n;
  cin>> n;
  string A;cin>>A;
  for(int i=2;i<n;i++){

    if(A[i] == 'C' && A[i-1]=='B' && A[i-2]=='A')res++;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    map <int,int> cnt;
    for (int i=2;i*i<=n;i++){
        while (n%i==0){
            n/=i; cnt[i]++;
        }
    }
    if (n>1) cnt[n]++;
    int ans=0;
    for (auto &it: cnt){
        int c=0;
        while ((c*(c+1))>>1<=it.ss) c++;
        ans += (c-1);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll t,i,n,x,y;
    ll ans=0;
    cin>>n;
    vector<ll>k(n),l(n);
    for(i=0;i<n;i++)
    {
        cin>>x;
        k.push_back(x);
    }
    for(i=0;i<n;i++){
        cin>>y;
        l.push_back(y);

    }
    for(i=0; i<k.size(); i++)
    {
        if(k.at(i)>l.at(i))
        {
            ans+=k.at(i)-l.at(i);
        }
    }

    cout<<ans<<endl;



    return 0;
}




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

#define ll long long

int dp[100001];
int n, k, arr[100001];
int pound(int pos)
{
    if (dp[pos] != -1)
        return dp[pos];
    
    int mn = INT_MAX;
    for (int i = 0; i < k; ++i)
        mn = min(mn, abs(abs(arr[pos] - arr[pos - i - 1])) + pound(pos - i - 1));
    return dp[pos] = mn;
}

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

    cin >> n >> k;
    k = min(n, k);

    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    dp[0] = 0;
    for (int i = 1; i < k; ++i)
        dp[i] = abs(arr[0] - arr[i]);

    cout << pound(n - 1);

    return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string [] args)
    {
        var rl = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        var a = rl[0] % rl[2] == 0 ? rl[0] : rl[0] + (rl[2] - rl[0] % rl[2]);
        var b = rl[1] - rl[1] % rl[2];
        if (a > b)
        {
            Console.WriteLine("0");
        }
        else
        {
            Console.WriteLine(b / rl[2] - a / rl[2] + 1);
        }
    }
}

Measured memory_bytes: 13268
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";

int main() {
	scanf("%lld %lld", &N, &M);
	cout << min(N % M, abs(M - (N % M)));
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main() {
  int H,N,tmp;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    cin >> tmp;
    H-=tmp;
  }
  if(H<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[] , int N){

    int i,j,t,sw=0,minj;
    for(i=0;i<N-1;i++){
      minj = i;
      for(j =i;j<N;j++){
        if (A[j] < A[minj] ) minj = j;
      }
      t =A[i];A[i]=A[minj];A[minj]=t;
      if( i!= minj)sw++;
    }
    return sw;
  }

int main(){
  int A[100],N,i,sw;

  scanf("%d",&N);
  for (i=0;i<N;i++)scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for (i=0; i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }

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

  return 0;
}

Measured memory_bytes: 2720
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	if n%2 == 1 {
		for i := 1; i <= m; i++ {
			fmt.Printf("%d %d\n", i, n-i)
		}
	} else {
		flag := true
		for l, r := 1, n-1; l < r && l <= m; l, r = l+1, r-1 {
			if flag && r-l <= n/2 {
				flag = false
				r--
			}
			fmt.Printf("%d %d\n", l, r)
		}
	}
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll n;
ll al[30]={};
string str;
ll ans=1;
bool l=false;
vector<int> v[200005];
int c[200005];
int num[200005];
ll dp[200005];
ll reg(int m){
	if(dp[m]!=-1)return dp[m];
	if(m==n)return 1;
	ll res1=0,res2=0;
	if(v[c[m]].size()!=num[m]+1&&v[c[m]][num[m]]+1!=v[c[m]][num[m]+1]){
		res1=reg(v[c[m]][num[m]+1])%r197;
	}
	res2=reg(m+1)%r197;
//	cout<<m<<" "<<(res1+res2)%r197<<endl;
	return dp[m]=(res1+res2)%r197;
}
int main() {
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,0,n){
		cin>>c[i];
		v[c[i]].push_back(i);
		num[i]=v[c[i]].size()-1;
	}
	cout<<reg(0)<<endl;
	return 0;
}


Measured memory_bytes: 20608
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    if(b-a+1 <= 2*k){
      for(int i=a; i<=b; i++){
        System.out.println(i);
      }
    }else{
      for(int i=a; i<a+k; i++){
        System.out.println(i);
      }
      for(int j=b-k+1; j<=b; j++){
        System.out.println(j);
        }
    }
  }
}


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

int main() {
    int d, n;
    cin >> d >> n;
  //so fucked up questions
    int p = pow(100, d);
    if (n == 100)
        n = 101;
    cout << p * n << "\n";
    return 0;
}


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


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

  string tmp = s;
  auto pos = tmp.find("()");
  while(pos != std::string::npos){
    tmp.erase(pos,2);
    pos = tmp.find("()");
  }
  swap(tmp,s);

  int sz=s.size();  
  int cnta=0;
  rep(i,s.rfind(")",sz)+1){
    if(s[i]==')'){ cnta++; } else { cnta--; }
  }
  
  int cntb=0;
  bool flag=false;
  for(int i=s.find("(",sz); i<sz; i++){
    if(flag==false){
      if(s[i]=='('){ cntb++; flag=true; }
      continue;
    }
    if(s[i]=='('){ cntb++; } else { cntb--; }
  }
  
  if(cnta>0){
    rep(i,cnta){ cout<<'('; }
  }
  cout << tmp;
  if(cntb>0){
    rep(i,cntb){ cout<<')'; }
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int Max = A[0];
            long sum = 0;
            for(int i = 1; i < n; i++)
            {
                if (Max >= A[i])
                {
                    sum += (Max - A[i]);
                }
                else
                {
                    Max = A[i];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 46724
#include<stdio.h>
#include<string.h>
#define is(a) (a=='A'||a=='C'||a=='G'||a=='T')
char a[66];int len,sum,ans;
main()
{
	scanf("%s",a);len=strlen(a);
	for(register int i=0;i<len;++i)
	{
		sum=0;
		for(register int j=i;j<len&&is(a[j]);++j,++sum);
		if(sum>ans)ans=sum;
	}
	printf("%d",ans);
}/**/

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  int x,y;
  for(int i=1; i<10000; i++){
    cin >> x >> y;
    if(x==0&&y==0){
      break;
    }
    if(y<x){
      cout << y <<  " " << x <<endl;
    }
    else{
      cout << x <<  " " << y <<endl;
    }
  }
}



Measured memory_bytes: 3052
n = input()
m = len(n)
K = int(input())
#状態をもつ：i桁目まで見たときのj（その値は指定された値未満かどうか）において0でない数字がk個ある状態
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1

for i in range(1, m+1):
    l = int(n[i-1])
    for k in range(K+1):
        
        #その値通りだった時、l=0だと0の数を増やせないのでi-1桁目でk個になってる個数を引き継ぐ
        if l == 0:
            dp[i][0][k] = dp[i-1][0][k]
        else:
            if k >= 1:
                #l!=0の場合にはまだ増やせるのでi-1桁目でk-1個になってる個数を引き継ぐ
                dp[i][0][k] = dp[i-1][0][k-1]
        

        dp[i][1][k] += dp[i-1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i-1][0][k]
        if k >= 1:
            dp[i][1][k] += 9*dp[i-1][1][k-1]
            if l != 0:
                dp[i][1][k] +=  (l-1)*dp[i-1][0][k-1]

print(dp[m][0][K] + dp[m][1][K])

Measured memory_bytes: 3064