akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    int n, s, h = 1, i, j, l = 1, f, x;
    int p[100], juni[100];

    while(1){
        scanf("%d,%d", &n, &p[h]);
        if(n == 0) break;
        h++;
    }

    for(i = 30; i >= 0; i--){
        for(j = 0; j < h; j++){
            if(i == p[j]){
                juni[j] = l;
                f = 1;
            }
        }
        if(f == 1){
            l++;
            f = 0;
        }
    }
    while(scanf("%d", &x) != EOF) printf("%d\n", juni[x]);
    return 0;
}

Measured memory_bytes: 600
s = input()
n,s = len(s),int(s)

ans=0
for i in range(2**(n-1)):
    num = s
    cut=1
    for j in range(n-1):
        if ((i>>j)&1):
            ans+=num%(10**cut)
            num=num//(10**cut)
            cut=1
        else:
            cut+=1
    ans+=num

print(ans)

Measured memory_bytes: 3064
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()
    N = len(S)
    M = len(T)

    SS = S + S

    A = [False] * 26
    for c in S:
        A[ord(c) - 97] = True

    for c in T:
        if not A[ord(c) - 97]:
            print(-1)
            return

    B = [[] for _ in range(26)]
    for i, c in enumerate(SS):
        B[ord(c) - 97].append(i)

    i = B[ord(T[0]) - 97][0]
    ans = i + 1
    for c in T[1:]:
        j = B[ord(c) - 97][bisect_right(B[ord(c) - 97], i)]
        ans += j - i
        if j < N:
            i = j
        else:
            i = j - N

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

string S;
int N;
int G[100005];

vector<int> VR, VL;

int ans[100005];

int main(void) {

	cin >> S;

	N = S.size();

	S = "#" + S + "#";

	for (int i = 1; i <= N; i++) {
		if (S[i] == 'R') {
			VR.push_back(i);
		}
		else if (S[i] == 'L') { VL.push_back(i); }
	}


	for (int i = 1; i <= N; i++) {
		if (S[i] == 'R') { auto it = upper_bound(VL.begin(), VL.end(), i);
		G[i] = *it;
		                 }
		else if (S[i] == 'L') {
			auto it = lower_bound(VR.begin(), VR.end(), i);
			it--;
			G[i] = *it;
		}
	}

	/*for (int i = 1; i <= N; i++) {
		cout << i << " G= " << G[i] << endl;
	}*/


	for (int i = 1; i <= N; i++) {
		if (S[i] == 'R') {
			int p = G[i] - i;
			if (p % 2 == 0) { ans[G[i]]++; }
			else { ans[G[i] - 1]++; }
		}
		else if (S[i] == 'L') {
			int p = i - G[i];
			if (p % 2 == 0) { ans[G[i]]++; }
			else { ans[G[i] + 1]++; }
		}
	}

	for (int i = 1; i <= N; i++) {
		if (i != 1) { cout << " "; }
		cout << ans[i];
	}cout << endl;

	return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};



int main() {
    int H,A; cin>>H>>A;
    cout<<(H-1)/A+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    yorn(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d ))

    return 0;
}

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

using namespace std;

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

    vector<int> v(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }

    int a, flag = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++)
        if (v[i] % 10) {
            a = v[i];
            flag = 1;
            break;
        }
    
    if (sum % 10) a = 0;
    if (flag) cout << sum - a << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#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 <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
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 { return mint(*this) += a; }
   mint operator-(const mint a) const { return mint(*this) -= a; }
   mint operator*(const mint a) const { return mint(*this) *= 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, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
   int S;
   cin >> S;
   mint dp[3000];
   fill(dp, dp + 3000, 0);
   mint sum = 0;
   for (int i = 3; i <= S; i++)
   {
      sum += dp[i - 3];
      dp[i] = sum + 1;
   }
   cout << dp[S] << endl;
   return 0;
}


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

int main(){
int n;
  cin >> n;
  int d[n];
  
  for(int i=0;i<n;i++) cin >> d[i];
int64_t sume=0;
int64_t counte=0;  
for(int i=0;i<n;i++){
  sume+=d[i];
  if(i%2==0){
    if(sume<=0){
      counte+=1-sume;
      sume=1;    
    }
  }
  else{
    if(sume>=0){
      counte+=sume+1;
      sume=-1;
    }
  }
}
int64_t sumo=0;
int64_t counto=0;  
for(int i=0;i<n;i++){
  sumo+=d[i];
  if(i%2==1){
    if(sumo<=0){
      counto+=1-sumo;
      sumo=1;    
    }
  }
    else{
      if(sumo>=0){
        counto+=sumo+1;
        sumo=-1;
       }
    }
}
cout << min(counte,counto) << endl;
}

Measured memory_bytes: 3984
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

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

int main() {
	int a;
  int b;
  int c;
  bool poor = false;
  cin >> a;
  cin >> b;
  cin >> c;
  if (a == b == c) {
    poor = false;
  } else {
    if (a == b && a != c) {
    poor = true;
  } else {
    if (a == c && a != b) {
    poor = true;
  } else {
    if (b == c && b != a) {
    poor = true;
  } else {
    if (b == a && b != c) {
    poor = true;
  } else {
    if (c == a && c != b) {
    poor = true;
  } else {
    if (c == b && c != a) {
    poor = true;
  } else {
    poor = false;
  }
  }
  }
  }
  }
  }
  }
  
  
  if (poor == true) {
    cout << "Yes";
  } else {
    cout << "No";
  }
	return 0;
}


Measured memory_bytes: 3632
n = int(input())

aList = []
bList = []
for i in range(n):
    a, b = map(int, input().split())
    aList.append(a)
    bList.append(b)

aList.sort()
bList.sort()


if not n % 2 == 0:
    half = (n+1) // 2 - 1
    print(bList[half] - aList[half] + 1)
else:
    half = (n) // 2 - 1
    print(bList[half] + bList[half+1] - (aList[half] + aList[half+1]) + 1)



Measured memory_bytes: 25388
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	static int n, c[], s[], f[];
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		n = fs.nextInt();
		c = new int[n-1];
		s = new int[n-1];
		f = new int[n-1];
		for(int i=0;i<n-1;i++) {
			c[i] = fs.nextInt();
			s[i] = fs.nextInt();
			f[i] = fs.nextInt();
		}
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(dfs(i, 0));
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
	static int dfs(int v,int sum) {
		if(v==n-1) {
			return sum;
		}
		int t = (sum + f[v] - 1) / f[v];
		int now = Math.max(s[v], t*f[v]);
		return dfs(v+1, now + c[v]);
	}
}

class UnionFind{
	int parent[];
	UnionFind(int N){
		parent = new int[N];
		Arrays.fill(parent, -1);
	}
	
	boolean same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x) {
		if(parent[x]<0)return x;
		return parent[x] = root(parent[x]);
	}
	int size(int x) {
		return -parent[root(x)];
	}
	void unite(int x, int y) {
		if(size(x)<size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)return;
		parent[rx] += parent[ry];
		parent[ry] = rx;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


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

    ll n;
    cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];

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

    vi suma(n,0);
    suma[0] = a[0];
    repA(i,1,n-1){
        suma[i] = a[i] + suma[i-1];
    }

    ll ans = 1;
    repD(i,n-2,0){
        if(2*suma[i] >= a[i+1]){
            ans++;
        } else {
            cout<<ans<<endl;
            exit(0);
        }
    }

    cout<<ans<<endl;

    timer();
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 2e5+10;

ll N, K;
ll A[MAX], F[MAX];

bool check(ll n) {
    if (n == 0) {
        ll s = 0;
        REP (i, N) s += A[i];
        return s <= K;
    }
    ll k = 0;
    REP (i, N) {
        ll b = max(0ll, A[N-i-1]*F[i] - n);
        k += (b+F[i]-1)/F[i];
    }
    return k <= K;
}

ll solve() {
    sort(A, A+N);
    sort(F, F+N);
    ll ng = -1, ok = 1e12;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i];
    REP (i, N) cin >> F[i];
    cout << solve() << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
   int x;
   cin>>x;
   if(x>=400&&x<=599) cout<<8<<endl;
   else if(x>=600&&x<=799) cout<<7<<endl;
else if(x>=800&&x<=999) cout<<6<<endl;
 else if(x>=1000&&x<=1199) cout<<5<<endl;
 else if(x>=1200&&x<=1399) cout<<4<<endl;
 else if(x>=1400&&x<=1599) cout<<3<<endl;
 else if(x>=1600&&x<=1799) cout<<2<<endl;
 else if(x>=1800&&x<=1999) cout<<1<<endl;
 
 
 
 
 
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
XYH = [list(map(int, input().split())) for i in range(N)]

XYH.sort(key=lambda x: x[2], reverse=True)

for x in range(101):
  for y in range(101):
    tmp_H = XYH[0][2]+abs(XYH[0][0]-x)+abs(XYH[0][1]-y)
    A = 0
    for i in range(1,N):
      if tmp_H - abs(XYH[i][0]-x) - abs(XYH[i][1]-y) == XYH[i][2]:
        A += 1
      elif tmp_H - abs(XYH[i][0]-x) - abs(XYH[i][1]-y) < 0 and XYH[i][2] == 0 :
        A += 1
    
    if A == N-1:
      print(x,y,tmp_H)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int mn = -1000000;
  int mx = 1000000;
  int k,x;
  cin >> k >> x;
  int tmp_min,tmp_max;
  tmp_min = x - k + 1;
  tmp_max = x + k - 1;
  int ans_min, ans_max;
  ans_min = max(mn, tmp_min);
  ans_max = min(mx, tmp_max);
  for (int i=ans_min; i < ans_max+1; i++) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[100002];
    ll lar = -10000000;
    ll les = 10000000;
    ll larnum;
    ll lesnum;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > lar){
            lar = a[i];
            larnum = i;
        }
        if(a[i] < les){
            les = a[i];
            lesnum = i;
        }
    }
    if(larnum == lesnum){
        cout << (n - 2) * abs(a[0]) << endl;
        int s = a[0];
        for(int i = 0; i < n - 2; i++){
            cout << s << " " << a[0] << endl;
            s -= a[0];
        }
        if(a[0]) cout << a[0] << " " << s << endl;
        else cout << s << " " << a[0] << endl;
        return 0;
    }
    ll pl = lar;
    ll mi = les;
    for(int i = 0; i < n; i++){
        if(a[i] < 0 && i != larnum && i != lesnum){
            lar -= a[i];
        }
        if(a[i] >= 0 && i != larnum && i != lesnum){
            les -= a[i];
        }
    }
    cout << lar - les << endl;
    for(int i = 0; i < n; i++){
        if(a[i] < 0 && i != larnum && i != lesnum){
            cout << pl << " " << a[i] << endl;
            pl -= a[i];
        }
        if(a[i] >= 0 && i != larnum && i != lesnum){
            cout << mi << " " << a[i] << endl;
            mi -= a[i];
        }
    }
    cout << pl << " " << mi << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a;cin>>n;
  map<ll,ll> mp;
  rep(i,n-1) {
    cin>>a;a--;
    mp[a]++;
  }
  rep(i,n) {
    if(mp[i]!=0) print(mp[i]);
    else print(0);
  }
  return 0;
}

Measured memory_bytes: 16156
#include <bits/stdc++.h>
					
using namespace std;
			
typedef long long ll;
#define mp make_pair
#define pub push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double
#define sz(a) (int)a.size()

string s;
int cnt[2];

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	for (char c : s) cnt[c - '0']++;
	int dd = 0;
	for (int ans = s.size(); ; ans--){
		if (min(cnt[0], cnt[1]) == 0) cout << ans, exit(0);
		cnt[s[dd] - '0']--;
		cnt[s[(int)s.size() - 1 - dd] - '0']--;
		dd++;
	}
}

Measured memory_bytes: 512
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int n,a[202020],k,b[202020];
map<int,int> mp;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	
	cin >> n >> k;
	int ans = 0;
	int sum = 0;
	mp[0]++;
	int l = 0;
	for(int i=1;i<=n;i++){
		if(i-l>=k){
			l++;
			mp[b[l-1]]--;
		}
		cin >> a[i];
		sum+=a[i];
		sum%=k;
		int cur = (-sum+i+k)%k;
		ans+= mp[cur];
		b[i] = (i-sum+k)%k;
		mp[(-sum+i+k)%k]++;
		//cout << (-sum+i+inf*k)%k << " ";
	}
	cout << ans << endl;
    

return 0;
}
///....


Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String N = sc.next();
    int A = N.charAt(0) - '0';
    int B = N.charAt(1) - '0';
    int C = N.charAt(2) - '0';
    int D = N.charAt(3) - '0';
    int n = 7;
    
    if (A + B + C + D == n) {
      System.out.println(A + "+" + B + "+" + C + "+" + D + "=7");
    } else if (A + B + C - D == n) {
      System.out.println(A + "+" + B + "+" + C + "-" + D + "=7");
    } else if (A + B - C + D == n) {
      System.out.println(A + "+" + B + "-" + C + "+" + D + "=7");
    } else if (A + B - C - D == n) {
      System.out.println(A + "+" + B + "-" + C + "-" + D + "=7");
    } else if (A - B + C + D == n) {
      System.out.println(A + "-" + B + "+" + C + "+" + D + "=7");
    } else if (A - B + C - D == n) {
      System.out.println(A + "-" + B + "+" + C + "-" + D + "=7");
    } else if (A - B - C + D == n) {
      System.out.println(A + "-" + B + "-" + C + "+" + D + "=7");
    } else if (A - B - C - D == n) {
      System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
    }
  }
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> road(n+1, 0);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        road[a]++;
    }
    int to0 = 0, toN = 0;
    for (int cur = x; cur >= 0; cur--) to0 += road[cur];
    for (int cur = x; cur <= n; cur++) toN += road[cur];
    cout << min(to0, toN) << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  if(s.at(k-1)=='A'){
    s.at(k-1)='a';
  }
  if(s.at(k-1)=='B'){
    s.at(k-1)='b';
  }
  if(s.at(k-1)=='C'){
    s.at(k-1)='c';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int M;
int X;

void solve(){
	cout << N + X / M << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> X;
	M = 10000;
	rep(i, N) {
		int m;
		cin >> m;
		X -= m;
		chmin(M, m);
	}
		solve();
	return 0;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  int count = 1;
  int x = 0;
  for (int i = 0; i < N; i++) {
    int l;
    cin >> l;
    x += l;
    if (x <= X) {
      count++;
    }
    else {
      break;
    }
  }
  cout << count <<endl;
}

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

typedef long long ll;

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

    int n;
    cin >> n;
    double sum=0;
    for(int i=0;i<n;i++){
        double a;
        cin >> a;
        sum += 1/a;
    }
    printf("%.12lf\n",1.0/sum);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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() {
  char a; cin >> a;
  char ans;
  if(a == 'A') ans = 'T';
  else if(a == 'T') ans = 'A';
  else if(a == 'C') ans = 'G';
  else ans = 'C';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import defaultdict, deque

def solve():
    N, K = map(int, input().split())
    H = defaultdict(int)
    for _ in range(N):
        H[int(input())] += 1
    if K in H.values():
        res = 0
    else:
        H = sorted(list(H.items()))
        res = float('inf')
        i = 0
        j = 0
        b = H[0][0]
        t = H[0][0]
        k = H[0][1]
        h = 0
        while j < len(H)-1:
            if k < K:
                j += 1 
                k += H[j][1]
                h += H[j][0] - t
                t = H[j][0]
            if k >= K:
                res = min(res, h)
                k -= H[i][1]
                i += 1
                h -= H[i][0] - b
                b = H[i][0]

    return str(res)

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

Measured memory_bytes: 20960
def main

  n, k = ARGF.gets.split.map(&:to_i)
  nums = ARGF.gets.split.map(&:to_i)

  # 1 の場所を探す
  pos1 = nums.find_index(1)

  # またぎパターンに対応出来てなかった

  # # k = 3
  # # pos1 = 3
  # #   . . . 1
  # # 下に2(k-1)ずつ拾っていき、何回で先頭に到達する？
  # head_cnt = (pos1+(k-2)) / (k - 1)
  #
  # # 上も同様
  # # num.count = 6
  # # pos1 = 3
  # #   . . . 1 . .
  # tail_cnt = (nums.count - pos1 - 1 + (k-2)) / (k - 1)
  #
  # # puts "#{nums.count}: #{pos1}: #{head_cnt}:#{tail_cnt}"
  # puts head_cnt + tail_cnt
  #
  # # k = 4 つまり3ずつ拾う
  # # 0 1 2 3 4 5 6 7 8 9 10
  # # 0 0 0 1 1 1 2 2 2 3 3
  # # 0 1 1 1 2 2 2 3 3 3 4

  puts (nums.count - 1 + (k-2)) / (k - 1)

end

if __FILE__ == $0
  main
end


Measured memory_bytes: 8068
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    vector<vector<int>> X(N, vector<int>(D, 0));

    REP(row, N)
    {
        REP(col, D)
        {
            int x;
            cin >> x;
            X[row][col] = x;
        }
    }

    int count = 0;
    REP(i, N)
    {
        for (int j = i+1; j < N; j++)
        {
            double d_ij = 0.0;
            REP(index, D)
                d_ij += (X[i][index] - X[j][index]) * (X[i][index] - X[j][index]);
            
            d_ij = sqrt(d_ij);

            if ( ceil(d_ij) == floor(d_ij) )
                count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int d,n;
cin>>d>>n;
if(d==0&&n!=100)
	cout<< n <<endl;
else if(d==0&&n==100){	
n++;
cout<< n <<endl;
}
else if(d==1&&n!=100)
    cout<< 100*n <<endl;
else if(d==1&&n==100){
n++;
cout<< 100*n <<endl;
}
else if(d==2&&n!=100)
	cout<< 10000*n <<endl;	
else if(d==2&&n==100){
	n++;
	cout<< 10000*n <<endl;
}
}


Measured memory_bytes: 256
N = int(input())
src = list(map(lambda x:int(x)-1,input().split()))

mem = []
seq = 0
for i,a in enumerate(src):
    if i == a:
        seq += 1
    else:
        if seq > 0:
            mem.append(seq)
            seq = 0
if seq:
    mem.append(seq)

ans = 0
for a in mem:
    ans += (a+1)//2
print(ans)


Measured memory_bytes: 14008
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int N, K, R, of[128], is[128];

int main() {
    scanf("%d%d", &N, &K);
    rep (i, K) {
        int m, b;
        scanf("%d", &m);
        rep (_, m) {
            scanf("%d", &b);
            b--;
            of[b] = i;
        }
    }
    scanf("%d", &R);
    rep (_, R) {
        int p, q;
        scanf("%d%d", &p, &q);
        p--, q--;
        if (of[p] == of[q]) is[p] = is[q] = 1;
    }
    int ans = 0;
    rep (i, N) ans += is[i];
    printf("%d\n", ans);
    return 0;
}

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

int main(void){
    int n, r, p, c;
    while(cin >> n >> r){
        int A[51] = {0};
        if(n == 0 && r == 0)    break;
    for(int i = 1; i <= n; i++) A[i] = n+1-i;
    for(int j = 0; j < r; j++){
        cin >> p >> c;
        rotate(A+1, A+p, A+p+c);
    }
    cout << A[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define MAXN 200005
#define PLI pair<long long,int>
#define fi first
#define se second
#define mp make_pair
#define ha 99994711
#define ba 823
//#define ivorysi
using namespace std;
typedef long long int64;
int N;
char s[305][305],b[305][305];
int64 hc[305],hr[305],e;
inline int C(int x) {
    return x > N ? x - N : x;
}
bool check(int y) {
    int T = C(N + y);
    for(int i = 1 ; i <= N ; ++i) 
        hr[i] = (hr[i] * ba + (b[i][T] - 'a' + 1)) % ha;
    for(int i = 1 ; i <= N ; ++i) {
        if(hr[i] != hc[C(i + y)]) {
            T = C(N + y + 1);
            for(int j = 1 ; j <= N ; ++j) 
                hr[j] = (hr[j] - e * (b[j][T] - 'a' + 1) % ha + ha) % ha;
            return false;
        }
    }
    T = C(N + y + 1);
    for(int i = 1 ; i <= N ; ++i) 
        hr[i] = (hr[i] - e * (b[i][T] - 'a' + 1) % ha + ha) % ha;
    return true;
}
void Solve() {
    scanf("%d",&N);
    if(N == 1) {
        puts("1");return;
    }
    e = 1;
    for(int i = 1 ; i < N ; ++i) e = e * ba % ha;
    for(int i = 1 ; i <= N ; ++i) {
        scanf("%s",s[i] + 1);
    }
    int cnt = 0;
    for(int A = 0 ; A < N ; ++A) {
        memset(hc,0,sizeof(hc));
        memset(hr,0,sizeof(hr));
        for(int i = 1 ; i <= N ; ++i) {
            for(int j = 1 ; j <= N ; ++j) {
                b[i][j] = s[C(i + A)][j];
                hc[j] = (hc[j] * ba + (b[i][j] - 'a' + 1)) % ha;
                if(j != N) {
                    hr[i] = (hr[i] * ba + (b[i][j] - 'a' + 1)) % ha;
                }
            }
        }
        for(int B = 0 ; B < N ; ++B) {
            if(check(B)) ++cnt;
        }
    }
    printf("%d\n",cnt);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);

int main(){
    int x,a,b; cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)) cout << "B" << endl;
    else cout << "A" << endl;
}

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

// APG4b-N
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  int Alice = 0;
  int Bob = 0;

  // bubble sort
  int rightend = n;
  while (rightend > 0)
  {
    for (int i = 1; i < rightend; i++)
    {
      if (a.at(i-1) < a.at(i))
      {
        int temp = a.at(i-1);
        a.at(i-1) = a.at(i);
        a.at(i) = temp;
      }
    }
    rightend--;
  }

  for (int i = 0; i < n; i++)
  {
    if (!(i%2)) Alice += a.at(i);
    else Bob += a.at(i);
  }

  cout << Alice - Bob << endl;

}


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

using namespace std;

#define ll long long
#define f(i,a,n) for(ll i=a;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[16];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 5*1e5;



int main(){
    AC
    int a, b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3608
void main()
{
    long n = rdElem;
    string s = rdStr;

    s.count("ABC").writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// s1870240氏.
// https://atcoder.jp/contests/tenka1-2019-beginner/submissions/5387642
#include <bits/stdc++.h>
int main(){
    int n, ans = 0, ok = 0;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);
    for(int i = 0; i < n; i++) if(s[i]=='.') ans++;
    ok = ans;
    for(int i = 0; i < n; i++){
        if(s[i] == '#') ok++;
        else            ok--;
        if(ok < ans)    ans = ok;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 384
program ABC_080_B_HarshadNumber
   implicit none
   integer i, N, Nold, fN
   read(*, *) N
   fN = 0
   Nold = N
   do i = 1, 9
       fN = fN + mod(N, 10) 
	   N = N / 10
   end do
   if(mod(Nold, fN) == 0) then
       write(*, *) 'Yes'
   else
       write(*, *) 'No'
   end if
end program ABC_080_B_HarshadNumber

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;
VI c,s,f;
lint ans[5005];
int main() {
	make(n);
	FOR(i,0,n-1) {
		make3(a, b, x);
		c.pb(a);
		s.pb(b);
		f.pb(x);
	}
	c.pb(0); s.pb(0);
	FOR(i,0,n) {
		ans[i] = s[i] + c[i];
		FOR(j,i+1,n-1) {
			if (s[j] > ans[i]) ans[i] = s[j];
			while (ans[i] % f[j] != 0) ans[i]++;
			ans[i] += c[j];
		}
		cout << ans[i] << "\n";
	}
	cout << endl;


}


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

int main()
{
    int N;
    cin >> N;
    while (N > 0)
    {
        if (N % 4 == 0 || N % 7 == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        N -= 7;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int a,b,c,d,e,f;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<=b)
	e=a;
	else
	e=b;
	if(c<=d)
	f=c;
	else
	f=d;
	printf("%d\n",e+f);

	
	
	
	return 0;

}
	
	

Measured memory_bytes: 1724
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    if(c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 >= 1000) cout << 1 << endl;
    else                                                                        cout << 0 << endl;
}


Measured memory_bytes: 3104
#include <cstdio>

using namespace std;

int main() {
  long long X, Y;
  scanf("%lld %lld", &X, &Y);
  long long ans_2 = Y/X;
  int ans = 0;
  while (ans_2 > 0) {
    ans_2 = ans_2 / 2;
    ans += 1;
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

assist = 0
kill = 0

for i in range(n):
    if assist+b[i] < a[i]:
        kill += assist+b[i]
        assist = 0
    else:
        if assist <= a[i]:
            kill += a[i]
            assist += b[i] - a[i]
        else:
            kill += a[i]
            assist = b[i]

if assist == 0:
    print(kill)
elif assist < a[-1]:
    print(kill + assist)
else:
    print(kill + a[-1])

Measured memory_bytes: 18624
program ABC157_C
  integer::X,Y,Z,A
  integer,dimension(:),allocatable::S,C
  read(5,*)N,M
  allocate(S(M),C(M))
  X=0
  Y=0
  Z=0
  if(N==2) Y=1
  if(N==3) X=1
  K=0
  do I=1,M
     read(5,*)S(I),C(I)
  end do
  if(M>1) then
     do I=1,M-1
        if(N>1 .and. (S(I)==1 .and. C(I)==0) ) then
           K=1
           go to 10
        end if
        do J=2,M
           if(S(I)==S(J) .and. C(I)/=C(J)) then
              K=1
              go to 10
           end if
        end do
     end do
  end if
  do I=1,M
     if(N==3 .and. S(I)==1) then
        X=C(I)
     else if( (N==3 .and. S(I)==2) .or. (N==2 .and. S(I)==1)) then
        Y=C(I)
     else
        Z=C(I)
     end if
  end do
  A=100*X+10*Y+Z
  if(N==3 .and. A<100) K=1
  if(N==2 .and. A<10) K=1
10 if(K==1) then
     write(6,*)'-1'
  else
     write(6,*)A
  end if
end program ABC157_C

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(void){
	std::string s;
	std::string code="CODEFESTIVAL2016";
	int count=0;
	std::cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]!=code[i])count++;
	}
	std::cout<<count<<std::endl;
	return 0;
}

Measured memory_bytes: 256
import math
a = input().split()
a = [int(i) for i in a]
x_list = input().split()
x_list = sorted([int(i) for i in x_list])


kankaku = [x_list[i + 1] - x_list[i] for i in range(len(x_list) - 1)]

kankaku = sorted(kankaku, key=lambda x: - x)


for i in range(a[0] - 1):
    if len(kankaku) == 0:
        break
    kankaku.pop(0)

if len(kankaku) > 0:
    print(sum(kankaku))
else:
    print(0)

Measured memory_bytes: 14728
r, c = map(int, input().split())
mat = []
c_sum = [0] * (c+1)
for i in range(r):
    tmp = list(map(int, input().split()))
    tmp.append(sum(tmp))
    mat.append(tmp)

for i in range(r):
    for j in range(c+1):
        c_sum[j] += mat[i][j]
    
mat.append(c_sum)
for i in range(len(mat)):
    print(*mat[i])


Measured memory_bytes: 6224
#include<stdio.h>
int main(){
  int tmp,cnt=0,n;
  scanf("%d",&n);
  tmp=n;
  while(tmp>0){
    tmp /= 10;
    cnt++;
  }
  if(cnt==1)
    printf("%d",n);
  else if(cnt==2)
    printf("9");
  else if(cnt==3)
    printf("%d",n-90);
  else if(cnt==4)
    printf("909");
  else if(cnt==5)
    printf("%d",n-9090);
  else if(cnt==6)
    printf("90909");
  return 0;
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,m=nm()
a=nl()
j=0
count=sum(a)/(4*m)
for i in a:
    if i>=count:
        j+=1
if j<m:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
parseInt(x) = parse(Int,x)

function main()
	a,b,c,k = map(parseInt, split(readline()))
	v = [a,b,c]
	x = [0 1 1;1 0 1;1 1 0]
	v = x^k*v
    println(abs(v[1]-v[2]) >= 1000000000000000000?"Unfair":v[1]-v[2])
end
main()

Measured memory_bytes: 158824
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

ll Cc(ll n, ll m)
{
    if (m > n / 2)
        m = n - m;
    ll a = 1, b = 1;
    for (int i = 1; i <= m; i++)
    {
        a *= n + 1 - i;
        b *= i;
        if (a % b == 0)
        {
            a /= b;
            b = 1;
        }
    }
    return a / b;
}
const int maxn = 1e5 * 2 + 2;
int a[maxn], num[maxn];
ll c[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    int mm = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        mm = max(a[i], mm);
        num[a[i]]++;
    }
    for (int i = 2; i <= n; i++)
        c[i] = Cc(i, 2);
    ll ans = 0;
    for (int i = 1; i <= mm; i++)
        if (num[i])
            ans += c[num[i]];

    for (int i = 1; i <= n; i++)
    {
        ll ansn = ans;
        ansn -= c[num[a[i]]];
        ansn += c[num[a[i]] - 1];
        printf("%lld\n", ansn);
    }
    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>

int main(void){
	int n,k,a,b;
	long ans=0;
	scanf("%d %d",&n,&k);
	for(b=k+1;b<=n;b++){
		ans=ans+(n/b)*(b-k);
		if(n%b>=k){
			ans=ans+((n%b)-(k-1));
		}
		if(k==0){
			ans--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;
const int N=2e5+5;
#define ll long long
bool done[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,k,R,P,S;
    long long ans=0;
    string s;
    cin>>n>>k>>R>>S>>P;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i>=k&&s[i]==s[i-k]&&done[i-k]) continue;
        if(s[i]=='r') ans+=P;
        if(s[i]=='p') ans+=S;
        if(s[i]=='s') ans+=R;
        done[i]=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 592
import numpy as np
h,n=map(int,input().split())

ab=np.array([list(map(int,input().split())) for _ in range(n)])

dp=np.zeros(10**4+1,int) 
dp[0]=0

for a,b in ab:
      dp[1:a+1]=np.minimum(dp[1:a+1],b)

for i in range(1,h+1):
  dp[i]=np.min(dp[i-ab[:,0]]+ab[:,1])
print(dp[h])


Measured memory_bytes: 12616
import numpy as np
import sys
input = sys.stdin.readline
n, m, q = map(int, input().split())
cnt = np.zeros((n+1, n+1), dtype=np.int32)
L, R = map(np.array, zip(*[map(int, input().split()) for _ in range(m)]))
np.add.at(cnt, (L, R), 1)

S = np.cumsum(cnt, axis=0).cumsum(axis=1)
L, R = map(np.array, zip(*[map(int, input().split()) for _ in range(q)]))

ans = S[R, R]-S[R, L-1]-S[L-1, R]+S[L-1, L-1]
print(*ans, sep='\n')

Measured memory_bytes: 112628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=55;
//i_am_noob
string str1,str2;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str1 >> str2;
	print1(str2+str1);
	return 0;
}

Measured memory_bytes: 256
r,c=map(int,input().split())

x=list()
for i in range(r):
    x.append(list(map(int,input().split())))
    x[i].append(sum(x[i]))
    print(' '.join(map(str, x[i])))

y=list()
for j in range(c+1):
    z=0
    for i in range(r):
        z+=x[i][j]
    y.append(z)

print(" ".join(list(map(str, y))))


Measured memory_bytes: 5676
// 山登り法しか思いつかない
#include <bits/stdc++.h>
using namespace std;

int D;
int res[365];  // 解答
long long c[26];
long long s[365][26];

long long evaluate() {
    static int LatestProb[26];
    long long score = 0;
    memset(LatestProb, 0, sizeof(LatestProb));
    for (int d = 0; d < D; ++d) {
        score += s[d][res[d]];
        LatestProb[res[d]] = d + 1;
        for (int j = 0; j < 26; ++j) {
            score -= c[j] * (d + 1 - LatestProb[j]);
        }
    }
    return score;
}

int main() {
    cin >> D;
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    random_device rnd;                         // 非決定的な乱数生成期を生成
    mt19937 mt(rnd());                         // メルセンヌ・ツイスタの32bit版、引数は初期シード値
    uniform_int_distribution<> rand26(0, 25);  // [0, 25]範囲の一様乱数
    uniform_int_distribution<> rand365(0, 364);

    for (int i = 0; i < D; ++i) {
        res[i] = rand26(mt);
    }
    // 山登り法をして、解を大きくしていく。
    long long score = evaluate();
    int IterationNum = 10000;
    while (IterationNum--) {
        // 二つ変える
        int ch1 = rand365(mt);
        int ch2;
        while ((ch2 = rand365(mt)) == ch1)
            ;
        // 変える前の情報を格納
        int prev1 = res[ch1], prev2 = res[ch2];
        // どの問題にするか決める
        int ct1, ct2;
        while ((ct1 = rand26(mt)) == prev1)
            ;
        while ((ct2 = rand26(mt)) == prev2)
            ;
        // 変更
        res[ch1] = ct1, res[ch2] = ct2;
        // スコア計算
        long long nxt = evaluate();
        if (score < nxt) {
            score = nxt;
        } else {
            // 元に戻す。
            res[ch1] = prev1, res[ch2] = prev2;
        }
    }

    for (int i = 0; i < D; ++i) {
        cout << res[i] + 1 << endl;
    }
    //cout << "score: " << score << endl;
    return 0;
}

Measured memory_bytes: 3680
A = int(input()) 
B = int(input()) 
C = int(input()) 
X = int(input()) 

ans = 0
for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if i * 500 + j * 100 + k * 50 == X:
        ans += 1
        
print(ans)


Measured memory_bytes: 9196
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#define long long

using namespace std;

int main() {
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a>b){
		cout<<b*c+(a-b)*d;
	}
	else{
		cout<<a*c;
	}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0;
long long ans=0;
int main()
{
  cin>>s;
  int g=s.size();
  for(int i=0;i<(1<<(g-1));i++)
    {
      long long m=s[0]-'0';
      for(int j=0;j<g-1;j++)
        {
          if(i&(1<<j))
           {
             ans+=m;
             m=0;
           }
          m=m*10+s[j+1]-'0';
        }
      ans+=m;
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624