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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


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

  cout << (n == 0 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br ;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int h = ob.nextInt();
		int a = ob.nextInt();
		int ans = (h/a) + Math.min(1, h%a);
		System.out.println(ans);
				
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q;
int main(){
	string str;int k;
	while(1){
		cin>>str;
		if(str=="end")break;
		if(str=="insert"){
		 	cin>>k; q.push(k);
		}
		if(str=="extract"){
			printf("%d\n",q.top());
			q.pop();
		} 
	}
} 


Measured memory_bytes: 7052
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            if (in.nextInt() == 1) {
                out.println("Hello World");
            } else {
                int A = in.nextInt();
                int B = in.nextInt();
                out.println(A + B);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include<deque>
#include<ext/rope>
#define ll long long
#define ld long double
#define ull unsigned long long
#define sc(x) scanf("%d",&x)
using namespace std;
using namespace __gnu_cxx;
const int N = 1e6 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ld pi = acos(-1.0);
int t,n,m,l,r,x,Case;
char mp[1003][1003];
int sx,sy,ex,ey,type[1003][1003];
bool vis[1003][1003];
struct node {
    int x,y,z;
};
deque<node>q;
void dfs(node now){
    int x,y,z;
    x=now.x;y=now.y;z=now.z;
    if(y+1<m&&mp[x][y+1]=='.')q.push_front({x,y+1,z});
    if(x+1<n&&mp[x+1][y]=='.')q.push_front({x+1,y,z});
    if(y-1>=0&&mp[x][y-1]=='.')q.push_front({x,y-1,z});
    if(x-1>=0&&mp[x-1][y]=='.')q.push_front({x-1,y,z});
    for(int i=now.x-2;i<=now.x+2;i++)
        for(int j=now.y-2;j<=now.y+2;j++)
            if(i>=0&&j>=0&&i<n&&j<m&&mp[i][j]=='.')q.push_back({i,j,now.z+1});
 
}
 
void run(){
    cin>>n>>m;
    cin>>sx>>sy;
    cin>>ex>>ey;
    sx--;
    sy--;
    ex--;
    ey--;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>mp[i][j],type[i][j]=inf;
    q.push_back((node){sx,sy,0});
    node now;
    while(q.size()){
        now=q.front();q.pop_front();
        if(vis[now.x][now.y])continue;
        vis[now.x][now.y]=1;
        type[now.x][now.y]=min(now.z,type[now.x][now.y]);
        dfs(now);
    }
    if(type[ex][ey]==inf)cout<<-1<<'\n';
    else cout<<type[ex][ey]<<'\n';
}
int main(){
#ifdef haosao
#endif
    ios::sync_with_stdio(false);
        run();
    return 0;
}

Measured memory_bytes: 10912
import numpy as np

X, N = list(map(int, input().split()))  
p_list = list(map(int, input().split()))

num_list = list(set([*range(0,102)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])

Measured memory_bytes: 26924
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << "{";
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i] << ",}"[i == vec.size() - 1];
  }
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << "{" << p.first << " " << p.second << "}";
}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

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

  int n; cin >> n;
  int64 dis[n][n], a[n][n];

  rep(i, n) {
    rep(j, n) {
      if (i == j) {
        dis[i][j] = 0;
      } else {
        dis[i][j] = INF64;
      }
    }
  }

  rep(i, n) {
    rep(j, n) {
      cin >> dis[i][j];
      a[i][j] = dis[i][j];
    }
  }

  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  rep(i, n) {
    rep(j, n) {
      if (dis[i][j] != a[i][j]) {
        cout << -1 << '\n';
        return 0;
      }
    }
  }

  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        if (k == j || k == i) continue;
        if (dis[i][k] + dis[k][j] == dis[i][j]) {
          a[i][j] = 0;
        }
      }
    }
  }

  int64 ans = 0;
  rep(i, n) {
    rep(j, n) {
      ans += a[i][j];
    }
  }

  cout << ans / 2 << '\n';

  return 0;
}

Measured memory_bytes: 1664
n,m = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(m)]

l_max, r_min = 1, 10**5
for di in d:
    l_max = max(l_max, di[0])
    r_min = min(r_min, di[1])

if r_min >= l_max:
    print(r_min - l_max + 1)
else:
    print(0)


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

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    std::vector<int> cnt(n, 0);
    while (m--) {
        int y;
        std::cin >> y;
        for (int i = 0; i < n; ++i) {
            if (xs[i] <= y) {
                ++cnt[i];
                break;
            }
        }
    }

    std::cout << std::max_element(cnt.begin(), cnt.end()) - cnt.begin() + 1
              << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  bool A = 0;
  if(a+b==c||a+c==b||b+c==a)A=1;
 if(A)
  cout << "Yes" <<endl;
  else{
  cout << "No" <<endl;}
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

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

    string A[N], B[M];

    for (int i = 0; i < N; ++i)
        cin >> A[i];

    for (int i = 0; i < M; ++i)
        cin >> B[i];

    for (int i = 0; i < N - M + 1; ++i)
        for (int j = 0; j < N - M + 1; ++j)
        {
            for (int k = 0; k < M; ++k)
                for (int l = 0; l < M; ++l)
                    if (A[i + k][j + l] != B[k][l])
                        goto NEXT;

            cout << "Yes\n";
            return 0;
        NEXT:;
        }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m; 
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
	//freopen("1.in","r",stdin);
	cin>>n>>m;
	cout<<(n-1)*n/2+(m-1)*m/2<<endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c = sorted(list(map(int, input().split())))
# 同じ数が2つできるまで、小さい2つの数に１を足す
ans=0
if b!=c:
    b+=ans
    ans+=c-b
a+=ans
q,r = divmod(c-a, 2)
ans+=q
if r>0:
    ans+=2
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> idx(n);
  rep(i,n) idx[a[i]] = i;
  set<int> s;
  ll ans = 0;
  for (int x = n-1; x >= 0; --x) {
    int i = idx[x];
    ll c = 0;
    { // calc c
      s.insert(i);
      vector<int> l(2,-1);
      vector<int> r(2,n);
      { // calc l
        auto it = s.find(i);
        rep(j,2) {
          if (it == s.begin()) break;
          --it;
          l[j] = *it;
        }
      }
      { // calc r
        auto it = s.find(i);
        rep(j,2) {
          ++it;
          if (it == s.end()) break;
          r[j] = *it;
        }
      }
      vector<int> ls(2);
      ls[0] = i-l[0]; ls[1] = l[0]-l[1];
      vector<int> rs(2);
      rs[0] = r[0]-i; rs[1] = r[1]-r[0];
      c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
    }
    ans += c*(x+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
A = np.array([rl() for _ in range(N)])
answer = 300
for _ in range(M):
    counter = np.bincount(A[:, 0])
    i = np.argmax(counter)
    x = counter[i]
    if x < answer:
        answer = x
    A = A[A != i].reshape(N, -1)

print(answer)


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

using namespace std;
#define d getchar()


int main() {

	int n;

	cin >> n;

	vector<string> output;
	vector<string> s(n);
	map<string, int> count;
	int max_count = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];

		count[s[i]]++;
	}

	auto begin = count.begin(), end = count.end();
	for (auto iter = begin; iter != end; iter++) {
		// first: key, second: value
		if (max_count < iter->second)
			max_count = iter->second;
	}

	for (auto iter = begin; iter != end; iter++) {
		// first: key, second: value
		if (iter->second == max_count)
			output.push_back(iter->first);
	}

	sort(output.begin(), output.end());
	
	for (auto a : output) {
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 28404
import sys
from collections import defaultdict

n, *a = map(int, sys.stdin.read().split())

def main():
    res = defaultdict(int)
    for i in a:
        res[i-1] += 1
        res[i] += 1
        res[i+1] += 1

    return max(res.values()) 
    
if __name__ == '__main__':
    ans = main()
    print(ans)

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5 + 5;
const int inf = 1e9 + 5;

int dp[N], a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        dp[i] = inf;
    }
    dp[1] = 0;
    for (int i=2; i<=n; i++) {
        for (int j=i-1; j>=max(1, i-k); j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	auto f = [&]() {
		return A <= C && C <= B;
	};
	if (f()) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
}

Measured memory_bytes: 256
U = 10**6+2
MOD = 10**6+3
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def perm(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
q = int(input())
for _ in range(q):
  x, d, n = map(int, input().split())
  if d == 0:
    ans = pow(x, n, MOD)
  else:
    invd = pow(d, MOD-2, MOD)
    y = x * invd % MOD
    if y == 0 or y > y+n-1:
      ans = 0
    else:
      g = pow(d, n, MOD)
      ans = perm((y+n-1)%MOD, n)*g % MOD
  print(ans)

Measured memory_bytes: 67932
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>
 
using namespace std;

const int MAXN = 100005;

int n;
int a[MAXN];
int b[MAXN];

int main()
{
	scanf("%d",&n);
	bool allzero = 1;
	for (int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		allzero &= !a[i];
	}
	if (allzero)
		puts("Yes");
	else if (n % 3 != 0)
		puts("No");
	else
	{
		sort(a + 1,a + n + 1);
		int N = n;
		memcpy(b,a,sizeof(b));
		n = unique(a + 1,a + n + 1) - a - 1;
		if (n != 3 && n != 2)
			puts("No");
		else if (n == 2)
		{
			int cnt[3] = {0};
			for (int i = 1;i <= N;i++)
				for (int j = 1;j <= 2;j++)
					if (b[i] == a[j])
						cnt[j]++;
			if (a[1])
				puts("No");
			else if (cnt[2] != cnt[1] * 2)
				puts("No");
			else
				puts("Yes");
		}
		else
		{
			int cnt[4] = {0};
			for (int i = 1;i <= N;i++)
				for (int j = 1;j <= 3;j++)
					if (b[i] == a[j])
						cnt[j]++;
			if (a[1] ^ a[2] ^ a[3])
				puts("No");
			else if (cnt[1] != cnt[2] || cnt[2] != cnt[3] || cnt[1] != cnt[3])
				puts("No");
			else
				puts("Yes");
		}
	}
	return 0;
}


Measured memory_bytes: 1024
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
  var low=0,high=0;
  low = input[1]-input[0]+1;
  high = input[1]+input[0]-1;
  var arr =[];
  for(var i=low;i<=high;i++){
  arr.push(i);
  }
  console.log(arr.join(" "));
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (S == "Rainy") {
        cout << "Sunny" << endl;
    } 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

void solve()
{
    int r;
    cin >> r;
    long double circumference;

    circumference = 2 * (M_PI)*r;
    cout << circumference << "";
}

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

    //int t;
    //cin >> t;

    // while (t--)
    solve();

    return 0;
}

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

int solve(long long N, std::vector<long long> A)
{
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
            {
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define make_unique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define dbg(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;

void solve(){
    int a, b, h, m; cin >> a >> b >> h >> m;
    int time = 60*h+m;
    long double pi = 3.1415926535897932384626433832795028841971;
    long double ang1 = (time%720)*pi/360.0;
    long double ang2 = ((time*6)%360) * pi/180.0;
    long double ans = sqrt(a*a+b*b-2*a*b*cos(ang1-ang2));
    cout << setprecision(40) << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4184
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<int> monsters(n+1);
    vector<int> b(n);
    for(int i = 0; i < n+1; i++) cin >> monsters[i];
    for(int i = 0; i < n;i++) cin >> b[i];
    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(b[i] == 0) continue;
        if(monsters[i] <= b[i]){
            ans += monsters[i];
            b[i] -= monsters[i];
            monsters[i] = 0;
        }else{
            ans += b[i];
            b[i] = 0;
            continue;
        }
//        cout << "ans = " << ans << " monsters[i+1] = " << monsters[i+1] << endl;
        if(monsters[i+1] <= b[i]){
            ans += monsters[i+1];
            b[i] -= monsters[i+1];
            monsters[i+1] = 0;
        }else{
            ans += b[i];
            monsters[i+1] -= b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int n,l;
    cin >> n >> l;
    int aji[n];
    for(int i=0;i<n;i++){
        aji[i] = l + i;
    }

    int min = 999999;
    for(int i=0;i<n;i++){
        if(min > abs(aji[i])){
            min = abs(aji[i]);
        }
    }

    int sum = 0;
    for(int i=0;i<n;i++){
        sum += aji[i];
    }

    if(sum > 0){
        cout << sum - min << endl;
    }else{
        cout << sum + min << endl;
    }
}

// -50 -49 --- -21

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int P_MAX = 100101;
	vector<bool> primes(P_MAX,true);
	primes[1] = false;
	for(int i = 2; i<=P_MAX; ++i){
		if(primes[i]){
			for(int k = 2; i*k<=P_MAX; ++k){
				primes[i*k] = false;
			}
		}
	}

	int x; cin>>x;
	while(true){
		if(primes[x]){cout<<x<<endl; return 0;}
		++x;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N, M, L,Ltemp, R, Rtemp, count=0;
    cin >> N >> M;
    L=0; R=N;
    for(int i=0; i<M; i++){
        cin >> Ltemp >> Rtemp;
        if(Ltemp > L){
            L = Ltemp;
        }
        if(Rtemp < R){
            R = Rtemp;
        }
    }
    for (int i=0; i<N; i++){
        if ((L <=  (i+1))&&((i+1) <= R)){
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int d=0,e=0,f=0,g=0;
    for(;;){
       int a,b,c;
       cin>>a>>b>>c;
       if(a+b>c&&a+c>b&&b+c>a){
         if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
           e++;
         }
         else if(a*a+b*b<c*c||a*a+c*c<b*b||b*b+c*c<a*a){
                f++;
         }
         else{
             g++;
         }
         d++;
       }
       else{break;}
    }
    cout<<d<<" "<<e<<" "<<g<<" "<<f<<endl;
    return 0;
}


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

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

	std::vector<int> v( N );

	for ( int i = 0; i < N; i++ )
	{
		std::cin >> v[i];
	}

	// あるXについて、余りの最大値は、X-1である
	long total = 0;
	for ( auto &&it : v )
	{
		total += it - 1;	//	つまり、最大値を全部合計すれば良い
	}

	std::cout << total << std::endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;


int main()
{
	int h,w;
	cin>>h>>w;
	vector<vector<char>> field(h);
	for(int i = 0; i < h; i++){
		field[i] = vector<char>(w);
		for(int j = 0; j < w; j++){
			cin>>field[i][j];
		}
	}
	int dx[9] = {-1,0,1,-1,0,1,-1,0,1};
	int dy[9] = {-1,-1,-1,0,0,0,1,1,1};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(field[i][j] == '#'){
				cout<<'#';
			}else{
				int ans = 0;
				for(int k = 0; k < 9; k++){
					int nx = j + dx[k];
					int ny = i + dy[k];
					if( 0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] == '#') ans++;
				}
				cout<<ans;
			}
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<set>
using ll =  long long;

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

using namespace std;

int main(){

    
    float r;
    cin >> r;

    cout << 2*r*3.14 << endl;


    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int A,B;
    cin>>A>>B;
    cout<<A*B<<endl;

}

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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

string ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS){ return "COUNTER_CLOCKWISE"; }
    if(cross(a,b) < -EPS){ return "CLOCKWISE"; }
    if(dot(a,b) < -EPS){ return "ONLINE_BACK"; }
    if(norm(a) < norm(b)){ return "ONLINE_FRONT"; }
    return "ON_SEGMENT";
}

int main(){
    int Q;
    Point p0,p1,p2;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    cin >> Q;
    while(Q--){
        cin >> p2.x >> p2.y;
        cout << ccw(p0,p1,p2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
class ModComb
  def initialize(max, mod)
    @mod = mod
    @fac = Array.new(max + 1)
    @finv = Array.new(max + 1)
    @inv = Array.new(max + 1)
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..max).each do |i|
      @fac[i] = @fac[i - 1] * i % @mod
      @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * @inv[i] % @mod
    end
  end

  def comb(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

require 'prime'
N, M = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
es = M.prime_division.map { |(n, e)| e }
comb = ModComb.new(10 ** 5 + 100, MOD)
ans = 1
es.each do |e|
  ans = ans * comb.comb(N + e - 1, e) % MOD
end
puts ans


Measured memory_bytes: 4604
# ABC054C - One-stroke Path
# graph theory
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
import sys
input = sys.stdin.readline

from itertools import permutations as perm


def main():
    N, M = tuple(map(int, input().split()))
    A = set(tuple(map(int, input().split())) for _ in range(M))
    ans = 0
    for path in perm(range(2, N + 1), N - 1):  # check all possible paths (O(N!))
        path = (1,) + path
        if all((i, j) in A or (j, i) in A for i, j in zip(path, path[1:])):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define YES cout<<"Yes\n"
#define NO cout<<"No\n"
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  ll n;
  vl arr;
  cin>>n;
  inputv(arr,n);
  if(sz(arr)<3)
  {
    cout<<0;nl;
    return;
  }
  ll ans=0;
  rep(i,n)
  {
    loop(j,i+1,n-1)
    {
      loop(k,j+1,n-1)
      {
        if((arr[i]!=arr[j])&&(arr[j]!=arr[k])&&(arr[k]!=arr[i]))
        {
          ll val1 = min3(arr[i],arr[j],arr[k]);
          ll val3 = max3(arr[i],arr[j],arr[k]);
          ll val2 = arr[i]+arr[j]+arr[k]-val1-val3;
          //cout<<val1<<" "<<val2<<" "<<val3;nl;
          if(val1+val2>val3)
          {
            ans++;
          }
        }
        
      }
    }
  }
  cout<<ans;nl;
  return;
}
int main()
{
    IOS;
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3776
def main():
    N = int(input())
    C = [0]*N
    S = [0]*N
    F = [0]*N
    for i in range(N-1):
        C[i],S[i],F[i] = map(int,input().split())
    for i in range(N):
        t = 0
        for j in range(i,N-1):
            if t < S[j]:
                t = S[j]
            elif t%F[j] == 0:
                tmp = 0
            else:
                t += F[j] - t%F[j]
            t += C[j]
        print(t)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>s;
    cin>>str;

    if(s == str.substr(0,str.length()-1)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3644
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_total = []
B_total = []
A_total.append(0)
B_total.append(0)

tmp = 0

for i in range(N):
    tmp += A[i]
    A_total.append(tmp)

tmp = 0

for i in range(M):
    tmp += B[i]
    B_total.append(tmp)

A_count = 0
B_count = 0

for i in range(N + 1):
    if A_total[i] > K:
        break
    else:
        A_count = i

max_count = A_count

for i in range(M + 1):
    if B_total[i] > K:
        break
    else:
        B_count = i
    while A_total[A_count] + B_total[i] > K and A_count > 0:
        A_count -= 1
    if max_count < A_count + B_count:
        max_count = A_count + B_count

print(max_count)

Measured memory_bytes: 126676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()

{
	string O,E;

	cin >>O>>E;
	
	for (int i = 0; i < O.size(); i++)
	{
		cout << O[i];
		if (i < E.size())
		{
			cout << E[i];
		}
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string a[3];cin>>a[0]>>a[1]>>a[2];
  int cnt[3] = {0};
  int tmp = 0;
  while(1){
    char c = a[tmp][cnt[tmp]++];
    if(a[tmp].size() == cnt[tmp]-1)break;

    if(c == 'a')tmp = 0;
    if(c == 'b')tmp = 1;
    if(c == 'c')tmp = 2;
  }
  if(tmp == 0)print('A');
  if(tmp == 1)print('B');
  if(tmp == 2)print('C');
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

int n;
ll a, b, c, d;

void run() {
    cin >> n >> a >> b >> c >> d;
    ll leftmost = a;
    ll rightmost = a;
    ll seg_len = 0;
    ll dist = 2 * c + (d - c);
    rep(i, 0, n - 1) {
        leftmost -= d;
        rightmost += d;
        seg_len += (d - c);
        dist -= (d - c);
    }
    
    if (dist <= 0) {
        cout << (leftmost <= b && b <= rightmost ? "YES" : "NO") << "\n";
        return;
    }
    
    for (ll x = leftmost; x <= rightmost; x += seg_len + dist) {
        ll l = x;
        ll r = x + seg_len;
        if (l <= b && b <= r) {
            cout << "YES\n";
            return;
        }
    }
    
    cout << "NO\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< (int)(n); i++)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define pb(e) push_back(e)
#define foreach(c, i) for(iter(c) i = (c).begin(); i != c.end(); ++i)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int x, y;
int grid[10][10];

int dr[] = {1, 0, -1, 0};
int dc[] = {0, -1, 0, 1};

bool goal(){
  int a = grid[0][0];
  rep(i, y)rep(j, x) if(a != grid[i][j]) return false;
  return true;
}

inline bool inside(int r, int c){
  return 0 <= r && r < y && 0 <= c && c < x;
}

void change_color(int before, int after, int r, int c, bool change[10][10]){
  grid[r][c] = after;
  change[r][c] = true;
  rep(i, 4){
    int r2 = r + dr[i];
    int c2 = c + dc[i];
    if(inside(r2, c2) && grid[r2][c2] == before){
      change_color(before, after, r2, c2, change);
    }
  }
}

void undo_change(int before, bool change[10][10]){
  rep(i, y)rep(j, x){
    if(change[i][j]) {
      change[i][j] = false;
      grid[i][j] = before;
    }
  }
}


bool dfs(int depth, int limit){
  bool change[10][10];
  memset(change, false, sizeof(change));
  if(depth > limit) return false;
  /*cout << depth << " " << limit << " " << endl;
    rep(i, y) rep(j, x) cout << grid[i][j] << (j == x - 1 ? '\n' : ' ');*/
  if(goal()) return true;
  
  int before = grid[0][0];
  rep(after, 3){
    if(after == before) continue;
    change_color(before, after, 0, 0, change);
    if(dfs(depth + 1, limit)) return true;
    undo_change(before, change);
  }
  return false;
}

int main(){
  char ch;
  while(cin >> x >> y){
    if(x == 0 && y == 0) break;
    rep(i, y)rep(j, x){
      cin >> ch;
      if(ch == 'R') grid[i][j] = 0;
      if(ch == 'G') grid[i][j] = 1;
      if(ch == 'B') grid[i][j] = 2;
    }
    int depth = 0;
    while(!dfs(0, depth)){
      depth++;
    }
    cout << depth << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long ans = 0;
        for(long i = 1; i < Math.floor(Math.sqrt(N)) + 1; i++) {
            if (N%i != 0) continue;
            long k = N/i;
            if (k >= i + 2) ans += k - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
n=int(input())
a=[]
c=[]
for i in range(n):
    a.append([])
    for j in range(3):
        a[i].append([])
for i in range(n):
    #for j in range(3):
    a[i][0], a[i][1], a[i][2]=map(int, input().split())
    a[i].sort()
    if(((a[i][0]*a[i][0])+(a[i][1]*a[i][1]))==(a[i][2]*a[i][2])):
        k="YES"
        c.append(k)
    else:
        k="NO"
        c.append(k)
for i in range(n):
    print(c[i])

Measured memory_bytes: 7940
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 1000000
for i in range(M):
  x,y,c = map(int,input().split())
  ans =  min(ans,a[x-1]+b[y-1]-c)
a.sort()
b.sort()
ans = min(ans,a[0]+b[0])
print(ans)

Measured memory_bytes: 24784
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int X; cin >> X;
  int ans = 1, now = X;
  
  while (now % 360 != 0){
    ans++; now += X;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	int sum = 0;

	for(int i = 0; i < N; ++i){
		int x;
		cin >> x;

		sum += MIN(x * 2, (K - x) * 2);
	}

	cout << sum << endl;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, l;
    cin >> n >> l;
    vector<string> s(n);
    REP(i, n){
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    string ans;
    for(const string& si : s){
        ans += si;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main()
{
	ll N,M;
	string S,T;
	cin >> N >> M;
	cin >> S >> T;
	ll g = gcd(N,M);
	bool a = true;
	rep(i,0,g){
		if(S[(N/g)*i] != T[(M/g)*i])a = false;
		//cout << 1+(N/g)*i << endl;
	}
	if(a)cout << (N/g)*M << endl;
	else cout << -1 << endl;
	return 0;
}


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

int main() {
  int64_t N,A,B;
  cin >> N>>A>>B;
	int64_t c = A+ B;
  int64_t x ;
  if (c == 0){
   x = 0;  
  }
  else if (c !=0 && N % c <= A){
   x = (N / c) * A + (N % c);
  }
  else {
	x =  ((N / c )+1) * A;
  }
  cout << x <<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    int a,b;
    cin >> a >> b;
    int x;
    x = b * 2;
    if(a > x)
        {
        int ans;
        ans = a-x;
        cout << ans << endl;
        }
    else
        cout << "0" << endl;
        
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;
static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll ds(k);
  rep(i,k) cin >> ds[i];

  repLRE(i, n, 1000010){
    bool ok = true;
    rep(j, k){
      if(to_string(i).find('0' + ds[j]) != string::npos) {
        ok = false;
        break;
      }
    }
    if(ok) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3680
def ceil(x,y):
    if x%y == 0:
        return x//y
    else:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)

Measured memory_bytes: 3064