akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import queue
import copy
import bisect#2分探索
from collections import deque #popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

ss = input()
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から4未満の位置を返す。rightだと以下
#bisect.insort_left(a, 4)#挿入

#ss=str(S)
# #print(ss)
ls=len(ss)
# l=[0]*(ls+1)

    #print(l[i])
#print(l)

# #優先度付きqueue

kl=[0]*2019
kl[0]=1
# a = [0]
# heapq.heapify(a)  # aを優先度付きキューに

tmp=0
t2=1
for s in reversed(ss):
    tmp=(tmp+int(s)*t2)%2019
    kl[tmp]+=1
    t2=t2*10%2019
    #print(tmp)

#print(a)




ans=0
for k in kl:
    ans+=k*(k-1)//2
print(ans)

# cur=-1
# ans=0
# for i, li in enumerate(l):
#     if cur==-1:
#         cur=li
#         count=1
#     elif li==cur:
#         count+=1
#     else:
#         ans+=count*(count-1)//2
#         cur=li
#         count=1

# print(ans)

Measured memory_bytes: 87448
#include <stdio.h>
#include <stdlib.h>
 
int	main(void)
{
  char buf[10];
  int a, b, c;
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d %d", &a, &b, &c);
  if (a == b && b == c)
  {
    printf("No");
  }
  else if( a != b && b != c && c != a)
  {
    printf("No");
  }
  else
  {
    printf("Yes");
  }
  
  return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string.h>
#include <cstdio>
#include <sstream>
#include <cmath>
using namespace std;

int main() {

    int n;
    cin >> n;

    string s;
    int p;

    vector<pair<pair<string, int>, int>> spi(n);

    for (int i = 0; i < n; i++) {
        cin >> s >> p;
        spi[i] = make_pair(make_pair(s, -p), i);
    }

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

    for (int i = 0; i < n; i++) {
        cout << spi[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    int l = Integer.parseInt(sc.next());
    int r = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    sc.close();
    
    System.out.println( r/d - (l-1)/d );
  }
}

Measured memory_bytes: 35352
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int A[101] = {};
	int count[101] = {};
	int save;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		A[i] = i;
		if (i % 2 == 0) {
			
			count[i]++;
			save = i;
			while(1) {
				save = save / 2;
				if (save % 2 == 0) {
					count[i]++;
				}
				else {
					break;
				}

			}
		}
	}
	int p = -1;
	for (int i = 1; i <= N;i++) {
		if (p<count[i]) {
			p = count[i];
		}
	}
	for (int i = 1; i <= N;i++) {
		if (p == count[i])cout << A[i] << endl;

	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const ll MAX_N = 1e5 + 10;

vector<int> es[MAX_N];

int x[MAX_N];
int y[MAX_N];

void dfs(int now, int par, int a, int dist) {
	dump(now);
	for(auto& to :es[now]) {
		if(to == par) continue;
		if(a == 0) {
			x[to] = dist+1;
		}
		else y[to] = dist+1;
		dfs(to, now, a, dist+1);
	}
}

int main(){
	int n;
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	dfs(0, -1, 0, 0);
	dfs(n-1, -1, n-1, 0);
	x[0] = 0;
	y[n-1] = 0;
	int s = 0, f = 0;
	rep(i, n) {
		if(x[i] <= y[i]) f++;
		else s++;
	}
	// rep(i, n) cout << " " << x[i];cout << endl;
	// rep(i, n) cout << " " << y[i];cout << endl;

	dump(f);dump(s);dump(w);
	cout << (f > s ? "Fennec" : "Snuke") << endl;

}


Measured memory_bytes: 12800
#union-find-tree
def init(n):
    lis = []
    for i in range(n+1):
        lis.append(i)
    return lis
def find(lis, x):
    if lis[x] == x:
        return x
    else:
        lis[x] = find(lis, lis[x])
        return lis[x]
def sameset(lis, x, y):
    return find(lis, x) == find(lis, y)
def union(lis, x, y):
    x = find(lis, x)
    y = find(lis, y)
    if x != y:
        lis[x] = y

N, M = map(int, input().split())
input_lis = [0]+[int(p) for p in input().split()]
union_find_lis = init(N)
for _ in range(M):
    x, y = map(int, input().split())
    union(union_find_lis, x, y)
count = 0
init_flag = True
for index, num in enumerate(input_lis):
    if init_flag:
        init_flag = False
    else:
        if sameset(union_find_lis, index, num):
            count += 1
print(count)

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

using namespace std;
using ll = long long;

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    int count =0;
    vector<int> ret(max(a,b));
    for(int i=1;i<=100;++i){
        if(a<i || b <i )break;
        if(a%i==0 && b%i==0){
            ret[count++] = i;
        }
    }
    sort(ret.rbegin(),ret.rend());
    cout << ret[k-1] << endl;
    return 0;
}



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

int main() {
    int x;cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3588
from collections import deque

n=int(input())

result=deque([])

for _ in range(n):
	temp=input().split()
	if temp[0]=="insert":
		result.appendleft(temp[1])
	elif temp[0]=="delete":
		if temp[1] in result:
			result.remove(temp[1])
	elif temp[0]=="deleteFirst":
		result.popleft()
	elif temp[0]=="deleteLast":
		result.pop()
print(" ".join(result)) 


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

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<lli> a(N);
	lli left = 0, right = 0;
	lli diff = 0;
	rep(i, 0, N) {
		cin >> a[i];
		right += a[i];
		diff += abs(a[i]);
	}

	rep(i, 0, N - 1) {
		right -= a[i];
		left += a[i];
		diff = min(abs(right - left), diff);
	}

	cout << diff << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[2][n];
    for(int i = 0;i < 2;i++)
    {
        for(int j = 0;j < n;j++)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int sum = 0;
        for(int j = 0;j < n;j++)
        {
            if(j <= i)
            {
                sum += a[0][j];
            }
            else
            {
                sum += a[1][j];
            }
        }
        sum += a[1][i];
        if(sum > ans)
        {
            ans = sum;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
from itertools import starmap


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


q = int(input())
while q:
    q -= 1
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, input().split())] * 2))
    max_x1, min_x1 = (p0.real, p1.real) if p0.real > p1.real else (p1.real, p0.real)
    max_y1, min_y1 = (p0.imag, p1.imag) if p0.imag > p1.imag else (p1.imag, p0.imag)
    max_x2, min_x2 = (p2.real, p3.real) if p2.real > p3.real else (p3.real, p2.real)
    max_y2, min_y2 = (p2.imag, p3.imag) if p2.imag > p3.imag else (p3.imag, p2.imag)
    if any((max_x1 < min_x2, max_x2 < min_x1, max_y1 < min_y2, max_y2 < min_y1)):
        print(0)
        continue

    print(int(cross(p1 - p0, p2 - p0) * cross(p1 - p0, p3 - p0) < 1e-6 and
              cross(p3 - p2, p0 - p2) * cross(p3 - p2, p1 - p2) < 1e-6))

Measured memory_bytes: 7792
import java.util.Scanner;



class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int N = sc.nextInt();

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

    		if(i%2==0){
    			if(A%2!=0){
    			A--;
    			}
    			A/=2;
    			B+=A;
    			}
    		else{
    			if(B%2!=0){
    				B--;
    				}
    				B/=2;
    				A+=B;

    		}

    	}

    	System.out.println(A+" "+ B);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <set>

using namespace std;

void solve()
{
	unsigned long long int N;
	cin >> N;
	int ans = 1e9;
	for (unsigned long long int i = 1; i * i <= N; ++i)
	{
		if (N % i == 0)
		{
			unsigned long long int temp = N / i;
			int cnt = 0;
			while (temp)
			{
				++cnt;
				temp /= 10;
			}
			if (ans > cnt)
			{
				ans = cnt;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		String[] a = new String[h];
		for (int i = 0; i < h; i++) {
			a[i] = scan.next();
		}
		String b = "";
		for (int i = 0; i <w+ 2; i++) {
			b = b+"#";
		}
		System.out.println(b);
		for (int i = 0; i < h; i++) {
			System.out.println("#"+a[i]+"#");
		}
		System.out.println(b);
	}
}


Measured memory_bytes: 22736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BSortingASegment {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;

        vector<int> p(N);
        REP(i, N) cin >> p[i];
        set<int> s;
        REP(i, K) s.insert(p[i]);

        int res = 1;
        int r = K;
        while (r < N) {
            int l = r - K;
            bool change = false;
            if (p[l] != *s.begin()) change = true;
            if (p[r] < *s.rbegin()) change = true;
            if (change) res++;
            s.erase(p[l]);
            s.insert(p[r]);
            r++;
        }

        int k = 0;
        int cur = 1;
        FOR(i, 1, N - 1) {
            if (p[i] > p[i - 1]) {
                cur++;
            } else {
                if (cur >= K) k++;
                cur = 1;
            }
        }
        if (cur >= K) k++;
        if (k > 1) res -= k - 1;
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BSortingASegment solver;
    solver.solve(in, out);
    return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    int n;
    cin>>n;
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            int x=i*i*i*i*i;
            int y=j*j*j*j*j;
            if(x-y==n){
                cout<<i<<" "<<j<<endl;
                return;
            }
        }
    }
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

const double INF = 1e20;

double calc(double h, double x, double y) {
  if (x < h) {
    if (y < h) {
      return ((h - x) + (h - y)) / 2;
    } else {
      return (pow(h - x, 2) + pow(y - h, 2)) / (y - x) / 2;
    }
  } else {
    if (y < h) {
      return (pow(x - h, 2) + pow(h - y, 2)) / (x - y) / 2;
    } else {
      return ((x - h) + (y - h)) / 2;
    }
  }
}

int main(void) {
  ll N;
  cin >> N;
  vector<ll> H(N);
  REP(i, 0, N) cin >> H[i];

  vector<double> dp1(1000, INF), dp2(1000);
  dp1[1] = 0;
  REP(i, 0, N) {
    REP(j, 0, 1000) dp2[j] = INF;
    REP(j, 1, 1000) {
      REP(k, 1, 1000) {
        dp2[k] = min(dp2[k], dp1[j] + calc(H[i], j, k));
      }
    }
    swap(dp1, dp2);
  }

  double ans = INF;
  REP(i, 1, 1000) ans = min(ans, dp1[i]);
  printf("%.15lf\n", ans);
}


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

int main(){
	int a, b, c;
	int i;
	int num=0;
	
	cin >> a >> b >> c;
	
	for(i=a;i<=b;i++){
		if(c%i==0)
			num++;
	}
	
	cout << num << endl;
	
	return 0;
}

Measured memory_bytes: 1164
package main

import(
	"fmt"
)

func main() {

	var numstr string
	
	for {
		fmt.Scan(&numstr)
		if numstr=="0" {
			break
		}

		rnumstr := []rune(numstr)

		tot := 0
		for _, rnumchar := range rnumstr {
			//fmt.Println(string(rnumchar))
			tot += int(rnumchar) - int(rune('0'))
		}
		fmt.Println(tot)
	}
}


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

int main() {
    int n, k; scanf("%d%d", &n, &k);
    double sum = 0, ret = 0;
    vector<double> p(n);
    for (int i = 0; i < k-1; i++) {
        scanf("%lf", &p[i]);
        p[i] = (1+p[i])/2;
        sum += p[i];
    }
    for (int i = k-1; i < n; i++) {
        scanf("%lf", &p[i]);
        p[i] = (1+p[i])/2;
        sum += p[i];
        ret = max(ret, sum);
        sum -= p[i-k+1];
    }
    printf("%1.10lf\n", ret);
    return 0;
}

Measured memory_bytes: 4812
//https://atcoder.jp/contests/abc163/tasks/abc163_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  double R; cin>>R;
  double ans=2*M_PI*R;
  cout<<fixed<<std::setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3784
N = int(input())
A = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

X = [0]*N
Y = [0]*N

for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])

Z = [0]*N
for i in range(N):
    Z[i]=gcd(X[i],Y[i])
print(max(Z))

Measured memory_bytes: 14432
#include <stdio.h>

int main(void){
   
   int a[3];
   int i, j, d;

   scanf("%d %d %d", &a[0], &a[1], &a[2]);

   for (i = 0; i < 2; i++){
      for (j = 0; j < 2; j++){
        if (a[j] > a[j+1]){
            d = a[j];
            a[j] = a[j+1];
            a[j+1] = d;
        }
      }
   }

   printf("%d %d %d\n", a[0], a[1], a[2]);

   return 0;
}



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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == 5 && B == 5 && C == 7)
    {
        cout << "YES" << endl;
    }
    else if (A == 5 && B == 7 && C == 5)
    {
        cout << "YES" << endl;
    }
    else if (A == 7 && B == 5 && C == 5)
    {
        cout << "YES" << endl;
    } else 
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3492
import java.util.Scanner;
import java.util.List;
import java.util.Arrays;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int pos[] = new int[n + 1];
        int posDiff[] = new int[n];
        
        for(int i = 0; i < n; i++){
            pos[i] = sc.nextInt();
        }
        pos[n] = x;
        Arrays.sort(pos);
        for(int i = 1; i < n + 1; i++){
            posDiff[i - 1] = pos[i] - pos[i - 1];
        }
        
        int r = posDiff[0];
        for(int i = 1; i < n; i++){
            int mod = 1;
            int x1 = r;
            int x2 = posDiff[i];
            int x3 = 0;
            while(mod != 0){
                int tmp = x1;
                if(x1 < x2){
                    x1 = x2;
                    x2 = tmp;
                }
                r = x1 / x2;
                mod = x1 % x2;
                x3 = x2;
                x1 = x2;
                x2 = mod;
            }
            r = x3;
        }

        System.out.println(r);
    }
}


Measured memory_bytes: 51836
// minpro2019_C
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    ll K, A, B;
    cin >> K >> A >> B;
    
    // calculation
    if (K == 1) {
        // ビスケットを叩いて＋１で２枚
        cout << 2 << "\n";
    } else if (K == 2) {
        // たたくのみ or 1回交換する
        // B = 1 でも良い．どうせ増やせないから
        cout << std::max(ll(1+2), B) << "\n";
    } else if (K >= 3){
        ll bis = 1;
        if (K < A - bis + 2) {
            // 1回も交換できないとき
            cout << 1 + K << "\n";
        } else if (K == A - bis + 2) {
            // ぴったり1回だけ交換できるとき
            cout << max(1+K, B) << "\n";
        } else {
            // 1回以上交換できるとき
            // 1回目
            bis = max(1 + (A-1) + 2, B);
            K -= (A - 1) + 2;
            
            // 2回目以降
            if (A + 2 >= B) {
                // 交換が得じゃないとき
                cout << bis + K << "\n";
            } else {
                // 交換が得なとき: (A + 2) < B
                ll max_times, nokori, possible_times;
                while (K >= 2) {
                    max_times = bis/A;  // 何回交換できるか
                    nokori = A - bis%A;
                    if (K >= max_times*2) {
                        bis += max_times*(B - A);
                        K -= 2 * max_times;  // 交換には２倍の回数が必要
                        
                    } else {
                        bis += (K/2)*(B-A);
                        K -= 2 * (K/2);
                        
                        bis += K%2;
                        K -= K%2;
                    }
                }
                
                // K = 1 or 0
                cout << bis + K << "\n";
                
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

bool flag;
int i, j, n, f, b;
string x, s;

int main()
{
    sf("%d", &n);
    cin >> x;
    s = x;
    for (i = n-1; i >= 0; i--) {
        if (s[i] == '1') continue;
        else if (s[i] == '(') b++;
        else {
            flag = false;
            for (j = i-1; j >= 0; j--) {
                if (s[j] == '(') {
                    s[j] = '1';
                    flag = true;
                    break;
                }
            }
            if (flag == false) f++;
        }
    }
    s = "";
    while (f--) s += '(';
    s += x;
    while (b--) s += ')';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll A, B, C;
    scanf("%lld %lld %lld", &A, &B, &C);
    if(B-A==C-B) printf("YES\n");
    else printf("NO\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define int long long
#define mod 1000000007
int n,k,ans,dp[1001000],p[1001000],cnt;
int quickpow(int x,int y){
	if(y==0)return 1;
	if(y==1)return x;
	if(y%2==0)return quickpow(x*x%mod,y/2);
	if(y%2==1)return quickpow(x*x%mod,y/2)*x%mod;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i*i<=n;i++)
		if(n%i==0){
			p[++cnt]=i;;
			if(i*i!=n)p[++cnt]=n/i;
		}
	std::sort(p+1,p+cnt+1);
	for(int i=1;i<=cnt;i++){
		dp[i]=quickpow(k,(p[i]+1)/2);
		for(int j=1;j<i;j++)
			if(p[i]%p[j]==0)dp[i]=(dp[i]-dp[j]+mod)%mod;
		if(p[i]%2==0)(ans+=dp[i]*p[i]/2%mod)%=mod;
		else(ans+=dp[i]*p[i]%mod)%=mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2176
# import itertools
# import math
# import sys
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()


A = np.array(list(map(int, input().split())))

print('YNEOS'[len(A) != len(np.unique(A))::2])

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if (a<b){
        if (b<c){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
    string str;
    cin>>str;
    int cc1=0,cc2=0;
    for(int i=0;i<3;i++){
        if(str[i]=='A')cc1++;
        else{
            cc2++;
        }
    }
    if(cc1&&cc2){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}

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

int n;
char a[1000];

int main(){
	cin>>n;
	bool flag=false;
	for (int i=0;i<n;i++) {
		cin>>a[i];
		if (a[i]=='Y') flag=true;
	}
	if (flag) cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  string S[n];
  for (int i = 0; i < n; i++)
    cin >> S[i];
  int al[26];
  for (int i = 0; i < 26; i++)
    al[i] = 51;
  for (int i = 0; i < n; i++)
  {
    int al_tmp[26] = {};
    for (int j = 0; j < S[i].length(); j++)
    {
      char c = S[i][j];
      al_tmp[c - 'a']++;
    }
    for (int i = 0; i < 26; i++)
      al[i] = min(al[i], al_tmp[i]);
  }
  string ans = "";
  for (int i = 0; i < 26; i++)
  {
    for (int j = 0; j < al[i]; j++)
      ans += (char)(i + 'a');
  }
  sort(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

void solve(std::string X) {
  int tmp = 0;
  int tmp1 = 0;
  for(int i= 0;i<X.size();i++){
    if(X[i] == 'T'){
      if(tmp1 == 0)tmp++;
      else tmp1++;
    }
    else tmp1--;
  }
  cout<<tmp-tmp1;;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string X;
  std::cin >> X;
  solve(X);
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    size_t len = S.length();

    int amari[2019] = {};
    amari[0]++;
    uint64_t Ti(0),t(1);
    for (size_t i = 0; i < len; ++i)
    {
        int a = S[i]-'0';
        Ti = (a * t + Ti) % 2019;
        t = t * 10 % 2019;
        amari[Ti]++;
    }
    uint64_t ans(0);
    for (size_t i = 0; i < 2019; ++i)
        ans += (uint64_t)amari[i]*(amari[i]-1)*0.5;
    cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3376
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll f[20][20][20][20];
ll a[20];
ll dfs(int l,int r,int x,int y) {
	if(l+1>=r) return 0;
	ll ans=1e18;
	for(int i=l+1;i<r;i++) {
		ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
	}
	return f[l][r][x][y]=ans;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	memset(f,-1,sizeof f);
	printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
using namespace std;
long long int A,B;
long int C,D;
long int eu(long int x,long int y){
    while(1){
        if(x<y) swap(x,y);
        if(!y) break;
        x %= y;
    }
    return x;
}
int main(){
    cin >> A >> B >> C >> D;
    int count = 0;
    long int bc,bd,bcd,ac,ad,acd;
    bc = B / C;
    bd = B / D;
    long  int cd=(C*D)/eu(C,D);
    bcd = B / cd;
    B = B - bc -bd + bcd;
    long long int A1=A-1;
    ac = A1 / C;
    ad = A1 / D;
    acd=A1/cd;
    A = A1 - ac -ad + acd;
    long  int C = B -A;

    printf("%ld\n",C);
}

Measured memory_bytes: 3732
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
	long long int x, y;
	int hoge = 1;
	cin >> x >> y;

	while(1){
		x *= 2;
		if(x > y){
			break;
		}else{
			++hoge;
		}
	}

	cout << hoge << endl;

	return 0;
}

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

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

    bool a = false;
    
    if((c[0][1] - c[0][0] == c[1][1] - c[1][0]) && (c[1][1] - c[1][0] == c[2][1] - c[2][0])){
        if((c[0][2] - c[0][1] == c[1][2] - c[1][1]) && (c[1][2] - c[1][1] == c[2][2] - c[2][1])){
            a =true;
        }
    }
    
    if(a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import itertools
import numpy as np

N, M, X = map(int, input().split())

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

min_v = 10**18
for n in range(1, N+1):
  for c in itertools.combinations(range(N), n):
    tmp = np.sum(items[[c]], axis=0)
    c = tmp[0]
    a = tmp[1:]
    if M == np.count_nonzero(a >= X):
      min_v = min(min_v, c)
if min_v == 10**18:
  print(-1)
else:
  print(min_v) 

Measured memory_bytes: 27484
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        if (N%2 == 1) {
            System.out.println(0);
            return;
        }
        long n = N/2;
        long tmp = 5;
        int five = 0;
        while (tmp <= n) {
            five++;
            tmp *= 5;
        }

        long ans = 0;
        long ff = 5;
        for (int i = 0; i < five; i++) {
            ans += n/ff;
            ff *= 5;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;

int main() {
	fastio();
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if(d > 0 && d*d > 4*a*b)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	bool isprime[70001];
	int prime[35000];
	int pnum = 0;
	fill(isprime, isprime+70001, true);
	isprime[0] = isprime[1] = false;
	for (int i=2; i<70001; i++) {
		if (isprime[i]) {
			for (int j=i+i; j<70001; j+=i) isprime[j] = false;
		}
	}
	for (int i=2; i<70001; i++) {
		if (isprime[i]) {
			prime[pnum++] = i;
		}
	}
/*	for (int i=0; i<100; i++) {
		printf("%d ",prime[i]);
	}
	printf("\n");
*/
	while (scanf("%d", &n)!=EOF) {
		int a, b;
		for (int i=0; i<35000; i++) {
			if (prime[i] > n) {
				a = prime[i-1];
				b = prime[i];
				break;
			} else if (prime[i] == n) {
				a = prime[i-1];
				b = prime[i+1];
				break;
			}
		}
		printf("%d %d\n", a, b);
	}
}

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

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

    int n;
    cin >> n;
    long initial[5];
    memset(initial, 0, sizeof(initial));
    string name;
    for (long i = 0; i < n; ++i) {
        cin >> name;
        switch (name[0]) {
            case 'M':
                initial[0] += 1;
                break;
            case 'A':
                initial[1] += 1;
                break;
            case 'R':
                initial[2] += 1;
                break;
            case 'C':
                initial[3] += 1;
                break;
            case 'H':
                initial[4] += 1;
                break;
            default:
                break;
        }
    }
    long long total = 0;
    for (int i = 0; i < 3; ++i) {
        for (int j = i + 1; j < 4; ++j) {
            for (int k = j + 1; k < 5; ++k) {
                total += initial[i] * initial[j] * initial[k];
            }
        }
    }

    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

n = inp[ii]; ii += 1
m = inp[ii]; ii += 1

for x in range(1000):
    ii = 2
    y = str(x)
    if len(y) != n:
        continue
    
    for _ in range(m):
        s = inp[ii]; ii += 1
        c = inp[ii]; ii += 1
        if y[s - 1] != chr(c + 48):
            break
    else:
        print y
        break
    continue
else:
    print -1


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

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[100001];
	int size;
} max_heap;

void push(data x, max_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key > h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(max_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key > h->obj[j].key) j ^= 1;
		if (h->obj[j].key > h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, L[100001], R[100001];
	data d;
	max_heap h[2];
	h[0].size = 0;
	h[1].size = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &(L[i]), &(R[i]));
		d.key = L[i];
		push(d, &(h[0]));
		d.key = -R[i];
		push(d, &(h[1]));
	}
	
	int tmp = 0;
	long long ans[2] = {};
	if (h[0].obj[1].key > 0) {
		tmp = h[0].obj[1].key;
		ans[0] += tmp;
		pop(&(h[0]));
		while (h[0].size > 0) {
			if (-(h[1].obj[1].key) < tmp) {
				ans[0] += tmp + h[1].obj[1].key;
				tmp = -(h[1].obj[1].key);
				pop(&(h[1]));
			} else break;
			if (h[0].obj[1].key > tmp) {
				ans[0] += h[0].obj[1].key - tmp;
				tmp = h[0].obj[1].key;
				pop(&(h[0]));
			} else break;
		}
		ans[0] += abs(tmp);
		
		h[0].size = 0;
		h[1].size = 0;
		for (i = 1; i <= N; i++) {
			d.key = L[i];
			push(d, &(h[0]));
			d.key = -R[i];
			push(d, &(h[1]));
		}
	}
	
	if (-(h[1].obj[1].key) < 0) {
		tmp = -(h[1].obj[1].key);
		ans[1] -= tmp;
		pop(&(h[1]));
		while (h[1].size > 0) {
			if (h[0].obj[1].key > tmp) {
				ans[1] += h[0].obj[1].key - tmp;
				tmp = h[0].obj[1].key;
				pop(&(h[0]));
			} else break;
			if (-(h[1].obj[1].key) < tmp) {
				ans[1] += tmp + h[1].obj[1].key;
				tmp = -(h[1].obj[1].key);
				pop(&(h[1]));
			} else break;
		}
		ans[1] += abs(tmp);
	}
	printf("%lld\n", (ans[0] > ans[1])? ans[0]: ans[1]);
	fflush(stdout);
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n, ans = 1;
    cin >> n;
    for(int i = 2; i * i <= n; i++){
        for(int j = i * i; j <= n; j *= i)ans = (ans < j? j : ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define maxn 100005
using namespace std;
typedef vector<int> vi;

int inp[maxn][3];

int solve(int n){
  int res[n][3];
  res[0][0] = inp[0][0];
  res[0][1] = inp[0][1];
  res[0][2] = inp[0][2];
  fo(i,1,n){
    res[i][0] = inp[i][0] + max(res[i-1][1], res[i-1][2]);
    res[i][1] = inp[i][1] + max(res[i-1][0], res[i-1][2]);
    res[i][2] = inp[i][2] + max(res[i-1][0], res[i-1][1]);
  }
  int ans = max({res[n-1][0],res[n-1][1],res[n-1][2]});
  return ans;
}


int main(){
  op_io;
  int n;
  cin>>n;
  fo(i,0,n){
    cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
  }
  cout<<solve(n)<<endl;
  return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<string> pic1(n), pic2(m);
  for(int i=0; i<n; ++i) cin >> pic1[i];
  for(int i=0; i<m; ++i) cin >> pic2[i];
  for(int i1=0; i1<n-m+1; ++i1) for(int i2=0; i2<n-m+1; ++i2){
    bool ansis = true;
    for(int j1=0; j1<m; ++j1){
      for(int j2=0; j2<m; ++j2){
        if(pic1[i1+j1][i2+j2] != pic2[j1][j2]){
          ansis = false;
          break;
        }
      }
      if(!ansis) break;
    }
    if(ansis){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


struct C{
	P p;
	int r;
	int c;
};

map<int, int> dp;
int n;
vector<C> cs;
int cover[30];

int next_combination(int p){
    int lsb = p&-p;
    int rem = p+lsb;
    int rit = rem&~p;
    return rem|(((rit/lsb)>>1)-1);
}

int go(int mask) {
	if(mask == 0) return 0;
	if(present(dp, mask)) return dp[mask];
	int res = 0;
	rep (i, n) if (mask & (1 << i)) REP (j, i + 1, n - 1) if (mask & (1 << j)) {
		if(cs[i].c != cs[j].c) continue;
		if((mask & cover[i]) || (mask & cover[j])) continue;
		res = max(res, go(mask ^ (1 << i) ^ (1 << j)) + 2);
	}
	return dp[mask] = res;
}

int main() {
	for (; cin >> n, n != 0; ) {
		cs.clear();
		rep (i, n) {
			C c; int x, y; cin >> x >> y >> c.r >> c.c;
			c.p = P(x, y);
			cs.pb(c);
		}
		rep(i, n) {
			int mask = 0;
			rep(j, i) if(cs[i].r + cs[j].r > abs(cs[i].p - cs[j].p)) mask |= 1 << j;
			cover[i] = mask;
		}
		
		dp.clear();
		cout << go((1 << n) -1) << endl;;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main () {
  ll n;
  cin >> n;
  ll dp[n + 1][4][4][4];
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j < 4; j++) {
      for (ll l = 0; l < 4; l++) {
        for (ll k = 0; k < 4; k++) {
          dp[i][j][l][k] = 0;  
        }  
      }  
    }
  }
  for (ll j = 0; j < 4; j++) {
    for (ll l = 0; l < 4; l++) {
      for (ll k = 0; k < 4; k++) {
          if ((j == 0 && l == 2 && k == 1) ||
            (j == 0 && l == 1 && k == 2) ||
            (j == 2 && l == 0 && k == 1)) {
          }
          else {
            dp[3][j][l][k] = 1;  
          }
      }
    }  
  }  
  string h[4] = {"A", "C", "G", "T"};
  for (ll i = 4; i <= n; i++) {
    for (ll j = 0; j < 4; j++) {
      for (ll k = 0; k < 4; k++) {
        for (ll l = 0; l < 4; l++) {
          for (ll p = 0; p < 4; p++) {
            // j, k, l, pについて
            string hh = h[j] + h[k] + h[l] + h[p];
            bool ok = true;
            if (hh.substr(0, 3) == "AGC" || hh.substr(1, 3) == "AGC") {
              ok = false;
            }
            for (ll x = 0; x < 3; x++) {
              swap(hh[x], hh[x + 1]);
              if (hh.substr(0, 3) == "AGC" || hh.substr(1, 3) == "AGC") {
                ok = false;
              }
              swap(hh[x], hh[x + 1]);  
            }
            if (ok == true) {
              dp[i][k][l][p] = (dp[i][k][l][p] + dp[i - 1][j][k][l]) % mod;
            }
          }  
        }  
      }  
    }  
  }
  ll sum = 0;
  for (ll j = 0; j < 4; j++) {
    for (ll l = 0; l < 4; l++) {
      for (ll k = 0; k < 4; k++) {
        sum = (dp[n][j][l][k] + sum) % mod;  
      }
    }  
  }
  cout << sum << endl;
}

Measured memory_bytes: 888
#include <iostream>

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

int countNum(int * nums, int length, int no){
  int res = 0;
  forLoop(i, length){
    if (nums[i] == no) res++;
  }
  return res;
}

int lengthArray(int * num){
  return sizeof(num) / sizeof(int);
}

int main(int argc, char ** argv){
  int a, b, c;
  std::cin >> a >> b >> c;
  int nums[] = {a, b, c};
  if (countNum(nums, 3, 5) == 2 && countNum(nums, 3, 7) == 1){
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


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

#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main() {
    int n, m, ac=0, pn=0;
    cin >> n >> m;
    int *status = new int[n];
    int *wa = new int[n];
    rep(i, n){
        status[i] = 0;
        wa[i] = 0;
    } 
    // int *p = new int[m];
    // string *s = new string[m];
    int p;
    string s;
    rep(i, m){
        cin >> p >> s;
        if(status[p-1]==0){
            if(s=="AC"){
                status[p-1]++;
                ac++;
                pn += wa[p-1];
            }else{
                wa[p-1]++;
            }
        }
    }

    cout << ac << " " << pn << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


int H, W; 
bool table[1000][1000];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
bool isrange(int x, int y) {
	bool flag = true;
	if (x < 0) flag = false;
	if (x >= H) flag = false;
	if (y < 0) flag = false;
	if (y >= W) flag = false;
	return flag;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W;
	queue<P> Q;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char tmp; cin >> tmp;
			if (tmp == '#') {
				table[i][j] = true;
				Q.push(P(i, j));
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		queue<P> Q2;
		while (!Q.empty()){
			P pos = Q.front();
			Q.pop();

			for (int i = 0; i < 4; i++) {
				int nx = pos.first + dx[i];
				int ny = pos.second + dy[i];
				if (isrange(nx, ny) && !table[nx][ny]) {
					table[nx][ny] = true;
					Q2.push(P(nx, ny));
					//cout << "(" << nx << ny << ")";
				}
			}
		}
		//cout << endl;
		ans++;
		while (!Q2.empty()) {
			Q.push(Q2.front());
			Q2.pop();
		}
	}

	cout << ans-1 << endl;

	return 0;
}

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

int main(){
    int N, x, in, i, tmp, sum = 0;
    vector <int> num;

    cin >> N >> x;

    for(i = 0; i < N; i++){
        cin >> in;
        sum += in;
        num.push_back(in);
    }
    tmp = x;
    sort(num.begin(), num.end());
    for(i = 0; i < N; i++){
        x -= num[i];
        if(x < 0)   break;
    }
    if(i == N && sum != tmp)  i--;
    //if(sum == x)    i++;

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  static char s[5100];
  int k;
  if (scanf("%s%d", s, &k) != 2) { return false; }

  int n = int(strlen(s));

  vector <int> lens(n, 1);
  while (1) {
    string bestS(1, 'z' + 1);
    vector <int> pos;
    for (int i = 0; i < n; ++i) {
      if (i + lens[i] > n) {
        continue;
      }
      string curS(s + i, s + i + lens[i]);
      if (bestS > curS) {
        bestS = curS;
        pos.clear();
      }
      if (bestS == curS) {
        pos.push_back(i);
      }
    }

    if (k == 1) {
      printf("%s\n", bestS.c_str());
      return true;
    }
    --k;
    for (int x : pos) {
      lens[x]++;
    }
  }
  assert(0);
}

int main() {
  while (solve());
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    if(n >= 3) cout << 0 << endl;
    else{
        int ans[3] = {1,2,1};
        cout << ans[n] << endl;
    }
}


Measured memory_bytes: 3088