akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
///for(int i = 0;)
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	cout << abs(N - 2) * abs(M - 2) << endl;


    return 0;
}


Measured memory_bytes: 256
// ARC060 C
#include <vector>
#include <iostream>

using namespace std;
using ll = long long;

ll dp[53][53][2501];

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i + 1; j++) {
            for (int k = 0; k <= 2500; k++) {
                dp[i+1][j][k] += dp[i][j][k];
                if (j - 1 >= 0 && k - X[i] >= 0) {
                    dp[i+1][j][k] += dp[i][j-1][k-X[i]];
                }
            }
        }
    }

    ll ret = 0;
    for (int j = 1; j <= N; j++) {
        for (int k = 1; k <= 2500; k++) {
            if (j * A == k) ret += dp[N][j][k];
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 51456
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
void print();
int n,m,k;
int alloc_data[305];
int need_data[305][305];
pii data[200005];
int alloc[305];
int need[305][305];
int zero[305];
bool use[305];

inline void recover(int x)
{
	use[x]=false;
	zero[x]=0;
	for(int i=0;i<m;i++)
	{
		alloc[i]+=need_data[x][i]-need[x][i];
		need[x][i]=need_data[x][i];
		zero[x]+=(need[x][i]==0);
	}
}

inline void run(int x)
{
	memset(use,false,sizeof(use));
	for(int i=0;i<n;i++)
	{
		alloc[i]=alloc_data[i];
	}
	for(int i=0;i<n;i++)
	{
		zero[i]=0;
		for(int j=0;j<m;j++)
		{
			need[i][j]=need_data[i][j];
			zero[i]+=(need_data[i][j]==0);
		}
	}
	for(int i=0;i<=x;i++)
	{
		use[data[i].first]=true;
		alloc[data[i].second]--;
		need[data[i].first][data[i].second]--;
		if(need[data[i].first][data[i].second]==0) zero[data[i].first]++;
		if(zero[data[i].first]==m) recover(data[i].first);
	}
}

inline bool check(int x)
{
	run(x);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(use[j]==false) continue;
			bool flag=true;
			for(int k=0;k<m;k++)
			{
				if(alloc[k]<need[j][k])
				{
					flag=false;
					break;
				}
			}
			if(flag==true) recover(j);
		}
	}
	for(int i=0;i<n;i++)
	{
		if(use[i]) return true;
	}
	return false;
}

void print()
{
	cout<<"ÄÚ´æÊ¹ÓÃÇé¿ö£º\n";
	for(int i=0;i<m;i++)
	{
		cout<<alloc[i]<<' ';
	}
	cout<<endl;
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n>>m>>k;
	for(int i=0;i<m;i++)
	{
		cin>>alloc_data[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>need_data[i][j];
		}
	}
	for(int i=0;i<k;i++)
	{
		cin>>data[i].first>>data[i].second;
		data[i].first--;
		data[i].second--;
	}
	int l=0,r=k-1,res=-2,mid;
	while(l<=r)
	{
		mid=l+((r-l)>>1);
		if(check(mid))
		{
			res=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<res+1<<endl;
	return 0;
}


Measured memory_bytes: 5456
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	int ans=0;
	rep(i, n - 2)if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys, heapq
input = sys.stdin.readline

N, Q = map(int, input().split())

event = []
for _ in range(N) :
    s, t, x = map(int, input().split())
    event.append([s - x, t - x, x])

D = [int(input()) for _ in range(Q)]

event.sort()

closed = []
ei = 0

for d in D :
    while ei < N and event[ei][0] <= d :
        heapq.heappush(closed, (event[ei][2], event[ei][1]))
        ei += 1
    while closed and closed[0][1] <= d :
        heapq.heappop(closed)
    
    if closed :
        print(closed[0][0])
    else :
        print(-1)

Measured memory_bytes: 114208
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).OrderBy(a => a).ToArray();

        int ans = 0;
        for (int i = 1; i < inpt.Length; i++) {
            ans += inpt[i] - inpt[i - 1];
        }
        Console.Write(ans);
    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




100 100 100



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 11348
# B - TAKOYAKI FESTIVAL 2019
N = int(input())
d = list(map(int, input().split()))
tmp = 0


for i in range(N):
    for j in range(N):
        if j == i:
            pass
        else:
            tmp += d[i]*d[j]
ans = tmp / 2
print(int(ans))

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

int n;
int as[11451419];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    for (int i=0; i<n; i++) {
      scanf("%d", &as[i]);
    }
    sort(as, as+n);

    int ans = 1145141919;
    for (int i=0; i<n-1; i++) {
      ans = min(ans, abs(as[i]-as[i+1]));
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 3244
#include <iostream>
#include <algorithm>

const bool debug = false;

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (size_t x = a; x < b; x++)
#ifdef DEBUG
#define show(name) cout << #name " = " << name << endl
#else
#define show(name)
#endif

struct edge {
  int next, weight;
  edge(int next, int weight): next(next), weight(weight){};
};

int idx(int r, int c, int h, int w, int io, int d = 0, int end = 0) {
  int dr[] = {0, +1, -1, 0, 0};
  int dc[] = {0, 0, 0, +1, -1};

  switch (d) {
  case 0: break;
  case 1: if (r == h - 1) return end; break;
  case 2: if (r == 0) return end; break;
  case 3: if (c == w - 1) return end; break;
  case 4: if (c == 0) return end; break;
  }

  return ((r + dr[d]) * w + c + dc[d]) * 2 + io;
}

const int toolarge = 2000000;

int dfs(vector<vector<edge>> &graph, vector<bool> &visit, int init, int end, int flow) {
  if (init == end)
    return flow;
  
  visit[init] = true;
  
  for (auto &e : graph[init]) {
    if (visit[e.next] || e.weight == 0) continue;

    int d = dfs(graph, visit, e.next, end, min(e.weight, flow));

    if (d > 0) {
      e.weight -= d;
      for (auto &b : graph[e.next]) {
        if (b.next == init) {
          b.weight += d;
        }
      }

      return d;
    }
  }

  return 0;
}

int maxflow(vector<vector<edge>> &graph, int init, int end) {
  vector<bool> visit(graph.size(), false);
  int flow = 0;
  int d = 0;

  while ((d = dfs(graph, visit, init, end, toolarge)) > 0) {
    flow += d;
    fill(visit.begin(), visit.end(), false);
  }

  return flow;
}

int main()
{
  size_t h, w;
  cin >> h >> w;

  vector<string> map(h);

  rep (i, 0, h) {
    cin >> map[i];
  }

  bool impossible = false;

  rep (i, 0, h)
    impossible |= (map[i][0] == 'X' || map[i][w - 1] == 'X');

  rep (i, 0, w)
    impossible |= (map[0][i] == 'X' || map[h - 1][i] == 'X');

  if (impossible) {
    cout << -1 << endl;
    return 0;
  }

  int init = h * w * 2;
  int end = h * w * 2 + 1;
  vector<vector<edge>> graph(h * w * 2 + 2);

  rep (r, 0, h) rep (c, 0, w) {
    if (map[r][c] == 'X') {
      graph[init].emplace_back(idx(r, c, h, w, 1), 4);
      graph[idx(r, c, h, w, 1)].emplace_back(init, 0);
    }

    graph[idx(r, c, h, w, 0)].emplace_back(idx(r, c, h, w, 1), 1);
    graph[idx(r, c, h, w, 1)].emplace_back(idx(r, c, h, w, 0), 0);
    
    rep(d, 1, 5) {
      graph[idx(r, c, h, w, 1)].emplace_back(idx(r, c, h, w, 0, d, end), toolarge);
      graph[idx(r, c, h, w, 0, d, end)].emplace_back(idx(r, c, h, w, 1), 0);
    }
  }

  rep (r, 0, h) rep (c, 0, w)
    if (map[r][c] == 'X') {
      graph[init].emplace_back(idx(r, c, h, w, 1), 4);
      graph[idx(r, c, h, w, 1)].emplace_back(init, 0);
    }

  if (debug)
  rep (i, 0, graph.size()) {
    cout << i << " ->";

    for (auto n : graph[i]) {
      cout << " <" << n.next << ", " << n.weight << ">";
    }

    cout << endl;
  }

  cout << maxflow(graph, init, end) << endl;

  return 0;
}


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

double f(vector<int> v, int i) {
    if (i + 1 == (int)v.size()) return v.at(i);
    return (f(v, i + 1) + v.at(i)) / 2;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end(), greater<int>());
    printf("%.6lf", f(v, 0));
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
char s[100006];
int sum[100006];
int n, i, j, l, ok, lmax, q, x, y;
int main()
{
    cin>>n>>q;
    for(i=1;i<=n;i++)
        cin>>s[i];
    for(i=2;i<=n;i++)
    {
        if((s[i]=='C'&&s[i-1]=='A'))
            sum[i]=sum[i-1]+1;
        else sum[i]=sum[i-1];
    }
    for(i=1;i<=q;i++)
    {
        cin>>x>>y;
        cout<<sum[y]-sum[x]<<'\n';
    }
   // for(i=1;i<=n;i++)
     //   cout<<sum[i]<<' ';
    return 0;
}


Measured memory_bytes: 1280
"""
A^5 - B^5
= (A - B)(A^4 + A^3*B + A^2*B^2 + A*B^3 + B^4)
= (A - B){(A + B) * (A^3 + B^3) + A^2*B^2}
= (A - B){(A + B)^2 * (A^2 - AB + B^2) + A^2*B^2}

(A + B)^2 > 0, (A^2 - AB + B^2) > 0, A^2*B^2 > 0
-> (A - B) > 0
"""


def main():
    print(*solve())


def solve():
    X = int(input())
    N = 10 ** 9 + 7

    step = 2 if X % 2 else 1  # if X is odd number, (A - B) also must be odd.

    for x in range(1, N, step):  # x means (A - B)
        if X % x:  # X must be divided by (A - B)
            continue

        for a in range(N):
            b = a - x

            diff = X - (a ** 5 - b ** 5)
            if diff == 0:
                return a, b

            if diff < 0 < b:
                break


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long num = scan.nextLong();

		long ans = num / 11;
		ans *= 2;
		long tmp = num % 11;
		if(tmp >= 7){
			ans += 2;
		}else if(tmp != 0){
			ans++;
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 9684
package main

import "fmt"

func main() {
	var N int
	_, _ = fmt.Scan(&N)
	tree := make([][]int, N+1)
	for i := 1; i < N + 1; i++ {
		tree[i] = make([]int, 0)
	}
	for i := 0; i < N - 1; i++ {
		var a, b int
		_, _ = fmt.Scan(&a, &b)
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}
	var q1 []int
	qq1 := []int{1}
	count1 := 0
	var q2 []int
	qq2 := []int{N}
	count2 := 0
	passed := make([]bool, N+1)
	for len(qq1) != 0 || len(qq2) != 0 {
		q1 = qq1
		qq1 = make([]int, 0)
		for i := 0; i < len(q1); i++ {
			if len(tree[q1[i]]) == 0 {
				continue
			}
			for j := 0; j < len(tree[q1[i]]); j++ {
				next := tree[q1[i]][j]
				if passed[next] {
					continue
				}
				qq1 = append(qq1, next)
				passed[next] = true
				count1++
			}
		}
		q2 = qq2
		qq2 = make([]int, 0)
		for i := 0; i < len(q2); i++ {
			if len(tree[q2[i]]) == 0 {
				continue
			}
			for j := 0; j < len(tree[q2[i]]); j++ {
				next := tree[q2[i]][j]
				if passed[next] {
					continue
				}
				qq2 = append(qq2, next)
				passed[next] = true
				count2++
			}
		}
	}
	if count1 > count2 {
		fmt.Println("Fennec")
	} else {
		fmt.Println("Snuke")
	}
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int A,B,K;cin>>K>>A>>B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


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

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

typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF=2000000000;
const ll LINF = 1e18+5;

int main() {
    ll N;
    cin >> N;
    if(N%2==1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll ten = 10;
    while(ten<=N) {
        ans += N/ten;
        ten*=5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

vector<int> pf(int n) {
    vector<int> primes;
    if (n%2 == 0) {
        primes.push_back(2);
        while (n%2 == 0) n /= 2;
    }
    for (int i=3; i*i<=n; i+=2) {
        if (n%i) continue;
        primes.push_back(i);
        while (n%i == 0) n /= i;
    }
    if (n != 1) primes.push_back(n);

    return primes;
}

int main() {
    const int MAX_N = 1e6;
    vector<int> sieve(MAX_N+1);
    iota(sieve.begin(), sieve.end(), 0);
    for (int i=2; i<=MAX_N; i++) {
        if (i != sieve[i]) continue;
        for (int j=i+i; j<=MAX_N; j+=i)
            sieve[j] = i;
    }

    int n;
    cin >> n;
    int all_gcd;
    bool pc = true;
    unordered_map<int, bool> check;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        all_gcd = (i==0)? a : gcd(all_gcd, a);

        if (!pc) continue;
        set<int> st;
        while (a != 1) {
            st.insert(sieve[a]);
            a /= sieve[a];
        }
        for (auto i : st) {
            if (check[i]) pc = false;
            check[i] = true;
        }
    }

    if (pc)
        cout << "pairwise coprime" << endl;
    else if (all_gcd == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


Measured memory_bytes: 10100
#include<iostream>
#include<iomanip>
using namespace std; // 575

int main() {
	double T, X;
	cin >> T >> X;
	cout << setprecision(8) << fixed << T / X;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	xs := make([]int, m)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	if n >= m {
		fmt.Println(0)
		return
	}

	sort.Ints(xs)
	ls := make([]int, m-1)
	for i := 0; i < m-1; i++ {
		ls[i] = xs[i+1] - xs[i]
	}
	sort.Ints(ls)
	var sum int
	for i := 0; i < n-1; i++ {
		sum += ls[m-2-i]
	}

	fmt.Println(xs[m-1] - xs[0] - sum)
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

int a, b, n;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

vector<bool> isPrimes(int n) {
	vector<bool> res(n, true);
	res[0] = res[1] = false;
	for (int i = 2;i < sqrt(n);i++) {
		if (res[i]) {
			for (int j = 0;i * (j + 2) < n;j++) {
				res[i * (j + 2)] = false;
			}
		}
	}
	return res;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	VB is_primes = isPrimes(100 * 100 * 101);
	while (1) {
		cin >> a >> b >> n;
		if (a == 0 && b == 0 && n == 0) break;
		int i = 0;
		int cnt = 0;
		int g;
		while (1) {
			g = a + i * b;
			if (is_primes[g]) {
				cnt++;
			}
			if (cnt == n) {
				break;
			}
			i++;
		}
		cout << g << endl;
	}
	return 0;
}

Measured memory_bytes: 3216
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

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

    vector<li> fr(m), to(m);
    rep(i, m) {
        cin >> fr[i] >> to[i];
        fr[i]--;
        to[i]--;
    }

    vector<li> count(n, 1), red(n, 0);
    red[0] = 1;
    rep(i, m) {
        count[fr[i]]--;
        count[to[i]]++;
        if (red[fr[i]]) {
            red[to[i]] = 1;
        }
        if (count[fr[i]] == 0) {
            red[fr[i]] = 0;
        }
    }

    cout << accumulate(red.begin(), red.end(), 0);

    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();
        long a = n + 1;
        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
            if(n % i == 0){
                a = Math.min(i + n / i , a);
            }
        }
        System.out.println(a - 2);
    }
}

Measured memory_bytes: 35664
l=[0]*1000
mod=10**9+7
n=int(input())
ans=1
for te in range(2,n+1):
    i=te
    for j in range(2,int(te**(1/2))+1):
        if i%j==0:
            while i%j==0:
                i//=j
                l[j]+=1
    if i!=1:l[i]+=1
    l[i]%=mod
for i in l:
    if i:ans*=(i+1)
    ans%=mod
print(ans)


Measured memory_bytes: 3188
from typing import List


def main():
    n = int(input())
    m = xyz(n)
    for i in m:
        print(i)


def f(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def xyz(n: int) -> List[int]:
    result = [0] * n
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                m = f(x, y, z)
                if m > n:
                    break
                result[m - 1] += 1

    return result


if __name__ == '__main__':
    main()


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

int main(){
  long long x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  long long n=x/d+1;
  long long m=min(k,n);
  x-=d*m;
  if((k-m)%2==0) cout<<abs(x);
  else cout<<x+d;
}
    
  

Measured memory_bytes: 3524
function Main(input){
	input = ~~input;
  
  var arr = [];
  
  var count = 1;
  while(true){
  	if(arr[input]){
    	return count;
    }else{
    	arr[input]=true;
    }
  	if(input%2){input=input*3+1}else{input/=2};
    count++;
  }
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8
`);

Measured memory_bytes: 7372
N, M = map(int, input().split())
G = [set() for i in range(N + 1)]

for i in range(M):
    a, b = map(int, input().split())
    G[a].add(b)
    G[b].add(a)

for a in G[1]:
    if a in G[N]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


Measured memory_bytes: 67740
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, a, b, c;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
char a[114][114];
signed main() {
	ll h, w;
	cin >> h >> w;
	rep(i, h) { rep(j, w)cin >> a[i][j]; }
	bool b[114], c[114];
	rep(i, 114) {
		b[i] = true, c[i] = true;
	}
	rep(i, h) {
		rep(j, w) {
				if (a[i][j] == '#')b[i] = false;
		}
	}
	rep(i, w) {
		rep(j, h) {
				if (a[j][i] == '#')c[i] = false;
		}
	}
	rep(i, h) {
		if (!b[i]) {
			rep(j, w) {
				if (!c[j])cout << a[i][j];
			}
			cout << endl;
		}
	}
	cout << endl;
	ggr
}


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

const int MAX_N = 5001;

int A, B;
int tA[MAX_N], tB[MAX_N];

int f(int *a, int na, int *b, int nb) {
  int j = 0;
  for(int i = 0; i < na && j < nb; ++i) {
    if(a[i] == b[j]) ++j;
  }
  return j;
}

int main() {
  cin >> A >> B;
  for(int i = 0; i < A; ++i) cin >> tA[i];
  for(int i = 0; i < B; ++i) cin >> tB[i];
  int ans = 0;
  for(int i = 0; i < B; ++i)
    ans = max(ans, f(tA,A,tB+i,B-i));
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#pragma GCC optimize ("03")

#pragma GCC optimize ("unroll-loops")

#define ll long long

#define ms(a) memset(a,0,sizeof(a))

#define endl '\n'

#define pb push_back

#define mp(a,b) make_pair(a,b)

#define mpp(a,b,c) make_pair(a,make_pair(b,c))

#define fi first

#define se second

#define rep(a,b,c) for(int a=b;a<=c;a++)

#define repp(a,b,c) for(int a=b;a>=c;a--)

ll n,arr[100100]={0};

ll memo[100100]={0};

ll dp(ll a){

	if(a>n)return 1e9;	else if(a==n)return 0;

	else if(memo[a]!=-1)return memo[a];

	else{

		ll temp;

		temp = min(dp(a+1)+abs(arr[a]-arr[a+1]),dp(a+2)+abs(arr[a]-arr[a+2]));

		return memo[a] = temp;

	}

}

int main(){

/////////////////////////////////////////////

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

/////////////////////////////////////////////

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

	scanf("%lld",&n);

	rep(i,1,n)scanf("%lld",&arr[i]);

	ll res;

	res = dp(1);

	cout << res << endl;	

	return 0;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;
 
 
int main(){
    int n,m; cin >> n >> m;
    ll ans=0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vector<P> ko(m);
    rep(i,m){
        int b,c; cin >> b >> c;
        ko[i].second=b; ko[i].first=c;
    }
    sort(all(ko));
    reverse(all(ko));
    int now=0;
    bool go=true;
    rep(i,m){
        int next=ko[i].first;
        int times=ko[i].second;
        rep(j,times){
            if(a[now]>=next){
                go=false;
                break;
            }
            if(now>=a.size()){
                go=false;
                break;
            }
            a[now]=next;
            now++;
        }
        if(go==false) break;
    }
    rep(i,n) ans+=a[i];
  cout << ans << endl;
return 0;
}

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

using namespace std;
int main() {
    int r,g,b;
    int num;

    cin >> r >> g >> b;
    num = r*100 + g*10 + b;

    if ( num % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	set<pair<int,int> > z;
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (z.empty()) {
			z.insert(make_pair(a[i],-i));
		}
		else {
			auto it=z.lower_bound(make_pair(a[i],-i));
			if (it == z.begin()) {
				z.insert(make_pair(a[i],-i));
			}
			else {
				it--;
				z.erase(*it);
				z.insert(make_pair(a[i],-i));
			}
		}
	}
	printf("%d\n", (int)z.size());

	return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  if (l % d == 0) {
    cout << r / d - l / d + 1;
    return 0;
  }
  {
    cout << r / d - l / d;
    return 0;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
 
int main() {
  string S;
  ll Q;
  cin >> S >> Q;
  
  deque<char> deq;
  for (ll i = 0; i < S.size(); i++) {
    deq.push_back(S.at(i));
  }
  
  bool reverse = false;
  for (ll i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      //反転
      reverse = !reverse;
      continue;
    } else {
      int F;
      char c;
      cin >> F >> c;
      if (F == 1) {
        if (reverse) {
          deq.push_back(c);
        } else {
          deq.push_front(c);
        }
      } else {
        if (reverse) {
          deq.push_front(c);
        } else {
          deq.push_back(c);
        }
      }
    }
  }
  
  if (reverse) {
    for (ll i = deq.size() - 1; i >= 0; i--) {
      cout << deq.at(i);
    }
  } else {
	for (ll i = 0; i < deq.size(); i++) {
      cout << deq.at(i);
    }
  }
}

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


ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}

ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<P> primes(ll n){
    vector<P> ans;
    for(ll i=2; i*i<=n; i++){
        int cnt = 0;
        if(n%i!=0)continue;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        ans.push_back(P(i,cnt));
    }
    if(n!=1)ans.push_back(P(n,1));
    return ans;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    map<ll,ll> pr;
    rep(i,n){
        vector<P> r = primes(a[i]);
        for(P p:r){
            pr[p.first]=max(pr[p.first],p.second);
        }
    }
    ll l = 1;
    for(P p:pr){
        l = mod(l*power(p.first,p.second));
    }
    ll ans = 0;
    for(ll aa:a){
        ans = mod(ans+mod(l*inv(aa)));
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
mod=10**9+7
ans=0
def sum_S(a,z):
    ans=0
    for i in range(len(z)):
        z_i=z[i]*(2*i+1-a)
        ans+=z_i
    return ans
ans_x=sum_S(n,x)
ans_y=sum_S(m,y)
res=(ans_x*ans_y)%mod
print(res)


Measured memory_bytes: 18576
#include <iostream>
#include <algorithm>
#include <vector>
#include <ostream>
#include <cmath>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

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

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i] << (i + 1 == v.size() ? "" : ", ");
  }
  os << "]";
  return os;
}

template <class T>
std::vector<std::vector<T>> Imos2D(const std::vector<std::vector<T>>& a) {
  int h = a.size(), w = a[0].size();
  std::vector<std::vector<T>> s(h + 1, std::vector<T>(w + 1, 0));
  rep(i, h) rep(j, w) s[i + 1][j + 1] = a[i][j];
  rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
  rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
  return s;
}

template <class T>
int sum(const std::vector<std::vector<T>>& s, int i, int j, int h, int w) {
  return s[i + h][j + w] - s[i][j + w] + s[i][j] - s[i + h][j];
}

int main() {
  int N, K, x, y;
  char ch;

  cin >> N >> K;

  int ans = 0;
  std::vector<std::vector<std::vector<int> > > b(2, std::vector < std::vector<int> >(K + 1, std::vector<int>(K + 1, 0))), w(2, std::vector<std::vector<int> >(K + 1, std::vector<int>(K + 1, 0)));

  for (int i = 0; i < N; ++i) {
    cin >> x >> y >> ch;
    int c = (ch == 'B' ? 0 : 1);
    if (c == 0) {
      b[(x / K) % 2 == (y / K) % 2][x % K][y % K]++;
    }
    else {
      w[(x / K) % 2 == (y / K) % 2][x % K][y % K]++;
    }
  }

  std::vector<std::vector<int> > b0 = Imos2D(b[0]), w0 = Imos2D(w[0]), b1 = Imos2D(b[1]), w1 = Imos2D(w[1]);

  //cerr << "OK" << endl;

  for (int i = 0; i < K; ++i) {
    for (int j = 0; j < K; ++j) {
      ans = std::max(ans, sum(b0, 0, 0, i, j) + sum(b0, i, j, K - i, K - j) + sum(w0, i, 0, K - i, j) + sum(w0, 0, j, i, K - j) +
        sum(w1, 0, 0, i, j) + sum(w1, i, j, K - i, K - j) + sum(b1, i, 0, K - i, j) + sum(b1, 0, j, i, K - j));
      ans = std::max(ans, sum(w0, 0, 0, i, j) + sum(w0, i, j, K - i, K - j) + sum(b0, i, 0, K - i, j) + sum(b0, 0, j, i, K - j) +
        sum(b1, 0, 0, i, j) + sum(b1, i, j, K - i, K - j) + sum(w1, i, 0, K - i, j) + sum(w1, 0, j, i, K - j));
    }
  }

  cout << ans << endl;
  //cin >> N;
  return 0;
}


Measured memory_bytes: 31872
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << floor((T+0.5)/A)*B << endl;
}


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

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  int ans = 0;
  for (int i=0; i<N; i++){
    int h; cin >> h;
    if (h >= K) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int n,m;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
	cin >> n >> m;
  
	int ans = 0;
	ans += (n*(n-1)) / 2;
	ans += (m*(m-1)) / 2;
	cout << ans << endl;
}



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

int main() {
	long long a, b, k;
	scanf("%lld%lld%lld", &a, &b, &k);

	while (k && (a > 0 || b > 0)) {

		if (a > 0) {
			if (k >= a) {
				k -= a;
				a = 0;
			} else {
				a -= k;
				k = 0;
			}
		} else if (b > 0) {
			if (k >= b) {
				k -= b;
				b = 0;
			} else {
				b -= k;
				k = 0;
			}
		} else {
			k = 0;
		}
	}

	printf("%lld %lld\n", a, b);
}

Measured memory_bytes: 256
class Array
  def cumsum; s = 0; map{|k| s += k } end
  def fd(n=nil); n = self.max if n.nil?; res = Array.new(n+1,0);self.map{|e| res[e]+=1 };res;end
end

n, m = gets.to_s.split.map{|t|t.to_i}
a    = gets.to_s.split.map{|t|t.to_i}.sort

sum_min = a[0]  * 2
sum_max = a[-1] * 2

cfd = a.fd.reverse.cumsum.reverse
class << cfd
  def number_greater_than(x)
    return self[0] if x <= 0
    return 0 if  size <= x+1
    self[x+1]
  end
end

sum_x = (sum_min .. sum_max).bsearch do |sum_x|
  cnt = 0
  a.each do |r|
    cnt += cfd.number_greater_than(sum_x-r)
    break if cnt >= m
  end
  cnt < m
end

c = ([0] + a).cumsum
s = c[-1]

ans = 0
a.each do |r|
  pos = a.bsearch_index{|l| sum_x < r + l } || n
  cnt = n - pos
  ans += cnt * r + (s - c[pos])
  m -= cnt
end

ans += m * sum_x

puts ans

Measured memory_bytes: 14472
#include<stdio.h>

int main()
{
    long long int w, h, x, y;

    scanf("%lld %lld %lld %lld", &w, &h, &x, &y);

    printf("%lf %d\n", w * h / 2.0, (x * 2 == w && y * 2 == h) );

    return 0;
}



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

int main()
{
    cin >> H >> W;
    vector<vector<int>> d(H * W, vector<int>(H * W, H * W + 1));
    vector<bool> is_road(H * W, false);
    rep(i, H * W)
    {
        char S;
        cin >> S;
        if (S == '.')
            is_road[i] = true;
    }

    rep(now, H * W)
    {
        //        cout << "now" << now << endl;
        d[now][now] = 0;
        int w = now % W;
        int h = now / W;
        //      cout << h << "," << w << endl;
        if (is_road[now])
        {
            if (w != 0 && is_road[now - 1])
            {
                d[now][now - 1] = 1;
                d[now - 1][now] = 1;
            }
            if (w != W - 1 && is_road[now + 1])
            {
                d[now][now + 1] = 1;
                d[now + 1][now] = 1;
            }
            if (h != 0 && is_road[now - W])
            {
                d[now][now - W] = 1;
                d[now - W][now] = 1;
            }
            if (h != H - 1 && is_road[now + W])
            {
                d[now][now + W] = 1;
                d[now + W][now] = 1;
            }
        }
    }

    int ans = -1;

    for (int k = 0; k < H * W; k++)
    { // 経由する頂点
        for (int i = 0; i < H * W; i++)
        { // 始点
            for (int j = 0; j < H * W; j++)
            { // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for (int start = 0; start < H * W; start++)
    {
        if (!is_road[start])
            continue;
        for (int goal = start + 1; goal < H * W; goal++)
        {
            if (!is_road[goal])
                continue;
            ans = max(d[start][goal], ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;
int n;
int x, y;

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

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        if (x == y) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
 
#define Bye return 0
#define int long long
 
void solve(){
    int n; cin>>n;
    double dp[n+1][n+1];
 
    memset(dp, 0, sizeof dp);
 
    double p[n+1];
    for (int i=1; i<=n; i++)
        cin>>p[i];
 
    dp[0][0] = 1;
 
    for (int i=1; i<=n; i++){
 
        for (int j=0; j<=i; j++){
 
            if(j == 0)
                dp[i][j] = (1-p[i])*dp[i-1][j];
            else
                dp[i][j] = (1-p[i])*dp[i-1][j]
                                      +
                                p[i]*dp[i-1][j-1];
        }
    }
 
    double ans = 0.0;
    for (int i=(n/2)+1; i<=n; i++)
        ans += dp[n][i];
    cout << setprecision(9) << ans;
}
 
int32_t main() {
    solve();
    Bye;
}

Measured memory_bytes: 74084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>

using namespace std;

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

	if(n==1){
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s=raw_input()
t=len(s)-1
tmp=2**t
ans=0
for i in range(tmp):
    p=bin(i)[2:]
    p='0'*(t-len(p))+p
    x=''
    for j,k in enumerate(s):
        x+=k
        if j!=t and p[j]=='1':
            x+='+'
    ans+=eval(x)
print ans

Measured memory_bytes: 2692
n,m = map(int, input().split())
cs = list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
for i in range(n+1):
    for c in cs:
        if i+c < n+1:
            dp[i+c] = min(dp[i+c], dp[i]+1)
print(dp[n])


Measured memory_bytes: 7268
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[1005][1005];
int cost[1005][1005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<pll> v(n);
  rep(i,n){
    ll x, l; cin>>x>>l;
    v[i]={x-l, x+l};
  }
  sort(v.begin(), v.end(), [](pll a, pll b) { return a.second < b.second; });
  
  int ans=0;
  int now=-1e9-5;
  rep(i,n){
    if(now<=v[i].first){
      ans++;
      now=v[i].second;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn main(){
    let n = read::<usize>();
    let mut a = read_vec::<i32>();
    a.insert(0,0);
    a.push(0);
    let mut r = 0;
    for i in 1..n+2{
        r += (a[i]-a[i-1]).abs()
    }
    for i in 1..n+1{
        println!("{}",r-(a[i]-a[i-1]).abs()-(a[i+1]-a[i]).abs()+(a[i+1]-a[i-1]).abs());
    }
}

fn read_vec<T: FromStr>() -> Vec<T>{
    let mut buf = String::new();
    stdin().read_line(&mut buf);
    let vec : Vec<&str> = buf.split_whitespace().collect();
    let mut v : Vec<T> = vec!();
    for i in 0..vec.len(){
        v.push(vec[i].parse().ok().expect("Error"));
    }
    v
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("Error") as char) 
        .skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Error")
}

Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>
#include <list>

using ll = long long;

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = n;
    while (r - l > 1) {
        int m = (l + r) / 2;
        unordered_map<string, int> um;
        string sub = s.substr(0, m);
        // cerr << "Int" << sub << '\n';
        um[sub] = m;
        bool yes = false;
        for (int i=m+1; i<=n; i++) {
            sub += s[i-1];
            sub.erase(sub.begin());
            // cerr << sub << ' ' << um[sub] << ' ' << i << '\n';
            if (um[sub] > 0 && um[sub] + m <= i) {
                yes = true;
                //cerr << sub << '\n';
                break;
            }
            if (um[sub] == 0)
                um[sub] = i;
        }
        if (yes)
            l = m;
        else
            r = m;
    }
    cout << l << '\n';
    return 0;
}

Measured memory_bytes: 6664
open System

[<EntryPoint>]
let main argv =
    let (|ABC|ARC|AGC|) x = if x < 1200 then ABC else if x < 2800 then ARC else AGC
    match Console.ReadLine() |> int with
    | ABC -> "ABC"
    | ARC -> "ARC"
    | AGC -> "AGC"
    |> Console.WriteLine
    0


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

int main(void){
  string s;
  int k;
  cin >> s >> k;
  string ans = "1";
  if(k < s.length()){
    for(int i = 0; i < k; i++){
      if(s[i] != '1'){
	ans = s[i];
	break;
      }
    }
  }else{
    for(int i = 0; i < s.length(); i++){
      if(s[i] != '1'){
	ans = s[i];
	break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
  
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
  
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
  
int F()
{
    char ch;
    int x, a;
    while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
    if (ch == '-') ch = getchar(), a = -1;
    else a = 1;
    x = ch - '0';
    while (ch = getchar(), ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + ch - '0';
    return a * x;
}
  
int a, b;
  
int main()
{
    gii(a, b);
    if (a <= 0 && b >= 0) puts("Zero");
    else
    {
        if (a > 0) puts("Positive");
        else
        {
            if ((b - a + 1) & 1) puts("Negative");
            else puts("Positive");
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,y,a,b,i;
	while(scanf("%d%d",&x,&y)!=EOF){
		a=x;b=y;
		while(1){
			if(a>b)a-=b;
			if(a<b)b-=a;
			if(a==b)break;
		}
		printf("%d %d\n",a,x*(y/a));
	}
	return 0;
}

Measured memory_bytes: 596