akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=200000+10;
pair<int,int> a[N];
ll b[N];
int n;
struct segmentTree
{
	ll tree[N<<2];
	void pushup(int k)
	{
		tree[k]=max(tree[k<<1],tree[k<<1|1]);
	}
	void build(int k,int l,int r)
	{
		if(l==r){
			tree[k]=l;
			return;
		}
		int mid=(l+r)/2;
		build(k<<1,l,mid);
		build(k<<1|1,mid+1,r);
		pushup(k);
	}
	ll query(int k,int l,int r,int x,int y)
	{
		if(x>r||y<l)return -1e9;
		if(x<=l&&r<=y)return tree[k];
		int mid=(l+r)/2;
		ll res=query(k<<1,l,mid,x,y);
		res=max(res,query(k<<1|1,mid+1,r,x,y));
		return res;
	}
	void modify(int k,int l,int r,int i,int x)
	{
		if(l==r){
			tree[k]=x;
			return;
		}
		int mid=(l+r)/2;
		if(i<=mid)modify(k<<1,l,mid,i,x);
		else modify(k<<1|1,mid+1,r,i,x);
		pushup(k);
	}
}t;
ll dp[N],mod=998244353,r;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i].first>>a[i].second;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)b[i]=a[i].first;
    t.build(1,1,n);
	dp[n+1]=1;
	for(int i=n;i>=1;i--){
		int pos=upper_bound(b+1,b+1+n,1ll*a[i].first+a[i].second-1)-b-1;
		r=t.query(1,1,n,i,pos);
		t.modify(1,1,n,i,r);
		dp[i]=(dp[i+1]+dp[r+1])%mod;
	}
	cout<<dp[1]<<"\n";
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll x0 = n;
    ll x1 = (n/b)*b-1;/*
    cout << x0 << endl;
    cout << x1 << endl;
    cout << (a*x0)/b-a*(x0/b) << endl;
    cout << (a*x1)/b-a*(x1/b) << endl;*/
//    ll ans = max(1000000000001, 1000000000002);
    ll ans = max((a*x0)/b-a*(x0/b), (a*x1)/b-a*(x1/b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
N, K = map(int, input().split())


def main():
    if K > (N - 2)*(N - 1) / 2:
        return 0
    
    # 中心が頂点0のスターをまずは構築
    G = [(0, i) for i in range(1, N)]
    

    # (N - 2)*(N - 1) / 2 - K の数だけ辺を追加
    num = (N - 2)*(N - 1) / 2 - K
    u = 1
    v = 2    
    while num >= 1:
        if v == N:
            u += 1
            v = u + 1
        G.append((u, v))

        v += 1
        num -= 1
    
    return G

if main():
    G = main()
    print(len(G))
    for i in range(len(G)):
        u, v = G[i]
        print("{} {}".format(u+1, v+1))

else:
    print("-1")
    
    

Measured memory_bytes: 3716
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int lcs(string x, string y) {
	int c[1200][1200];
	int m = x.size();
	int n = y.size();
	x = ' ' + x;
	y = ' ' + y;
	for (int i = 1; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;
	c[0][0] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (x[i] == y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
		}
	}
	return c[m][n];
}

int main() {
	int n;
	cin >> n;
	string a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		cout << lcs(a, b) << endl;
	}
}

Measured memory_bytes: 7904
s = list(input())
l = len(s)
ans = "NO"
for i in range(l):
    for j in range(1, l):
        t = s.copy()
        del t[i:j]
        if t == ["k","e","y","e","n","c","e"]:
            ans = "YES"
            break
print(ans)

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
   return a%b ==0 ? b : gcd(b,a%b);
}
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    if(s[0]!='A')
    {
        cout<<"WA"<<endl;
        return 0;
    }
    if(s[1]=='C'||!(s[1]>='a'&&s[1]<='z'))
    {
        cout<<"WA\n";
        return 0;
    }
    int cnt=0;
    int ans=0;
    for(int i=2;i<l-1;i++)
    {
        if(s[i]=='C')cnt++;
        if(s[i]>='a'&&s[i]<='z')ans++;
    }
    if(cnt!=1){cout<<"WA"<<endl;return 0;}
    if(s[l-1]>='a'&&s[l-1]<='z')ans++;
    if(ans+1+2!=l){
        cout<<"WA"<<endl;
        return 0;
    }
    cout<<"AC"<<endl;
    return 0;
}


Measured memory_bytes: 256
//Knapsack2
import java.io.*;
import java.util.*;
public class Main{
	static int n,w;
	static int[] weight=new int[101];
	static int[] cost=new int[101];	
	public static long solve(int max_profit,int w){			
		 long[][] dp=new long[n+1][max_profit+1];
		 long inf=(long)1e11;
		 for(int i=1;i<=max_profit;i++){
		 	dp[0][i]=inf;
		 }
		 for(int i=1;i<=n;i++){
		 	for(int j=1;j<=max_profit;j++){
		 		if(cost[i-1]>j){
		 			dp[i][j]=dp[i-1][j];
		 		}
		 		else{
		 			dp[i][j]=Math.min(0+dp[i-1][j],weight[i-1]+dp[i-1][j-cost[i-1]]);
		 		}
		 	}
		 }
		 long ans=0;
		 for(int i=1;i<=max_profit;i++){
		 	if(dp[n][i]<=w){
		 		ans=i;
		 	}
		 }
		 
		 return ans;

	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
        String str[]=br.readLine().split(" ");
		n=Integer.parseInt(str[0]); 
		w=Integer.parseInt(str[1]); 
		int max_profit=0;
		for(int i=0;i<n;i++){	
		str=br.readLine().split(" ");		
		   weight[i]=Integer.parseInt(str[0]);
		   cost[i]=Integer.parseInt(str[1]);
		   max_profit+=cost[i];
		}

		System.out.println(solve(max_profit,w));
	}
    }


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

#define NIL -2
#define INF 1000000001
#define EPS 1e-10
#define equals(a,b) (fabs((a) - (b)) < EPS)

using namespace std;
class Point{
    public:
    double x,y;

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

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

    double norm(){ return x*x + y*y;}
    double abs(){ return sqrt(norm());}
    double dot(Point p){
        return x*p.x + y*p.y;
    }

    bool operator < (Point &p){
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == (Point &p){
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
  
};
typedef Point Vector;

int main(){
    double x1,y1,x2,y2;
    double x,y;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    Point p1(x1,y1);
    Point p2(x2,y2);
    Vector p12 = p2-p1;
    p12 = p12 / p12.abs();

    int q;
    scanf("%d",&q);
    for(int i = 0;i < q;i++){
        scanf("%lf %lf",&x,&y);
        Point p(x,y);
        p = p - p1;
        Point ans;
        double inner_prod = p12.dot(p);
        ans = p + (p12 * inner_prod - p)*2 +p1;
        printf("%.9lf %.9lf\n",ans.x,ans.y);
    }
    return 0;
}


Measured memory_bytes: 3256
#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<ll> A(N), B(N + 1, 0);
    rep(i, N) {
        cin >> A[i];
        B[A[i]]++;
    }
    ll s = 0;
    rep(i, N + 1) {
        s += B[i] * (B[i] - 1) / 2;
    }
    rep(i, N) {
        cout << s - B[A[i]] + 1 << "\n";
    }
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K){
    cout << S << endl;
  }
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc,char **argv)
{
	int x,b,t;

	scanf("%d %d",&x,&t);

	b = x - t;

	if (b <= 0)
	{
		printf("0\n");
	}

	else 
	{
		printf("%d\n",b);
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define testcase int tc;cin>>tc;while(tc--)
#define all(x) x.begin(),x.end()
#define allR(x) x.rbegin(),x.rend()

int main()
{

    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    int sum=0;
    cin>>n;
    vector<int> v(2*n);
    for(int i=0;i<2*n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<2*n;i+=2)
    {
        sum+=v[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double pi = acos(-1);
    double theta = ((double)M*(1.0/(60.0*12.0))+(double)H/(double)12-(double)M/(double)60)*2*pi;
    if(theta>2*pi) {
        theta -= 2*pi;
    }
    double d = sqrt(B*B+A*A-2*A*B*cos(theta));
    printf("%.13lf\n", d);
    return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, M;
	cin >> N >> M;
	if (N == M) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

int n, m, x, d;
vector<string> field;

bool solve() {
	int num[n];
	for (int i = 0; i < n; i++) num[i] = i + 1;
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (field[i][j] == '1') {
				swap(num[j], num[j + 1]);
			}
		}
	}
	return (num[x - 1] == m);
}

int main() {
	while (cin >> n, n) {
		cin >> m >> x >> d;
		field.clear();
		for (int i = 0; i < d; i++) {
			string line;
			cin >> line;
			field.push_back(line);
		}
		if (solve()) {
			cout << 0 << endl;
			continue;
		}
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n - 1; j++) {
				if ((j == 0 || field[i][j - 1] == '0') && field[i][j] == '0' && (j + 1 == n - 1 || field[i][j + 1] == '0')) {
					field[i][j] = '1';
					if (solve()) {
						cout << i + 1 << ' ' << j + 1 << endl;
						goto NEXT;
					}
					field[i][j] = '0';
				}
			}
		}
		cout << 1 << endl;
NEXT:
		continue;
	}
}

Measured memory_bytes: 1212
#include<cstdio>
using namespace std;
typedef long long int ll;

int N, k;

int main(){
	scanf("%d %d", &N, &k);
	ll res = 0;
	for(int i = 0; i < N - 1; i++){
		res += res / (ll)(k - 1) + 1;
		if(res % k == 0) res++;
	}
	printf("%lld\n", res);
	return 0;
}


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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

#define Grt ch = getchar()
#define DeBug(x) std::cout << #x << '=' << x << std::endl

const int MaxN = 2 * 1e5 + 10;

namespace IO
{
	char buf[1<<15], *fs, *ft;
	inline char getc() { return ft == fs && (ft = (fs = buf) + fread(buf, 1, 1<<15, stdin), ft == fs) ? 0 : *fs++; }
	template <typename T> inline void read(T &x)
	{
		x = 0;
		T f = 1, Grt;
		while (!isdigit(ch) && ch ^ '-') Grt;
		if (ch == '-') f = -1, Grt;
		while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), Grt;
		x *= f;
	}


	template <typename T, typename... Args>
	inline void read(T &x, Args &...args) { read(x); read(args...); }

	char Out[1<<24], *fe = Out;
	inline void flush() { fwrite(Out, 1, fe-Out, stdout); fe = Out; }
	template <typename T> inline void write(T x, char str)
	{
		if (!x) *fe++ = 48;
		if (x < 0) *fe++ = '-', x = -x;
		T num = 0, ch[20];
		while (x) ch[++ num] = x % 10 + 48, x /= 10;
		while (num) *fe++ = ch[num --];
		*fe++ = str;
	}
}

using IO::read;
using IO::write;

template <typename T> inline bool chkMin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> inline bool chkMax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template <typename T> inline T min(T a, T b) { return a < b ? a : b; }
template <typename T> inline T max(T a, T b) { return a > b ? a : b; }

int v[MaxN], f[MaxN], cnt[20], xr[MaxN];
int main()
{
	int n, ans = 0, state = 0; read(n);
	for (int i = 1, x, y, z; i < n; ++ i) read(x, y, z), v[x] ^= z, v[y] ^= z;
	for (int i = 0; i < n; ++ i) ++ cnt[v[i]];
	for (int i = 1; i <= 15; ++ i)
	{
		ans += cnt[i] >> 1;
		state |= (cnt[i] & 1) << (i - 1);
	}
	for (int i = 1; i < (1 << 15); ++ i) f[i] = f[i >> 1] + (i & 1);
	for (int i = 1; i < (1 << 15); ++ i) -- f[i];

	for (int i = 1; i < (1 << 15); ++ i)
		for (int j = 0; j < 15; ++ j)
			if ((i >> j) & 1) xr[i] ^= (j + 1);
	for (int s = 1; s < (1 << 15); ++ s)
	{
		if (xr[s] != 0) continue;
		for (int t = (s - 1) & s; t; t = (t - 1) & s)
			if (xr[t] == 0) chkMin(f[s], f[t] + f[t ^ s]);
	}
	write(ans + f[state], '\n');
	IO::flush();
	return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a >= b && a >= c)
  {
    cout << b + c << endl;
  }
  else if(b >= a && b >= c)
  {
    cout << a + c << endl;
  }
  else
  {
    cout << a + b << endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 0; i < 4; ++i) {
        int t, n;
        cin >> t >> n;
        if (t == 1) {
            cout << 6000 * n << '\n';
        } else if (t == 2) {
            cout << 4000 * n << '\n';
        } else if (t == 3) {
            cout << 3000 * n << '\n';
        } else {
            cout << 2000 * n << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3180
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	x1, y1, x2, y2 := scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)
	base := vec{x: x1, y: y1}
	dv := vec{x: x2 - x1, y: y2 - y1}
	orDv := orthogonal(dv)
	p3 := add(add(base, dv), orDv)
	p4 := add(base, orDv)
	fmt.Println(p3.x, p3.y, p4.x, p4.y)
}

type vec struct{ x, y int }

func add(v1, v2 vec) vec {
	return vec{x: v1.x + v2.x, y: v1.y + v2.y}
}

func orthogonal(v vec) vec {
	return vec{x: -v.y, y: v.x}
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 1784
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 924844033;
int n, k;
long long fac[2001];
long long comb[2001][2001];
long long p[2001];
long long cur[2001];
long long nxt[2001];

void init() {
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i-1] * i % MOD;
  comb[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++)
      comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
  }
}

void calc(int x) {
  int maxv = x/2;
  REP (i, maxv+1) p[i] = comb[x-i][i];
  REP (i, n+1) nxt[i] = 0;
  REP (i, n+1) for (int j = 0; j <= maxv && i+j <= n; j++)
    nxt[i+j] = (nxt[i+j] + cur[i] * p[j]) % MOD;
  REP (i, n+1) cur[i] = nxt[i];
}

long long solve() {
  cur[0] = 1;
  REP (i, k) {
    int v = i;
    int cnt = 0;  // # of node
    while (v < n) {
      ++cnt;
      v += k;
    }
    calc(cnt);  // start from left node
    calc(cnt);  // start from right node
  }

  long long ret = fac[n];
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      ret -= cur[i] * fac[n-i] % MOD;
    else
      ret += cur[i] * fac[n-i] % MOD;
    ret = (ret % MOD + MOD) % MOD;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  init();
  cout << solve() << endl;
  return 0;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;
LL INF = 1000000007LL;

struct node{
  LL idx;
  LL a;
  LL ans;
  LL parent;
  LL changed_i;
  LL changed_prev_num;
};

vector<LL> dp(300000, INF);

vector<node> nodes;

// key以上の最小
LL binary_search(LL key) {
  LL ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  LL ok = 300001; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
    LL mid = (ok + ng) / 2;

    if (dp[mid]>=key) ok = mid;
    else ng = mid;
  }
  return ok;
}

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

  dp[0] = 0;

  LL N;
  cin >> N;

  REP(i,N){
    LL a;
    cin>> a;
    nodes.push_back({i, a,-1,-1,-1,-1});
  }
  
  vector<vector<LL>> graph(N,vector<LL>(0));
  
  REP(i,N-1){
    LL v,u;
    cin>>v>>u;
    v--;
    u--;
    graph[v].push_back(u);
    graph[u].push_back(v);
  }

  stack<LL> st;
  st.push(0);

  LL ans = 0;
  node prev_node;

  while(!st.empty()){
    LL idx = st.top();
    st.pop();

    // cout << idx << endl;

    if(idx!=0){
      while(prev_node.idx!=nodes[idx].parent){
        dp[prev_node.changed_i] = prev_node.changed_prev_num;
        prev_node = nodes[prev_node.parent];
        ans = prev_node.ans;
      }
    }

    LL bs = binary_search(nodes[idx].a);
    nodes[idx].changed_i = bs;
    nodes[idx].changed_prev_num = dp[bs];
    if(dp[bs] == INF){
      ans++;
    }
    nodes[idx].ans = ans;
    dp[bs] = nodes[idx].a;
    
    REP(i,graph[idx].size()){
      LL next_idx = graph[idx][i];
      if(nodes[next_idx].ans == -1){
        st.push(next_idx);
        nodes[next_idx].parent = idx;
      }
    }

    prev_node = nodes[idx];
  }
  
  REP(i,nodes.size()){
    cout << nodes[i].ans << endl;
  }
}


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

tmp1 = 0
sum1 = 0
tmp2 = 0
sum2 = 0

for i in range(n):
    sum1 += a[i]
    if i % 2 == 0:
        if sum1  > 0 :
            pass
        else:
            tmp1 += 1 - sum1
            sum1 =  1
    else:
        if sum1  < 0 :
            pass
        else:
            tmp1 += sum1 - (-1)
            sum1 =  -1

for i in range(n):
    sum2 += a[i]
    if i % 2 == 1:
        if sum2  > 0 :
            pass
        else:
            tmp2 += 1 - sum2
            sum2 =  1
    else:
        if sum2  < 0 :
            pass
        else:
            tmp2 += sum2 - (-1)
            sum2 =  -1

ans = min(tmp1, tmp2)
print(ans)

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

for i in range(n-k):
#  print(a[k+i],a[i])
#  if a[n-k+1+i]>a[i]:
  if a[k+i]>a[i]:
    print('Yes')
  else:
    print('No')
  


Measured memory_bytes: 31432
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
#define MAX 200000
#define rep(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define IN(n) scanf("%d",&n);
#define OUT(n) printf("%d\n",n);
#define IN2(n,k) scanf("%lf%lf",&n,&k);
#define OUT2(n,k) printf("%d%d\n",n,k);
#define IN3(n,k,s) scanf("%d%d%d",&n,&k,&s);
#define OUT3(n,k,s) printf("%d%d%d\n",n,k,s);

int main(){
    char a[101],b[101];
    cin>>a>>b;
    if(strlen(a)>strlen(b)){
        cout<<"GREATER"<<endl;
        return 0;
    }
    else if(strlen(b)>strlen(a)){
        cout<<"LESS"<<endl;
        return 0;
    }
    else {
        rep(i,strlen(a)){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }
            else if (a[i]<b[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    priority_queue< double, std::vector<double>, std::greater<double> > q;
    for(int i=1;i<=N;i++){
        int v;
        cin >> v;
        q.push(v);
    }
    for(int i=0;i<N-1;i++){
        double a,b;
        a = q.top();
        q.pop();
        b = q.top();
        q.pop();
        q.push((a+b)/2.0);
    }
    double ans = q.top();
    q.pop();
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class PrimeNumberCalculator {
    using ull = unsigned long long;
public:
    PrimeNumberCalculator(const ull& n_max) :
        list_(generateList(std::sqrt(n_max))) { }

    const std::vector<ull>& getList() const {
        return list_;
    }

    bool check(const ull& n) const {
        ull n_max = std::sqrt(n);
        for(const auto& v : list_) {
            if(n_max < v) {
                break;
            }
            else if(n % v == 0) {
                return false;
            }
        }
        return true;
    }

    std::map<ull, ull> generatePrimeFactorizationMap(ull n) const {
        std::map<ull, ull> prime_cnt_map;
        ull n_max = std::sqrt(n);
        for(const auto& v : list_) {
            if(n_max < v) {
                break;
            }
            while(n % v == 0) {
                n /= v;
                auto itr = prime_cnt_map.find(v);
                if(itr != prime_cnt_map.end()) {
                    itr->second++;
                }
                else {
                    prime_cnt_map.insert(make_pair(v, 1));
                }
            }
        }
        if(1 < n) {
            prime_cnt_map.insert(make_pair(n, 1));
        }
        return prime_cnt_map;
    }

    ull calcNumOfDivisor(ull n) const {
        ull  num = 1;
        auto map = generatePrimeFactorizationMap(n);
        for(const auto& v : map) {
            num *= (v.second + 1);
        }
        return num;
    }

    ull calcSumOfDivisor(ull n) const {
        ull sum   = 1;
        auto map = generatePrimeFactorizationMap(n);
        for(const auto& v : map) {
            ull t     = 1;
            ull t_sum = 1;
            for(ull i = 0; i < v.second; i++) {
                t     *= v.first;
                t_sum += t;
            }
            sum *= t_sum;
        }
        return sum;
    }

private:
    const std::vector<ull> list_;

    std::vector<ull> generateList(const ull& n_max) const {
        std::vector<uint> table(n_max + 1, 0);
        std::vector<ull> list;
        for(ull i = 2; i <= n_max; i++) {
            if(table[i] == 0) {
                list.push_back(i);
                for(uint j = i; j <= n_max; j+=i) {
                    table[j] = 1;
                }
            }
        }
        return list;
    }
};

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

    int N;
    std::cin >> N;
    vector<ll> list(N + 1, 0);
    for(int i = 2; i <= N; i++) {
        PrimeNumberCalculator p(i);
        auto map = p.generatePrimeFactorizationMap(i);
        for(const auto& v : map) {
            list[v.first] += v.second;
        }
    }

    auto ans = 1;
    for(const auto& v : list) {
        ans = (ans * (v + 1)) % MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 200000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
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; }



int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) {
		cin >> A.at(i);
	}
	ll ans = 0;
	int MAXnum = 0;
	rep(i, N) {
		MAXnum = max(MAXnum, A[i]);
		int tmp = MAXnum;
		ans += tmp - A[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    string s;
    cin>>s;
    int dig=0;
    int n=s.length();
    rep(i,n){
        dig += s[i]-'0';
    }
    YN(dig%9==0);
}

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

using usize = ::std::size_t;
//using u64 = ::std::uint_least64_t;
typedef int u64;
//static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
const int Inf = 0x3f3f3f3f;

u64 N, V, E;
u64 dp[1 << 16][16], g[16][16];

u64 dfs(int mask , int u){
    
    
    if (mask == (1 << V) - 1) {
        return g[u][0];
    }
    
    if (~dp[mask][u]) return dp[mask][u];
    
    u64 r = Inf;
    
    for (int v = 0; v < V; v++) {
        if (v != u && !(mask & (1 << v))) {
            r = min(r, g[u][v] + dfs(mask | (1 << v), v));
        }
    }
    
    return dp[mask][u] = r;
    
}

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> V >> E;
    memset(g, Inf, sizeof(g));
    for (int i = 0; i < E; i++) {
        u64 v1, v2;
        cin >> v1 >> v2;
        cin >> g[v1][v2];
    }
    memset(dp, -1, sizeof(dp));
    
    dfs(1, 0);
    
    if (dp[1][0] >= Inf) {
        cout << -1 << endl;
    } else {
        cout << dp[1][0] << endl;
    }
    
    
    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int sum[1002]={};
    REAP(i,1,1002)sum[i]=sum[i-1]+i;
    int n;
    while(cin >> n,n){
        int cou=0;
        REAP(i,2,n){
            REAP(j,0,i){
                if(sum[i]-sum[j]==n)cou++;
            }
        }
        cout << cou << endl;
    }
}



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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
int n,m,cnt;
int f[MAXN];
int find(int x){
	if(x == f[x])
	    return x;
	else
	    return f[x] = find(f[x]);
}
int main()
{
	cin>>n>>m;
	for(int i = 1;i <= n;i++)
	    f[i] = i;	
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fx = find(x);
		int fy = find(y);
		if(fx != fy){
			f[fx] = fy;
			cnt++;
		}
	}
	cout<<n-cnt<<endl;
}

Measured memory_bytes: 768
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X = int(input())

x = 100
ans = 0
while X > x:
    x = math.floor(x * 1.01)
    ans += 1
print(ans)

Measured memory_bytes: 10956
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; ll X; cin >> N >> X; ll a[2*N];
  rep(i, N) cin >> a[i];
  for(int i=N; i<2*N; i++){
    a[i] = a[i-N];
  }
  ll ans = longinf; ll mi[N];
  rep(i, N) mi[i] = a[i];
  rep(i, N){
    ll tmp = 0;
    rep(j, N){
      mi[j] = min(mi[j], a[j+N-i]);
    }
    rep(j, N){
      tmp+=mi[j];
    }
    tmp+=i*X;
    ans=min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    readln.split.map!(s => s.front.toUpper).writeln;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,cntB=0,cntA=0,cnt=0,cntAB=0;
  cin >> n;
  string s;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(s[0]=='B'&&s[s.size()-1]=='A') {
      cntAB++;
    }
    else if(s[0]=='B') {
      cntB++;
    }
    else if(s[s.size()-1]=='A') {
      cntA++;
    }
    for(int j=0; j<s.size()-1; j++) {
      if(s[j]=='A'&&s[j+1]=='B') {
        cnt++;
      }
    }
  }
  if(cntAB==0) {
    cout << cnt+min(cntB,cntA) << endl;
    return 0;
  }
  if(cntAB!=0&&cntA+cntB>0) {
    cout << cnt+cntAB+min(cntA,cntB) << endl;
    return 0;
  }
  if(cntAB!=0&&cntA+cntB==0) {
    cout << cnt+cntAB-1 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[100][2];
int at[100];
int wolf[200];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			scanf("%s%d",str[i],at+i);
		}
		for(int t=1;;t++){
			for(int i=0;i<b;i++)wolf[i]=0;
			for(int i=0;i<a;i++){
				if(str[i][0]=='L'){
					at[i]--;
					if(at[i]>0)wolf[at[i]]++;
				}else{
					at[i]++;
					if(at[i]<b)wolf[at[i]]++;
				}
			}
			for(int i=0;i<a;i++){
				if(0<at[i]&&at[i]<b&&wolf[at[i]]>1){
					if(str[i][0]=='L')str[i][0]='R';
					else str[i][0]='L';
				}
			}
			bool ok=true;
			for(int i=0;i<a;i++){
				if(at[i]>0&&at[i]<b){
					ok=false;
				}
			}
			if(ok){
				printf("%d ",t);
				int l=-1;
				int r=-1;
				for(int i=0;i<a;i++){
					if(at[i]==0)l=i;
					if(at[i]==b)r=i;
				}
				if(~l)printf("%d\n",l+1);
				else printf("%d\n",r+1);
				break;
;			}
		}
	}
}

Measured memory_bytes: 1028
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")

# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define FILE

using namespace std;

const int N = 1e5 + 7;

int n, k, q, a[N], x;

int main()
{
    /// Author: Dilshod--Imomov
    speed;
    #ifdef FILEx
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // FILE
    cin >> n >> k >> q;
    for ( int i = 0; i < q; i++ ) {
        cin >> x;
        a[x]++;
    }
    for ( int i = 1; i <= n; i++ ) {
        string ans = "No";
        if ( (k - q) + a[i] > 0 ) ans = "Yes";
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long v,n,a,i,j,k,x;
double d[]={0.25,0.5,1,2};
vector<pair<long long,double> >V;
main(){
  for(;i<4;V.push_back({v,d[i++]}))cin>>v;
  for(cin>>n;j<4;++j)for(i=3;i>j;--i)if(V[i-1].first/V[i-1].second>V[i].first/V[i].second)swap(V[i-1],V[i]);
  for(;k<4&&n;++k){
    x=n/V[k].second;
    a+=x*V[k].first;
    n-=x*V[k].second;
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> White(100, vector<bool>(100, false));
vector<vector<int>> Steps(100, vector<int>(100, 100000));
int H, W;

void search(int h, int w, int prevStep, bool prevBlack)
{
  if (h >= H || w >= W)
    return;
  if (Steps.at(h).at(w) <= prevStep)
    return;
  if (White.at(h).at(w))
  {
    Steps.at(h).at(w) = prevStep;
    search(h, w + 1, prevStep, false);
    search(h + 1, w, prevStep, false);
  }
  else
  {
    if (prevBlack)
    {
      Steps.at(h).at(w) = prevStep;
      search(h, w + 1, prevStep, true);
      search(h + 1, w, prevStep, true);
    }
    else
    {
      Steps.at(h).at(w) = prevStep + 1;
      search(h, w + 1, prevStep + 1, true);
      search(h + 1, w, prevStep + 1, true);
    }
  }
}

int main()
{
  cin >> H >> W;
  char g;
  for (int r = 0; r < H; r++)
  {
    for (int c = 0; c < W; c++)
    {
      cin >> g;
      if (g == '.')
        White.at(r).at(c) = true;
    }
  }
  search(0, 0, 0, false);
  cout << Steps.at(H - 1).at(W - 1) << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int X = sc.nextInt();
		String ans = "NO";
		if (X == 3 || X == 5 || X == 7) {
			ans = "YES";
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 21076
import Data.List
import Control.Monad

main = do
  [n, m] <- map read . words <$> getLine
  ks <- map (tail . map read . words) <$> replicateM m getLine :: IO [[Int]]
  ps <- map read . words <$> getLine :: IO [Int]
  print $ solve n ks ps

solve n ks ps = sum $ do
  t <- replicateM n [0, 1]
  forM_ (zip ks ps) $ \(s, p) -> do
    guard $ (sum (map ((t !!) . subtract 1) s) `rem` 2) == p
  return 1

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long m = sc.NextLong();

        long[] counts = new long[n + 1];

        for (long i = 0; i < m; i++)
        {
            long a = sc.NextLong();
            long b = sc.NextLong();
            counts[a]++;
            counts[b]++;
        }

        string answer = counts.Where(c => c % 2 != 0).Count() == 0 ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 43928
from math import gcd
from itertools import combinations


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p**.5) + 1):
        if p % i == 0:
            return False
    return True


a, b = map(int, input().split())
se = set(make_divisors(a)) & set(make_divisors(b))
ans = 1
for i in se:
    if is_prime(i):
        ans += 1
print(ans)


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

// Shabdan Batyrkulov

using namespace std;

#define MAX 1007
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double
#define vi vector <int>
#define pii pair <int, int>
#define OK puts("OK");

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
   
int main () {     
	int a, b; cin >> a >> b;
	if (a + b >= 10) {
		cout << "error";
	} else {
		cout << a + b;
	}                    
}


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

#define maxsiz 1000000
#define F first
#define S second
#define fr(i,k,n) for(int i = k ; i < n ; i++ )
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define printvect(a,n) fr(i,0,n) cout << a[i] << " " ;
#define point pair<int,int>
#define pii pair<int,int>
#define pib pair<int,bool>
#define arr vector<int> 
#define vectin(a,n) fr(i,0,n) { cin >> a[i] ; }
typedef unsigned long long int ull;

vector<int> getMult(int s,int n)
{
	vector<int> a(n);
	int current = 0 ;

	a[n-1] = current ;
	int i = n-2;
	while(s!=0 || i >= 0)
	{
		if(s%2==1) //+
			current = 0 ;
		else //No +
			++current;
		a[i] = current  ;
		i--;
		s /= 2;
	}
	return a;
}


int main()
{
	string s;
	cin >> s ;
	vector<int> a(s.length());

	fr(i,0,s.length())
		a[i] = (int)(s[i]-'0') ; 

	ull total = 0;
	fr(i,0,pow(2,s.length()-1))
	{
		ull tmp = 0 ;
		vector<int> curr = getMult(i,s.length());
		fr(j,0,s.length())
			tmp += a[j]*pow(10,curr[j]);
		total += tmp;
	}
	cout << total << endl ;
}

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

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--){
        ll n,x,t;
        cin>>n>>x>>t;
        ll y=(n+x-1)/x;
        cout<<y*t;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(1)==S.at(2)){
    cout << "No" << endl;
  }else if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)){
    cout << "Yes" << endl;
  }else if(S.at(0)==S.at(2)&&S.at(1)==S.at(3)){
    cout << "Yes" << endl;
  }else if(S.at(0)==S.at(3)&&S.at(1)==S.at(2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
H,W=map(int,input().split())
S=["."]*(W+2)
S=[["."]*(W+2)] + [list("."+input()+".") for _ in range(H)] + [["."]*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == "#":
            print("#",end="")
        else:
            print((S[i-1][j-1]+S[i-1][j]+S[i-1][j+1]+S[i][j-1]+S[i][j+1]+S[i+1][j-1]+S[i+1][j]+S[i+1][j+1]).count("#"),end="")
    print()

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

int main()
{
	int x;
	int i = 0;
	while(1)
	{
		i+= 1;
		cin >> x;
		if(x==0)
		{
			break;
		}

		cout << "Case " << i << ": " << x << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC157D();

#if 1
int main()
{
	ABC157D();
	fflush(stdout);
	return 0;
}
#endif

class UnionFindTree
{
protected:
	int* _par = 0;
	int* _rank = 0;
	int* _count = 0;

	void init(int size) {
		_par = new int[size];		//	親ノード
		_rank = new int[size];		//	高さ
		_count = new int[size];		//	結合グループの要素数

		for (int i = 0; i < size; i++) {
			_par[i] = i;
			_rank[i] = 0;
			_count[i] = 1;
		}
	}

public:
	UnionFindTree(int size = 10) {
		init(size);
	}

	~UnionFindTree() {
		delete[] _par;
		delete[] _rank;
		delete[] _count;
	}

	//	木の根を求める
	int find(int x) {
		if (_par[x] == x) {
			return x;
		}
		else {
			return(_par[x] = find(_par[x]));
		}
	}

	//	x と y の属する集合を併合
	void Unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			//	すでに同じ集合だった
			return;
		}

		if (_rank[x] < _rank[y]) {
			//	数をまず加算しておく
			_count[y] = _count[y] + _count[x];
			_par[x] = y;
		}
		else {
			//	数をまず加算しておく
			_count[x] = _count[y] + _count[x];

			_par[y] = x;
			if (_rank[x] == _rank[y]) {
				_rank[x]++;
			}
		}
	}

	bool IsUnion(int x, int y) {
		return (find(x) == find(y));
	}

	int count(int x) {
		return _count[find(x)];
	}
};

static void ABC157D()
{
	int N, M, K;
	getint(N, M, K);

	UnionFindTree uf(N);

	std::vector<std::set<int>> fr(N), br(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		getint(a, b); a--; b--;
		fr[a].insert(b);
		fr[b].insert(a);
		uf.Unite(a, b);
	}

	for (int i = 0; i < K; i++) {
		int a, b;
		getint(a, b); a--; b--;
		if (uf.IsUnion(a, b)) {
			br[a].insert(b);
			br[b].insert(a);
		}
	}

	std::string ans;
	for (int i = 0; i < N; i++) {
		char tmp[16] = { 0 };
		sprintf(tmp, "%d", uf.count(i) - fr[i].size() - br[i].size() - 1);
		if (ans.size()) {
			ans += ' ';
		}
		ans += tmp;
	}
	printf("%s\n", ans.c_str());
}


Measured memory_bytes: 30852
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
int main() {
	double N, D;
	cin >> N >> D;
	double num = 2 * D + 1;
	cout << ceil(N/num) << endl;
};

Measured memory_bytes: 256
import fractions
a,b=map(int,input().split())
g=fractions.gcd(a,b)

def prime_factor(n):
    ass = set() 
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.add(i)
            n = n//i
    if n != 1:
        ass.add(n)
    return ass

print(len(prime_factor(g))+1)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a,b,k;

signed main() {
    cin >> a >> b >> k;
    cout << max(0LL, a-k) << " " << max(0LL,min(b,b-(k-a))) << endl;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = int(input())
nums = list(map(int, input().split()))

n_colors = [0, 0, 0]

cnt = 1
for x in nums:
	cnt = (cnt * len([y for y in n_colors if x == y])) % mod
	if cnt == 0:
		break
	n_colors[n_colors.index(x)] += 1

print(cnt)

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

int main(){
  int N; cin>>N;
  ll sum=0, mi=1e10;
  rep(i,N){
    ll A,B; cin>>A>>B;
    if(A>B) mi=min(mi,B);
    sum+=A;
  }
  if(mi==1e10) cout<<0<<endl;
  else cout<<sum-mi<<endl;
  return 0;
}


Measured memory_bytes: 256