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

int main(){
  int n,ans = 0;cin >> n;
  string s[n];for(int i=0;i<n;++i)cin >> s[i];
  map<string,int> m;
  for(int i=0;i<n;++i){
    if(m[s[i]] == 0)ans += 1;
    m[s[i]] += 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 25428
from collections import deque

N = int(input())

d = deque()

d.append(([],0,-1))
dlen = 1
while dlen != 0:
    arr,le,ma = d.popleft()
    dlen -= 1
    if le == N:
        for a in arr:
            print('abcdefghij'[a],end='')
        print('')
        continue
    for i in range(ma+2):
        aarr = arr + [i]
        lle = le + 1
        mma = max(ma,i)
        d.append((aarr,lle,mma))
        dlen += 1




Measured memory_bytes: 120540
k, n = map(int, input().split())
a = list(map(int, input().split()))

dist = [0] * n
dist[0] = k - a[n - 1] + a[0]
for i in range(1, n):
    dist[i] = a[i] - a[i - 1]

print(k - max(dist))

Measured memory_bytes: 26444
import numpy as np

def ABC133C(l, r):
    Min = np.inf
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = (i * j) % 2019
            if a < Min:
                Min = a
                if a == 0: # ここに注目
                    print(Min)
                    return
    print(Min)

l, r = map(int, input().split())
ABC133C(l, r)


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N,0);
  int max;
  int64_t ans=0;
  cin >> v.at(0);
  max = v.at(0);
  for(int i=1; i<N; i++){
    cin >> v.at(i);
    if(max <= v.at(i)){
      max = v.at(i);
    }else{
      ans += max - v.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4000
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = ["0"] * n
        for c in C:
            s[c - 1] = "1"

        c = "".join(s[::-1])
        ABC.append([a, b, int(c, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for a, b, c in ABC:
        for i in range(1 << n):
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

    if dp[-1] == f_inf:
        print(-1)
    else:
        print(dp[-1])


if __name__ == '__main__':
    resolve()


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

int h, w;
const int MOD = 1000000007;
int dp[1024][1024];
string a[1024];

int calc(int x, int y) {
    int &Y = dp[x][y];
    if(a[x][y] == '#') return 0;    
    if(Y != -1) return Y;
    if(x == 0 or y == 0) return Y = 0;
    if(x == 1 and y == 1) return Y = 1;
    return Y = (calc(x-1, y) + calc(x, y-1)) % MOD;
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> h >> w;
	for(int i=1; i<=h; ++i) {
	    cin >> a[i];
	    a[i] = ' ' + a[i];
	}
	cout << calc(h, w) << endl;
	return 0;
}

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

int main() {
	int i, y;
	double r, w, c, x;	
	while (1){
		i = 0;
		cin >> r >> w >> c >> x;
		if (r == 0 && w == 0 && c == 0 && x == 0){break;}
		y = r / (double)w;
		while(y != c){
			if (y > c) {
				w= w + 0.1;
			}else if (y < c) {
				r = r + x;
				i++;
			}
			y = r / (double)w;
		}
		cout << i << endl;
	}
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  int a;
  a = B /A;
  
  if (a > C){
    cout << C << endl;
  }
  else {
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    long long a,b,k,taka,ao;

    scanf("%lld %lld %lld",&a,&b,&k);

    taka=(a>k)? a-k:0;
    if(a>=k) ao=b;
    else if(a+b>=k) ao=a+b-k;
    else ao=0;

    printf("%lld %lld",taka,ao);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;

int32_t main() {
    fast();
    int a,b,k;
    cin >> a >> b >> k;
    if(k>=a){
        k-=a;
        a=0;
        
        if(k>=b){
            b=0;
        }
        else
            b-=k;
        cout<<a<<" "<<b;
    }
    else{
        a-=k;
        cout<<a<<" "<<b;
    }
    

}
 

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a

print(len(D))

Measured memory_bytes: 8092
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e7
typedef long long ll;
typedef long double ld;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> maze(h+2,vector<char> (w+2));
    vector<vector<int>> dist(h+2,vector<int> (w+2, INF));
    queue<pair<int,int>> que;
    REP(i,h+2)REP(j,w+2){
        if(i==0||j==0||i==h+1||j==w+1)continue;
        else{
            cin>>maze[i][j];
            if(maze[i][j]=='#'){
                que.push(make_pair(i,j));
                dist[i][j]=0;
            }
        }
    }
    vector<int> movel={1,-1,0,0}, movec={0,0,1,-1};
    while(!que.empty()){
        pair<int,int> p=que.front();
        int l=p.first, c=p.second;
        que.pop();
        REP(i,4){
            int nl=l+movel[i], nc=c+movec[i];
            if(maze[nl][nc]=='.'){
                maze[nl][nc]='#';
                dist[nl][nc]=dist[l][c]+1;
                que.push(make_pair(nl,nc));
            }
        }
    }
    int ans=0;
    FOR(i,1,h+1)FOR(j,1,w+1){
        if(ans<dist[i][j]){
            ans=dist[i][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16272
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

template <typename T>
T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

pair<Int, Int> tapu(Int a, Int b) {
	if (a == 0 && b != 0) { return { 0, 1 }; }
	if (a != 0 && b == 0) { return { 1, 0 }; }
	Int g = gcd(abs(a), abs(b));
	Int ag = abs(a) / g;
	Int bg = abs(b) / g;
	if ((a > 0 && b > 0) || (a < 0 && b < 0)) { return { ag, bg }; }
	else { return { -ag, bg }; }
};

int main() {
	constexpr Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	vector<Int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}

	map<pair<Int, Int>, Int> mp;
	Int zero = 0;
	for (int i = 0; i < N; ++i) {
		if (A[i] == 0 && B[i] == 0) {
			++zero;
			continue;
		}
		mp[tapu(A[i], B[i])] += 1;
	}

	Int ans = 1;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		if (it->second <= 0) { continue; }
		auto p = it->first;
		Int a = p.first, b = p.second;
		Int X = modpow(2, it->second, MOD);
		mp[{a, b}] = 0;
		Int Y = 0;
		if (a == 0 || b == 0) {
			Y = modpow(2, mp.count({b, a}) ? mp[{b, a}] : 0, MOD);
			mp[{b, a}] = 0;
		} else {
			Y = modpow(2, (mp.count({b, -a}) ? mp[{b, -a}] : 0), MOD);
			mp[{b, -a}] = 0;
		}
		(ans *= (X + Y - 1 + MOD) % MOD) %= MOD;
	}
	cout << (ans + zero - 1 + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 31448
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[200010];
int main() {
	int n; cin >> n;
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	sort(a, a + n + 1);
	a[n + 1] = -1;
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		int j = i;
		while (a[j + 1] == a[i])j++;
		ans += (ll)(j - i + 1)*(ll)(j - i) / 2;
		i = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
   ll  a,b,c;
  cin>>a>>b;
  for(ll i=0;i<a;i++)
  {
    cin>>c;
  }
  cout << ceil((a - 1) * 1. / (b - 1));
  
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static long n, ans;
  static long[] a, b, asum, bsum;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);

    br.close();

    ans = 0;
    for (long i = 1; i <= n; i++) {
      for (long j = i; j <= n; j += i) {
        ans += j;
      }
    }

    out.println(ans);

    out.flush();

  }
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        if(a!=c){
            cout<<"Yes";
            return 0;
        }else{
            cout<<"No";
            return 0;
        }
    }
    if(a==c){
        if(a!=b){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No";
            return 0;
        }
    }
    if(b==c){
        if(a!=c){
            cout<<"Yes";
            return 0;
        }else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []

for i in range(1,n):
  b.append(a[i] - a[i-1])
b.append(k - a[n-1] + a[0])
b = sorted(b)

print(sum(b[:-1]))


Measured memory_bytes: 32172
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
//typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    vector<int> a(n), less(n), mt(n,0);
    vector<bool>done(n,false);
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> a[i];
    bool ok = true;
    mt[0] = t[0];
    done[0]=done[n-1]=true;
    if(n==1){
        if(t[0]!=a[0]){
            ok=false;
        }
    }else{
        mt[n - 1] = a[n - 1];
    }
    FOR(i,1, n)
    {
        if (t[i] > t[i - 1])
        {
           
            mt[i] = t[i];
            done[i]=true;
        }
    }
    

    FOR(i,1, n)
    {
        int ite = n - 1 - i;
        if (a[ite] > a[ite + 1])
        {
            if (mt[ite] == 0 or mt[ite] == a[ite])
            {
                mt[ite] = a[ite];
                 
                done[ite]=true;
            }
            else
            {
                ok = false;
            }
        }
    }
    rep(i,n){
        if(mt[i]>t[i] or mt[i]>a[i]){
            ok=false;
        }
    }
    rep(i, n)
    {
        less[i] = min(t[i], a[i]);
    }
    ll ans = 1;
    rep(i, n)
    {
        if (done[i])
        {

        }
        else
        {
           //cout << i << " " << less[i] << endl;
            ans *=(ll) less[i];
            ans %= M;
        }
    }
    if (ok)
    {
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1792
import java.math.*;
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long D = sc.nextLong();
    long A = sc.nextLong();
    long[][] XH = new long[N][2];
    for (int i = 0; i < N; i++) {
      XH[i][0] = sc.nextLong();
      XH[i][1] = sc.nextLong();
    }
    sc.close();

    Arrays.sort(XH, (a, b) -> Long.compare(a[0], b[0]));
    Queue<long[]> q = new ArrayDeque<>();
    long d2 = D * 2;
    long d = 0;
    long ans = 0;
    for (int i = 0; i < N; i++) {
      long hi = XH[i][1];
      if (hi <= 0) continue;

      long xi = XH[i][0];
      while (!q.isEmpty() && q.peek()[0] < xi) {
        d -= q.poll()[1];
      }
      hi -= d;
      XH[i][1] = Math.max(0, hi);
      if (hi <= 0) continue;

      long c = (hi + A - 1) / A;
      long ac = A * c;
      ans += c;
      hi -= ac;
      d += ac;
      q.add(new long[] {xi + d2, ac});
      XH[i][1] = Math.max(0, hi);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 126920
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0||c>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
        a=a-d;
        if(a<=0)
        {
            
            cout<<"No";
            break;
        }
     }
}

Measured memory_bytes: 3636
def sum(x):
    a=int(x//3)
    b=int(x//5)
    c=int(x//15)
    sall=int((1+x)*(x/2))
    #print(sall)
    s3=int((3*(a-1)+6)*(a/2))
    #print(s3)
    s5=int((5*(b-1)+10)*(b/2))
    #print(s5)
    s15=int((15*(c-1)+30)*(c/2))
    #print(s15)
    ans=int(s15-s3-s5+sall)
    print(ans)
n=int(input())
sum(n)

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

// @@ !! LIM(dinic)
// --> dinic
// ---- inserted library file dinic.cc

struct Edge {
  int dst;
  ll cap;
  int rev;
  Edge(int d, ll c, int r) : dst(d), cap(c), rev(r) {}
};

class Dinic {

  int vSize;
  int source;
  int sink;
  vector<int> level;  // from sink rather than source
  vector<size_t> iter;
  vector<vector<Edge>> edges;

  ll dfs(int u, ll sCap) {
    if (u == sink) return sCap;
    ll f = 0;
    for (size_t& i = iter.at(u); i < edges.at(u).size(); i++) {
      Edge& e = edges.at(u).at(i);
      if (e.cap == 0 || level.at(e.dst) >= level.at(u)) continue;
      ll f0 = dfs(e.dst, min(sCap - f, e.cap));
      e.cap -= f0;
      edges.at(e.dst).at(e.rev).cap += f0;
      f += f0;
      if (f == sCap) break;
    }
    return f;
  }

  void set_level() {
    level.assign(vSize, -1);
    deque<pair<int,int>> deq;
    deq.emplace_back(sink, 0);
    while (!deq.empty()) {
      pair<int,int> p = deq.front(); deq.pop_front();
      int i = p.first;
      int lev = p.second;
      if (level.at(i) >= 0) continue;
      level.at(i) = lev;
      for (const Edge& erev : edges.at(i)) {
	const Edge& e = edges.at(erev.dst).at(erev.rev);
	if (e.cap == 0) continue;
	deq.emplace_back(erev.dst, lev + 1);
      }
    }
  }

public:

  Dinic(int sz, int src, int snk)
    : vSize(sz), source(src), sink(snk), edges(sz) {}

  void add_edge(int u, int v, ll cap) {
    assert(0 <= u && u < vSize && 0 <= v && v < vSize);
    assert(cap > 0);
    int nu = edges.at(u).size();
    int nv = edges.at(v).size();
    edges.at(u).push_back(Edge(v, cap, nv));
    edges.at(v).push_back(Edge(u, 0,   nu));
  }

  ll run() {
    ll flow = 0;
    while(1) {
      set_level();
      if (level.at(source) == -1) break;
      iter.assign(vSize, 0);
      flow += dfs(source, LLONG_MAX);
    }
    return flow;
  }
};
// ---- end dinic.cc
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N), C(N), D(N);
  for (ll i = 0; i < N; i++) cin >> A[i] >> B[i];
  for (ll i = 0; i < N; i++) cin >> C[i] >> D[i];

  ll source = 2 * N;
  ll sink = 2 * N + 1;
  Dinic dinic(2*N + 2, source, sink);
  for (ll i = 0; i < N; i++) {
    dinic.add_edge(source, i, 1);
    dinic.add_edge(N + i, sink, 1);
  }
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (A[i] < C[j] && B[i] < D[j]) dinic.add_edge(i, N + j, 1);
    }
  }
  ll flow = dinic.run();
  cout << flow << endl;

  return 0;
}



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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N, K;
ll dp[3001][3001];
ll a[3001];

signed main() {
    cin >> N;
    REP(i, N) cin >> a[i];
    REPR(i,N-1) {
	    FOR(j,i,N){
	        if ((N-i-j-1)%2==0){
	            dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
	        }else{
	            dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
	        }
	    }
	}
    cout <<dp[0][N-1] << "\n";
}


Measured memory_bytes: 70016
#include <iostream>
using namespace std;
int main(void){
    int l, cnt=1, a[10];
    while(cin>>l){
        a[cnt] = l;
        //cout << a[i] << " cnt "<< i<< endl;
        cnt++;
        if(cnt>4){
            cnt=0;
            break;
        }
    }  
    //cout << "owari" << endl;

    for(int i=0;i<=a[1];i++){
        for(int j=0;j<=a[2];j++){
            for(int k=0;k<=a[3];k++){
                if(a[4] == 500*i + 100*j + 50*k){
                    cnt++;
                }
            }

        }
    }
 

    cout << cnt << endl;


}

Measured memory_bytes: 256
from collections import deque

def main():
    s = input()
    t = s.replace('x', '')
    if t != ''.join(list(reversed(t))):
        print(-1)
        return
    if len(s) == 1:
        print(0)
        return
    
    que = deque(s)
    gnr = []
    l = que.popleft()
    r = que.pop()
    tmp = '0'
    cnt = 0
    for _ in range(len(s)):
        if l == r:
            gnr.append(l)
            if len(que)>=2:
                l = que.popleft()
                r = que.pop()
            elif len(que) == 1:
                tmp = que.pop()
            else:
                break
        else:
            if l == 'x':
                cnt += 1
                gnr.append(l)
                if len(que) == 0:
                    tmp = r
                    break
                l = que.popleft()
            elif r == 'x':
                cnt += 1
                gnr.append(r)
                if len(que) == 0:
                    tmp = l
                    break
                r = que.pop()
            else:
                print(-1)
                return
    rgnr = gnr
    rgnr.reverse()
    if tmp == '0':
        ans = ''.join(gnr) + ''.join(rgnr)
    else:
        ans = ''.join(gnr) + tmp + ''.join(rgnr)
    #print(ans)
    print(cnt)

if __name__ == "__main__":
    main()


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

int main(){
      int n;cin >> n;
      int sum = 0;
      int maxx = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            if(t > maxx)maxx = t;
            sum += t;
      }
      cout << sum - (maxx / 2);
}

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

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  cout << ((n-1)/x+1)*t;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef long long ll;

int main()
{
	ll n;
    while ( ~scanf("%lld", &n) ) {
		ll sum = 1;
		for(int i =1; i <= n; i++){
			sum = sum *i;
			sum = sum % 1000000007;
		}
		printf("%lld\n",sum);
    }
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   string S1, S2;
   cin >> S1;
   cin >> S2;
   bool flg[N][2];
   memset(flg, false, sizeof(flg));
   ll ans = 1;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < 2; j++) {
         if (flg[i][j]) continue;
         if (j == 0) {
            if (S1[i] == S2[i]) {
               if (i == 0) mul(ans, 3);
               else if (S1[i - 1] == S2[i - 1]) mul(ans, 2);
               else mul(ans, 1);
               flg[i][j] = true;
               flg[i][j + 1] = true;
            } else {
               if (i == 0) mul(ans, 6);
               else if (S1[i - 1] == S2[i - 1]) mul(ans, 2);
               else mul(ans, 3);
               flg[i][j] = true;
               flg[i + 1][j] = true;
               flg[i][j + 1] = true;
               flg[i + 1][j + 1] = true;
            }
         } else {
            if (i == 0) mul(ans, 2);
            else if (S1[i] == S2[i - 1]) mul(ans, 2);
            else mul(ans, 1);
            flg[i][j] = true;
            flg[i + 1][j] = true;
         }
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

bool isprime(ll x){
    for(ll i=2; i*i<=x; ++i) if(x%i==0) return false;
    return true;
}

ll gcd(ll a, ll b){
    if(a<b) swap(a, b);
    while(b!=0){
        ll t=a;
        a=b;
        b=t%b;
    }
    return a;
}

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

    ll a, b; cin >> a >> b;
    ll g=gcd(a, b);

    ll ans=1;
    for(ll i=2; i*i<=g; ++i){
        if(g%i==0){
            ++ans;
            while(g%i==0) g/=i;
        }
    }
    if(g!=1) ++ans;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 2e9
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;

class mint
{
  const ll mod = 998244353;
  ll x;

public:
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint &a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint &a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint &a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint &a) const
  {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &m)
  {
    os << m.x;
    return os;
  }
};

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

  if (m == 1)
  {
    if (n == k + 1)
      cout << 1 << endl;
    else
      cout << 0 << endl;

    return 0;
  }

  mint x = mint(m) * mint(m - 1).pow(n - 1);
  mint ans = x;
  FOR(i, 1, k)
  {
    x *= (mint(n) - i) / (mint(m - 1) * i);
    ans += x;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main{

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

	 int a=sc.nextInt();
	 int b=sc.nextInt();
	 int c=sc.nextInt();
	 int d=sc.nextInt();

	 if((Math.abs(a-b)<=d && Math.abs(b-c)<=d) || Math.abs(a-c)<=d){
		 System.out.println("Yes");
	 }else{
		 System.out.println("No");
	 }



	}
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x; cin >> x;
	if(x<1200)cout << "ABC";
	else if(x<2800)cout << "ARC";
	else cout << "AGC";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
N, M = map(int, input().split())

to = [[] for _ in range(N)]
dist = [[0 for _ in range(3)] for _ in range(100005)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  to[a].append(b)

sv, tv = map(int, input().split())
sv -= 1
tv -= 1

for i in range(N):
  for j in range(3):
    dist[i][j] = float("inf")
q = [[sv, 0]]
dist[sv][0] = 0
while len(q) != 0:
  v = q[0][0]
  l = q[0][1]
  q.pop(0)
  for u in to[v]:
    nl = (l + 1) % 3
    if dist[u][nl] != float("inf"):
      continue
    dist[u][nl] = dist[v][l] + 1
    q.append([u, nl])
ans = dist[tv][0]
if ans == float("inf"):
  ans = -1
else:
  ans //= 3
print(ans)

Measured memory_bytes: 43264
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;



int N;
LL K;
LL A[1234];
LL R[1234];

bool ok(LL x) {
	for (int i = 0; i < N; ++i) {
		R[i] = A[i] % x;
	}
	LL wrap = 0;
	for (int i = 0; i < N; ++i) {
		wrap += R[i];
	}
	wrap /= x;
	sort(R, R + N);
	for (int i = N - 1; i >= 0; --i) {
		if (wrap > 0) {
			wrap--;
			R[i] -= x;
		}
	}
	LL can = 0;
	for (int i = 0; i < N; ++i) {
		can += max(0LL, R[i]);
	}
	return can <= K;
}

int main() {
	cin >> N >> K;
	LL total = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		total += A[i];
	}
	set<LL>yak;
	for (LL i = 1; i * i <= total; ++i) {
		if (total % i == 0) {
			yak.insert(i);
			yak.insert(total / i);
		}
	}
	LL ans = 1;
	for (LL y : yak) {
		if (ok(y)) {
			ans = max(ans, y);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int G[n][n] = {};
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = 1; G[b][a] = 1;
    }

    vector<int> A;
    for(int i = 1; i < n; i++){
        A.push_back(i);
    }
    
    int cnt = 0;
    do{
        int s = 0, e, p = 1;   //start, end, product
        for(int i = 0; i < A.size(); i++){
            e = A[i];
            p *= G[s][e];
            if(p){
                s = e;
            }
            else break;
        }
        if(p) cnt++;
    }while(next_permutation(A.begin(), A.end()));

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long ll;

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

    int N, K;
    cin >> N >> K;

    vector<int> ps(N);
    rep(i, N) cin >> ps[i];

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

    int sum = 0;
    rep(i, K) sum += ps[i];

    cout << sum << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    string S;
    ll A,B,C,D;
    cin >> S;
    A = S[0] - '0';
    B = S[1] - '0';
    C = S[2] - '0';
    D = S[3] - '0';

    char ope1,ope2,ope3;

    REP (i,8) {
             if (A + B + C + D == 7) { ope1 = '+'; ope2 = '+'; ope3 = '+'; } 
        else if (A - B + C + D == 7) { ope1 = '-'; ope2 = '+'; ope3 = '+'; }
        else if (A + B - C + D == 7) { ope1 = '+'; ope2 = '-'; ope3 = '+'; }
        else if (A - B - C + D == 7) { ope1 = '-'; ope2 = '-'; ope3 = '+'; }
        else if (A + B + C - D == 7) { ope1 = '+'; ope2 = '+'; ope3 = '-'; }
        else if (A - B + C - D == 7) { ope1 = '-'; ope2 = '+'; ope3 = '-'; }
        else if (A + B - C - D == 7) { ope1 = '+'; ope2 = '-'; ope3 = '-'; }
        else if (A - B - C - D == 7) { ope1 = '-'; ope2 = '-'; ope3 = '-'; }
        else { cout << "error" << endl;}
    }

    cout << A << ope1 << B << ope2 << C << ope3 << D << "=7" << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
 int main()
 {
 	int a,b,c,sum=0;
 	int n,m;
 	scanf("%d",&a);
 	b=a;
 	if(a==0){
 		printf("NO");
 		goto out;
	 }
 	while(a>0){
 		c=a%10;
 		sum=sum+c;
 		a=a/10;
	 }
	 if(b%sum==0){
	 	printf("Yes");
	 }
	 else{
	 	printf("No");
	 }
	 out:
	 return 0;
  } 

Measured memory_bytes: 128
// AOJ GRL_1_A 

#include<bits/stdc++.h>
#include <algorithm>
#include <vector>


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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;
const int int_INF = 100100100;
int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


struct edge{int from, to,cost;};

int MAX_N=1000; //edge
int MAX_M=2000; // node
// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

vec<edge> es(MAX_M); //辺
vec<ll> d(MAX_N,INF); // 各点への最短距離
int V,E; //Vは頂点数,Eは辺数
vec<bool> negative(MAX_N,false);

int N,M,s;

void shortest_path(int s){
    for(int i=0;i<N;i++) d[i]=INF;
    d[s]=0;
    for(int loop=0;loop<N-1;++loop){ //任意の頂点にたどり着くのに、
        for(int i=0;i<M;++i){
            edge e=es[i];
            if(d[e.from]!=INF && d[e.to] > d[e.from]+e.cost){
                // cout<<d[e.from]<<" > "<<d[e.from]<<"+"<<e.cost<<endl;
                d[e.to]=d[e.from]+e.cost;
            }
        }
        
    }
}

void find_negative_loop(int s){
    for(int i=0;i<N;i++) negative[i]=false;
    d[s]=0;
    for(int loop=0;loop<N;++loop){
        for(int i=0;i<M;++i){
            edge e=es[i];
            
            if(d[e.from]!=INF && d[e.to] > d[e.from]+e.cost){
                
                d[e.to]=d[e.from]+e.cost;
                negative[e.to]=true;
            }
            if(negative[e.from]==true){
                negative[e.to]=true;
            }
        }
        
    }
}


int main()
{
    
    cin>>N>>M;
    rep(i,M){
        cin>>es[i].from>>es[i].to>>es[i].cost;
        es[i].from--; //頂点番号を0-indexに
        es[i].to--;
        es[i].cost*=-1;
    }
    shortest_path(s);
    ll ans=d[N-1];
    find_negative_loop(s);




    if(negative[N-1]){
        cout<<"inf"<<endl;
    }else{
        cout<<-ans<<endl;
    }
    

    return 0;

}




Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> al = new ArrayList<>();
		
		int d;
		while(sc.hasNext()) {
			d = sc.nextInt();
			int ans = 0;
			
			for(int i = d; i < 600; i += d) {
				ans += i * i * d;
			}
			
			al.add(ans);
		}
		
		for(int i : al) {
			System.out.println(i);
		}
	}
}

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



int main() 
{
  ll N; cin>>N;
  vector<tuple<string,ll,ll>> mise(N);
  rep(i,N)
  {
    get<2>(mise.at(i))=i;
    cin>>get<0>(mise.at(i))>>get<1>(mise.at(i));
    get<1>(mise.at(i))=100-get<1>(mise.at(i));
  }
  sort(mise.begin(),mise.end());
  rep(i,N)
  {
    cout<<get<2>(mise.at(i))+1<<endl;
  }  
  return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] >= 0) ans += v[i] - c[i];
  }
  cout << ans << endl;
}


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

long long a, b;
int q;

inline long long sq( long long x )
{
    int l = 1, r = 1000000009;
    while( r - l > 1 )
    {
        long long m = ( l + r ) >> 1;
        if( m * m <= x )
            l = m;
        else
            r = m;
    }
    if( r * 1ll * r <= x )
        return r;
    return l;
}

main()
{
    cin >> q;
    while( q-- )
    {
        scanf( "%d%d", &a, &b );
        long long c = a * b;
        c--;
        if( a > b )
            swap( a, b );
        long long d = sq( c );
        long long ans = d * 2;

        if( d >= a )
            ans--;
        if( d >= b )
            ans--;
        if( d == c / d )
            ans--;
        cout << ans << endl;

    }
}


Measured memory_bytes: 256
#include<stdio.h>

int bubbleSort(int ,int *);

int main(){
    int n,cnt;
    scanf("%d",&n);
    int i,h[n];
    for(i=0;i<n;i++)scanf("%d",&h[i]);
    cnt=bubbleSort(n,&h[0]);
    for(i=0;i<n;i++){
        if(i!=n-1)printf("%d ",h[i]);
        else printf("%d\n",h[i]);
    }
    printf("%d\n",cnt);
    return 0;
}

int bubbleSort(int n,int *A){
  int i,cnt=0,j;
  for(i=0;i<n-1;i++){
        for (j=n-1;j>=i+1;j--){
            if (A[j] < A[j-1]){
                int tmp = A[j];
                A[j]=A[j-1];
                A[j-1]=tmp;
                cnt++;
            }
        }
    }
    return cnt;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)


int main() {
    int M = 1e9;
    int n,x;
    cin >> n >> x;
    int sum = 0;
    rep(i,0,n - 1){
        int a;
        cin >> a;
        M = min(M,a);
        sum += a;
    }

    x -= sum;

    cout << n + x / M << endl;


}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      String work = scanner.nextLine();
      if (work.equals("0")) {
        break;
      }
      String works[] = work.split(" ");
      int s = 0;
      int oc = 0;
      for (int ii = 0; ii < works.length; ii++) {
        int w = Integer.parseInt(works[ii]);
        if (2 <= w && w <= 9) {
          s += w;
        } else if (10 <= w && w <= 13) {
          s += 10;
        } else {
          oc++;
        }
      }
      s += oc;
      for (int ii = 0; ii < oc; ii++) {
        if (s + 10 <= 21) {
          s += 10;
          break;
        }
      }

      if (s > 21) {
        s = 0;
      }

      System.out.println(s);
    }
  }
}

Measured memory_bytes: 19308
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>int LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>int UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int i,n;cin>>n;
	static llint a[1<<20]={};
	static llint ni[100001]={};
	ni[0]=1;
	for(i=0;i<n;i++){ni[i+1]=ni[i]*2%mod;}
	while(n--){
		int x;cin>>x;
		a[x]++;
	}
	for(i=0;i<20;i++){
		for(int bi=0;bi<(1<<20);bi++){
			if(bi&(1<<i)){continue;}
			a[bi]+=a[bi+(1<<i)];
		}
	}
	llint ans=0;
	
	for(int bi=0;bi<(1<<20);bi++){
		int fu=1;
		for(i=0;i<20;i++){if(bi&(1<<i)){fu*=-1;}}
		ans+=fu*ni[a[bi]];ans%=mod;
		//if(bi<16){cerr<<ni[a[bi]]<<endl;}
	}
	ans+=mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}
/*
3
0 1 2
3 1 1 0
+ - - +
8-2-2+1 =5
*/


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

int main()
{
  long N; cin >> N;
  
  long root_N = pow(N, 0.5);
  
  int F = 20;
  
  for (long A = 1; A <= root_N; A++)
  {
    long B = N / A;
    
    if (A * B == N)
    {
      // cout << "(" << A << ", " << B << "), ";
      string As = to_string(A), Bs = to_string(B);
      int digits = max(As.length(), Bs.length());
      F = min(F, digits);
    }
  }
  
  cout << F << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int n,x[100010],y[100010];
vector<P> vec, vec2;
vector<P> g[100010];

int main(){
	cin >> n;
	REP(i,0,n){
		int a, b; cin >> a >> b;
		vec.push_back({a, i});
		vec2.push_back({b, i});
	}
	sort(vec.begin(), vec.end());
	sort(vec2.begin(), vec2.end());
	
	
	REP(i,0,n - 1){
		g[vec[i].second].push_back({vec[i + 1].second, abs(vec[i + 1].first - vec[i].first)});
		g[vec[i + 1].second].push_back({vec[i].second, abs(vec[i + 1].first - vec[i].first)});
		g[vec2[i].second].push_back({vec2[i + 1].second, abs(vec2[i + 1].first - vec2[i].first)});
		g[vec2[i + 1].second].push_back({vec2[i].second, abs(vec2[i + 1].first - vec2[i].first)});
	}
	
	ll total = 0;
	bool used[100010] = {};
	pq<P, vector<P>, greater<P>> qu; qu.push({0, 0});
	while(!qu.empty()){
		auto p = qu.top(); qu.pop();
		
		if(used[p.second]) continue; used[p.second] = true;
		total += p.first;
		for(auto e:g[p.second]) qu.push({e.second, e.first});
	}
	
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 11628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> 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>
using namespace std;
typedef long long ll;
double eps=1.0e-9;

int main() {
  ll W,H,x,y;
  cin >> W >> H >> x >> y;
  
  cout << setprecision(9) << W*H*0.5 << " ";
  
  if( abs(x-W*0.5) < eps && abs(y-H*0.5) < eps){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
  
  return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		int n = Integer.parseInt(sc.nextLine());

		for(int i=0;i<n;i++){
			String s=sc.nextLine();
			int num=Integer.parseInt(s);
			double numDouble=Double.parseDouble(s);
			int divor=Math.round(Math.round(Math.sqrt(numDouble)))+1;
			boolean f=true;
			for(int j=2;j<divor;j++){
				if(num%j==0){
					f=false;
					break;
				}
			}
			if(f){
				count++;
			}
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 64376