akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 100
int N;

int count=0;


int string_compar(const void *a, const void *b)
{
    return(strcmp((char*)a, (char*)b));
}



int main(void){
	scanf("%d",&N);
  	char str[N][11];
  for(int j=0;j<N;j++){
    scanf("%s",str[j]);
  }
  
  	int data_cnt = sizeof( str )/sizeof( str[0] );
	 
	qsort((void *) str, N , 11, string_compar);
	


	for(int i = 0;i < N-1;i++){
		if(strcmp(str[i],str[i+1])==0){
				count++;
				
			}
		}
	
	printf("%d",N-count);

}

Measured memory_bytes: 5740
#include <cstdio>
#include <algorithm>
#include <cstring>

#define maxn 20
int a[maxn], b[maxn];
typedef long long ll;
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int main()
{
	int n, k; scanf("%d%d", &n, &k);
	ll ans = ~0ULL >> 1;
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for (int S = 0, _ = 1 << n; S < _; ++S)
	{
		memcpy(b, a, n << 2);
		int cnt = 0;
		ll cost = 0, maxx = -0x7fffffff;
		for (int i = 0; i < n; ++i)
		{
			if ((S & (1 << i)) && b[i] <= maxx)
				cost += maxx - b[i] + 1, b[i] = maxx + 1;
			cmax(maxx, b[i]) ? ++cnt : 0;
		}
		cnt >= k ? cmin(ans, cost) : 0;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;
    cin>>n;
    ll res=0;
    ll rmin=INF,lmax=-INF;
    vector<pair<ll,ll>> a;
    ll li,ri;
    for(int i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        r++;
        if(rmin>r)
        {
            rmin=r;
            ri=i;
        }
        if(lmax<l)
        {
            lmax=l;
            li=i;
        }
        a.push_back(make_pair(l,r));
    }
    sort(all(a));
    
        ll x=-1;
        ll y=INF;
    for(ll i=0;i<n;i++){
        chmax(res,mmax(0,rmin-lmax)+a[i].se-a[i].fi);
    }
    for(ll i=n-1;i>=0;i--){
        x=a[i].fi;
        if(i<n-1)chmax(res,mmax(0,y-lmax)+mmax(0,rmin-x));
        chmin(y,a[i].se);
    }
    
    cout<<res<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private final byte MASK_RIGHT = 0x0F;//右4bit数値化用マスク
	private int[][] paper = new int[10][10];//都合の良い方眼紙

	public static void main(String[] args) throws Exception {
		new Main().execute();
	}

	private void execute() throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > max) {
					max = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	cin >> N;
	vector<int> a( N );
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( (i + 1) % 2 && a[i] % 2 ) ans++;
	}

	cout << ans << endl;
}


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

path_matrix = []
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1
    
    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)
    
    visited[now] = False

    return total_paths

print(dfs(0, 0))


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

string s;
int ss, tt, ans;

int main()
{
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == 'S'){
            ss++;
        }
        else {
            tt++;
            if(ss > 0){
                ss--;
                tt--;
            }
            else {
                ans++;
                tt--;
            }
        }
    }
    ans += ss;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;

int main() {
	IOS
	int a, b, k;
	cin >> a >> b >> k;
	vector<int> divisors;
	for(int i=1; i<=min(a, b); i++) {
		if(a % i == 0 && b % i == 0) divisors.push_back(i);
	}
	reverse(divisors.begin(), divisors.end());
	cout << divisors[k-1];
	return 0;
}


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n,m = LI()
mx = [list(map(int,input().split())) for i in range(m)]
p = LI()

l = [0]*m
result = 0
for i in range(1 << n):
    flg = True
    for j in range(m):
        count = 0
        for k in range(mx[j][0]):
            if((1 <<(mx[j][k+1]-1)) & i):
                count += 1
        if(count % 2 != p[j]):
            flg = False
            break
    if(flg):
        result += 1

print(result)

Measured memory_bytes: 40176
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
typedef long long int ll;
typedef vector<long long int> VL;
typedef vector<VL> VVL;
 
int main() {
    while(1) {
        string s;
        ll res = 0;
        cin >> s;
        if(s.length() <= 1 && s[0] == '0') {
            break;
        }
         
        for(int i=0; i<s.length(); i++) {
            char temp[2];
            temp[0] = s[i];
            temp[1] = '\0';
            res += atoll(temp);
        }
         
        cout << res << endl;
    }
     
    return 0;
}


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

int main(){
  map<int,int> mp;
  int temp;
  for(int i=0;i<6;i++){
    cin>>temp;
    temp--;
    mp[temp]++;
  }
  if(mp.size()==3){
    cout<<"NO"<<endl;
    return 0;
  }
  for(int i=0;i<4;i++){
    if(mp[i]>=3){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  
    
    
  cout<<"YES"<<endl;
  
  return 0;
}

    
  
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    long long t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    long long int x,y;
    long long int ans=0;
    if(a1>b1){
        x=(a1-b1)*t1;
        if(a2>b2){cout<<0<<endl;return 0;}
        else{y=(b2-a2)*t2;}
    }
    else{
        x=(b1-a1)*t1;
        if(b2>a2){cout<<0<<endl;return 0;}
        else{y=(a2-b2)*t2;}
    }
    if(x>y){cout<<0<<endl;return 0;}
    if(x==y){cout<<"infinity"<<endl;return 0;}
    //差はx開きy縮むを繰り返す。
    y=y-x;

    if(x%y==0){
        ans=2*(x/y);
    }
    else{ans=2*(x/y)+1;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,i,count;
	count = 0;

	scanf("%d %d %d",&a,&b,&c);

	for(i = a; i <= b; i++)
	{
		if(c % i == 0)
		{
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
n,m=map(int,input().split())
li=[]
for i in range(m):
    a,b=map(int,input().split())
    li.append([a,b])
li1=set([i[1] for i in li if i[0]==1])
li2=set([i[0] for i in li if i[1]==n])
li3=li1&li2
if len(li3)>=1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 44688
n,m=map(int, input().split())
a=list(map(int, input().split()))
num=[2,5,5,4,5,6,3,7,6]
for i in range(9):
    if i+1 not in a:
        num[i]=0
dp=[[0]*10 for i in range(n+1)]
from copy import deepcopy
for i in range(2,n+1):
    for j in range(9):
        if num[j]>0 and num[j]<=i and dp[i][0]<=dp[i-num[j]][0]+1:
            if dp[i-num[j]][0]==0 and i-num[j]!=0:
                continue
            else:
                dp[i]=deepcopy(dp[i-num[j]])
                dp[i][0]+=1
                dp[i][j+1]+=1
ans=dp[n]
for i in range(9,0,-1):
    while ans[i]!=0:
        print(i,end='')
        ans[i]-=1
print()


Measured memory_bytes: 6912
n = int(input())
a = [int(i) for i in input().split()]

res = 0
sum = 0
r = 0

for l in range(n):
    while r < n and (sum + a[r]) == (sum ^ a[r]):
        sum += a[r]
        r += 1
    res += r - l
    if l == r:
        r += 1
    else:
        sum -= a[l]

print(res)


Measured memory_bytes: 23560
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 200005, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n, m;

struct EDGE {
    int to, nex;
} edge[N << 1];
int head[N], cntedge;
void Addedge(int u, int v) {
    edge[++cntedge] = (EDGE) { v, head[u] };
    head[u] = cntedge;
}


int Ldfn[N], Rdfn[N], cntDfs;
void Dfs(int u, int fa) {
    Ldfn[u] = ++cntDfs;
    for (reg int i = head[u], v; i; i = edge[i].nex) {
        v = edge[i].to;
        if (v == fa) continue;
        Dfs(v, u);
    }
    Rdfn[u] = cntDfs;
}

int c[N];
void Add(int x, int k) { for ( ; x <= n; x += x & -x) c[x] += k; }
int Que(int x) {
    int res = 0;
    for ( ; x > 0; x -= x & -x) res += c[x];
    return res;
}


int main() {
    n = read<int>(), m = read<int>();
    rep (i, 2, n) {
        int x = read<int>(), y = read<int>();
        Addedge(x, y), Addedge(y, x);
    }

    Dfs(1, 0);

    rep (i, 1, m) {
        int p = read<int>(), x = read<int>();
        Add(Ldfn[p], x), Add(Rdfn[p] + 1, -x);
    }

    rep (i, 1, n) printf("%d%c", Que(Ldfn[i]), " \n"[i == n]);
    return 0;
}



Measured memory_bytes: 17792
n=int(input())
a=list(map(int,input().split()))
import heapq as hq
f1=[0]*(3*n)
f1[n-1]=sum(a[:n])
h=a[:n]
hq.heapify(h)
su=f1[n-1]
for i in range(n,2*n):
    cur=a[i]
    x=hq.heappop(h)
    if cur>x:
        su-=x
        su+=cur
        hq.heappush(h,cur)
    else:
        hq.heappush(h,x)
    f1[i]=su
f2=[0]*(3*n)
f2[2*n]=sum(a[2*n:])
su=f2[2*n]
h2=[]
for i in a[2*n:]:
    h2.append(-i)
hq.heapify(h2)
for i in range(2*n-1,n-1,-1):
    cur=a[i]
    x=-1*hq.heappop(h2)
    if cur<x:
        su-=x
        su+=cur
        hq.heappush(h2,-cur)
    else:
        hq.heappush(h2,-x)
    f2[i]=su
ans=-float('inf')
for i in range(n-1,2*n):
    ans=max(ans,f1[i]-f2[i+1])
print(ans)





Measured memory_bytes: 40068
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0

for a in range(A+1):
    if X < 500*a:
        break
    for b in range(B+1):
        if X < 500*a+100*b:
            break
        for c in range(C+1):
            if X == 500*a+100*b+50*c:
                ans+=1
print(ans)

Measured memory_bytes: 9148
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;

template<typename T>
struct edge {

	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	bool operator<(const edge<T> e1) {
		return cost < e1.cost;
	}


	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }

};
template<typename T>
using Edge = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edge<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;



template<typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s) {
	const auto INF = numeric_limits<T>::max();
	vector<T> dist(g.size(), INF);

	using Pi = pair<T, int>;

	priority_queue<Pi, vector<Pi>, greater<Pi>> q;

	dist[s] = 0;

	q.emplace(dist[s], s);

	while (!q.empty()) {
		T cost;
		int idx;

		tie(cost, idx) = q.top();
		q.pop();
		if (dist[idx] < cost) continue;

		for (auto &e : g[idx]) {
			auto next_cost = cost + e.cost;
			if (dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			q.emplace(dist[e.to], e.to);

		}
	}
	return dist;
}


int main() {

	cin >> N;
	ll a, b;
	WeightedGraph<ll> e(N+1);
	rep(i, N-1) {
		cin >> a >> b;
		
		e[a].emplace_back(b, 1);
		e[b].emplace_back(a, 1);
	}

	vector<ll> dist1 = dijkstra(e, 1);


	ll m = 0, s = 0;
	rep(i, N) {
		if (dist1[i+1] > m) {
			s = i+1;
			m = dist1[i + 1];
		}
	}



	vector<ll> dist2 = dijkstra(e, s);
	ll r = 0;
	rep(i, N) {

		r = max(dist2[i + 1], r);
	}

	if (N == 1) {
		cout << "First" << endl;
		return 0;
	}

	if (r % 3 != 1) {
		cout << "First" << endl;
	}

	else  {
		cout << "Second" << endl;
	}



	return 0;
}

Measured memory_bytes: 24628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> d(n);
    rep(i, 0, n) cin >> d[i];
    int ans = 0;
    rep(i, 0, n - 1){
        ans += min(b, a * (d[i + 1] - d[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int a,b;
		a = sc.nextInt();
		b = sc.nextInt();
		
		if(b%a==0) 
			System.out.println(a+b);
		else
			System.out.println(b-a);
	}
}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;
int h = 0, w = 0;
char canvas[51][51] = { 0 };
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x, int y) {
    canvas[x][y] = 'B';

    for (int i = 0; i < 4; i++) {
        if (x + dx[i] >= 0 && x + dx[i] < h && y + dy[i] >= 0 && y + dy[i] < w && canvas[x + dx[i]][y + dy[i]] == '#') {
            dfs(x + dx[i], y + dy[i]);
        }
    }
}

bool checkAroundTarget(int x, int y) {
    int flag = false;
    for (int i = 0; i < 4; i++) {
        if (canvas[x + dx[i]][y + dy[i]] == '#') {
            flag = true;
            break;
        }
    }

    return flag;
}

int main()
{
    bool ans = true;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> canvas[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (canvas[i][j] == '#') {
                if (!checkAroundTarget(i, j)) {
                    ans = false;
                    break;
                }
                dfs(i, j);
            }
        }
        if (!ans) break;
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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

ll bin(ll n, ll i) {
	if (i == 0) { return n % 2; }
	else { return bin(n / 2, i - 1); }
}

	
int main() {

	ll n;
	cin >> n;
	string s;
	cin >> s;

	ll lead[MAX];

	lead[0] = 0;
	for (ll i = 1; i < n; i++) {
		if (s[i] == 'E') { lead[0]++; }
	}
	
	for (ll i = 1; i < n; i++) {
		lead[i] = lead[i - 1];
		if (s[i - 1] == 'W') { lead[i]++; }
		if (s[i] == 'E') { lead[i]--; }
	}

	ll ans = n;
	rep(i, n) ans = min(ans, lead[i]);

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define N 1000000
using namespace std;

bool prime[N + 5] = {0};
int n, p, now;

void sprime() {
  int i, j;
  prime[0] = 1;
  prime[1] = 1;
  for(i = 2; i < sqrt(N); ++i)
    if(!prime[i])
      for(j = 2; i * j <= N; ++j) prime[i * j] = 1;
}

int main() {
  int i, j;
  sprime();
  while(1) {
    cin >> n >> p;
    if(n + p == -2) break;
    vector<int> v;
    while(v.size() < p)
      if(!prime[++n]) v.push_back(n);
    vector<int> ans;
    bool ch[N] = {0};
    for(i = 0; i < v.size(); ++i)
      for(j = i; j < v.size(); ++j) {
        // if(ch[v[i] + v[j]]) continue;
        ans.push_back(v[i] + v[j]);
        ch[v[i] + v[j]] = 1;
      }

    sort(ans.begin(), ans.end());
    // for(i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
    cout << ans[p - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 4184
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String s = sc.next();
		int[] left = new int[m];
		int[] right = new int[m];
		int[] cnt = new int[n+1];
		for(int i = 0; i < m; i++) {
			left[i] = sc.nextInt();
			right[i] = sc.nextInt();
		}
		for(int i = 1; i < n-1; i++) {
			if(cnt[i-1] != 0) {
				cnt[i] = cnt[i-1];
			}
			if(s.substring(i-1, i+1).equals("AC")) {
				cnt[i] ++ ;
			}
		}
		if(s.substring(n-2, n).equals("AC")) {
			cnt[n-1] = cnt[n-2] + 1;
		}else {
			cnt[n-1] = cnt[n-2];
		}

		//cnt[n-1] = cnt[n-2];

		System.out.println();
		for(int i = 0; i < m; i++) {
			int ans = cnt[right[i]-1] - cnt[left[i]-1];


			System.out.println(ans);
		}
		sc.close();
	}
}


Measured memory_bytes: 87984
#include<stdio.h>

int main(){
  
  int N;
  scanf("%d",&N);
  unsigned long long L[N];
  L[0] = 2;
  L[1] = 1;

  for(int i=2; i<=N; i++){
    L[i] = L[i-1] + L[i-2];
  }

  printf("%lld",L[N]);

  return 0;
}

Measured memory_bytes: 128
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn calc(a: &[i64], y: i64) -> u64 {
    let n = a.len();
    let s = a.iter().fold(0, |s, a| s + *a);
    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for _ in 0..5 {
        let mut next = vec![0; n + 1];
        for i in 0..n {
            let v = dp[i];
            let mut sum = 0;
            for j in i..n {
                sum += a[j];
                if sum + y >= s / 5 {
                    next[j + 1] += v;
                }
            }
        }
        dp = next;
    }
    dp[n]
}

fn run() {
    input! {
        n: usize,
        y: i64,
        a: [i64; n],
    }
    let mut ans = calc(&a, y);
    for i in 1..n {
        let mut b = vec![];
        b.extend_from_slice(&a[i..]);
        b.extend_from_slice(&a[..i]);
        ans += calc(&b, y);
    }
    ans /= 5;
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5040
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int 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 (a > b) { a = b; return 1; }
	return 0;
}

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

	int a, b, c;
	cin >> a>>b>>c;
	a + b + c >= 22 ? puts("bust") : puts("win");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	int n = 0;
	cin >> n;
	rep(i, n) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				cout << "DENIED";
				return 0;
			}
		}
	}

	cout << "APPROVED";
	return 0;
}

Measured memory_bytes: 384
#input,start
N,Y = map(int,input().split()) 
A=-1
B=-1
C=-1

#calculate
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        y = a * 10000 + b * 5000 + c * 1000
        if y == Y:
            A,B,C = a,b,c
#print
print(A,B,C)

Measured memory_bytes: 3188
// bit演算を使う
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, ans = -1e15;

  cin >> n;
  int cou = 0;

  long long open[n][10] = {0}, profit[n][11] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {

      cin >> open[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> profit[i][j];
    }
  }
  for (int i = 1; i < 1024; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      cou = 0;
      for (int k = 0; k < 10; k++) {
        if (open[j][k] == 1 && (i >> k) & 1) {
          cou++;
        }
      }
      sum += profit[j][cou];
    }

    ans = max(sum, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void)
{
	int i, j, k, l;
	// freopen("1275_input.txt","r",stdin);
	int start = clock();
	while (1) {
		int n, k, m;
		cin >> n >> k >> m;
		if (n == 0) break;
		--m;
		vector<int> stones(n);
		rep(i, n) stones[i] = i;
		while (stones.size() != 1) {
			stones.erase(stones.begin() + m);
			m = (m + k - 1) % stones.size();
		}
		cout << stones[0]+1 << endl;
	}
	// cout << "time : " <<  (clock() - start) / CLOCKS_PER_SEC << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n % 10 == 3) {
        cout << "bon" << endl;
    } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n == 8) cout << "pon";
    else cout << "hon" << endl;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int n,c=0;
  n=S.size();
  rep(i,n){
    if(S.at(i)!=T.at(i)){
      c++;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3852
def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod
    else            : return power(x, y//2, mod)**2 * x % mod


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x


mod = int(1e9) + 7
n, a, b = map(int, input().split())

nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
nCb = div(factorial_part(n - b + 1, n, mod), factorial_part(1, b, mod), mod)
n2 = power(2, n, mod)
ans = n2 - nCa - nCb - 1
ans = ans % mod
if ans < 0:
    ans += mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(n,a,b);
    if(a>b)cout<<0<<endl;
    else if(n==1)cout<<(a==b?1:0)<<endl;
    else cout<<(b-a)*(n-2)+1<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
MOD = 10**9+7
def inputs():return [int(x) for x in input().split()]
A = np.array([inputs()])
ans = 0
for i in range(63):
  B = A&(1<<i)
  x = np.count_nonzero(B)
  y = N-x
  x*=y
  ans+=(2**i*x)%MOD
  ans%=MOD
print(ans)
  


Measured memory_bytes: 48780
#include<iostream>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int MAXN = 100;
static const int INTFY = (1 << 21);

int n, M[MAXN][MAXN];

int prim()
{
	int u, minv;
	int d[MAXN], p[MAXN], color[MAXN];
	
	for(int i = 0; i < n; i++)
	{
		d[i] = INTFY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(true)
	{
		minv = INTFY;
		u = -1;
		for(int i = 0; i < n; i++)
		{
			if(minv > d[i] && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}

		if(u == -1) break;
		color[u] = BLACK;

		for(int v = 0; v < n; v++)
		{
			if(color[v] != BLACK && M[u][v] != INTFY)
			{
				if(M[u][v] < d[v])
				{
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		if(p[i] != -1)
			sum += M[i][p[i]];
	}
	return sum;	
}


int main ()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++) 
		{
			int e;
			cin >> e;
			M[i][j] = (e == -1)? INTFY : e; 
		}
	}
	cout << prim() << endl;
	
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main() {
    double xa, ya, xb, yb, xc, yc, xd, yd;
    char c;
    while (cin >> xa >> c >> ya >> c >> xb >> c >> yb >> c >> xc >> c >> yc >> c >> xd >> c >> yd) {
        double check1, check2;
        bool flg = false;
        check1 = (yb - ya) - (yc - ya) / (xc - xa) * (xb - xa);
        check2 = (yd - ya) - (yc - ya) / (xc - xa) * (xd - xa);
        if (check1 * check2 > 0) { //同じ側
            flg = true;
        }
        check1 = (ya - yb) - (yd - yb) / (xd - xb) * (xa - xb);
        check2 = (yc - yb) - (yd - yb) / (xd - xb) * (xc - xb);
        if (check1 * check2 > 0) { //同じ側
            flg = true;
        }
        if (flg == true) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3200
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const int N = 2222;

char a[N][N];
 
struct Sum {
	int s[N][N];
 
	Sum() {
		memset(s, 0, sizeof(s));
	}
 
	void Upd(int i, int j, int k) {
		s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + k;
	}
 
	int Get(int xl, int yl, int xr, int yr) {
		return (s[xr][yr] + s[xl][yl] - s[xr][yl] - s[xl][yr]);
	}
};
 
Sum s1, s2, s3;


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), m = readInt(), Q = readInt();
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		cin >> a[i][j];
    	}
    }
    
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			s1.Upd(i, j, a[i][j] == '1');
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < m; j++) {
			s2.Upd(i, j, (a[i][j + 1] == '1') && (a[i][j] == '1'));
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= m; j++) {
			s3.Upd(i, j, (a[i + 1][j] == '1') && (a[i][j] == '1'));
		}
	}
	while(Q--) {
		int xl = readInt(), yl = readInt(), xr = readInt(), yr = readInt();
		cout << s1.Get(xl - 1, yl - 1, xr, yr) - s2.Get(xl - 1, yl - 1, xr, yr - 1) - s3.Get(xl - 1, yl - 1, xr - 1, yr) << "\n";
	}
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;


llint gcd (llint x, llint y) {
    if (x % y == 0) return y;
    else return gcd(y, x % y);
}


llint lcm (llint x, llint y) {
    return x * y / gcd(x, y);
}


int main () {
    llint a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  if(A + B < 10){
    co(A + B);
  }
  else{
    co("error");
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int Comp_Strs(char *str1, char *str2){
	for(; *str1 == *str2; str1++, str2++)
		if(*str1 == '\0')
			return 0;
	return *str1 - *str2;
}
int main(){
	int N, ca = 0, cb = 0, cc = 0, cd = 0;
	scanf("%d", &N);
	char str[10];
	char *a = "AC", *b = "WA", *c = "TLE", *d = "RE";
	for(int i = 1; i <= N; i++){
		scanf("%s", str);
		if(Comp_Strs(a, str) == 0)
			ca++;
		if(Comp_Strs(b, str) == 0)
			cb++;
		if(Comp_Strs(c, str) == 0)
			cc++;
		if(Comp_Strs(d, str) == 0)
			cd++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ca, cb, cc, cd);

	return 0;
}

Measured memory_bytes: 1732
#include<iostream>

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    long long sum = 0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    printf("%lld",sum);
}

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int W = 0;
int H = 0;
int N = 0;
P spot[1020];

void input() {
  cin >> W >> H >> N;
  for (int i = 0; i < N; i++) {
    cin >> spot[i].first >> spot[i].second;
  }
}

int sign(int num) {
  return (num > 0) - (num < 0);
}

int solve() {
  int way = 0;
  for (int i = 0; i < N-1; i++) {
    P now(spot[i].first, spot[i].second);
    P next(spot[i+1].first, spot[i+1].second);
    int distance[2] = {now.first-next.first, now.second-next.second};
    if (sign(distance[0]) == sign(distance[1])) {
      way += max(abs(distance[0]), abs(distance[1]));
    }
    else {
      way += abs(distance[0]) + abs(distance[1]);
    }
  }
  return way;
}

int main() {
  input();
  printf("%d\n", solve());
  return 0;
}



Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int f(ll a){
    int res = 0;
    while(a>0){
        res++;
        a/=10;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    int res = INT_MAX;
    for(ll i=1;i*i<=n;++i){
        if(n%i==0){
            chmin(res,f(n/i));
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
int N;
int A[250000], v[500][500];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
bool B[500][500];


int main() {
    init();
    cin >> N;
    rep(i, N * N) cin >> A[i], A[i]--;
    
    rep(i,N)rep(j,N){
        v[i][j] = min(min(i, j), min(N - i - 1, N - j - 1)), B[i][j] = true;
    }

    queue<int> q;
    int ans = 0;

    for(int i = 0; i < N * N; i++) {
        int R = A[i] / N, C = A[i] % N;
        ans += v[R][C];
        B[R][C] = false;

        q.emplace(A[i]);
        while(!q.empty()){
            int a = q.front();
            q.pop();
            int r = a / N, c = a % N;
            int cost = v[r][c] + B[r][c];

            for (int j = 0; j < 4; j++) {
                int rr = r + dx[j], cc = c + dy[j];
                if (rr < 0 or rr >= N or cc < 0 or cc >= N) continue;
                if (v[rr][cc] > cost) q.emplace(rr * N + cc), v[rr][cc] = cost;
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
int main() {
    FAST
   ll n,m;
    cin>>n>>m;
    if(n ==1 || m==1)
        return cout<<1,0;
    cout<<setprecision(18)<<n*m/2+(n*m)%2<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
a = l()
ans = 0
for i in range(N):
    if (i+1)%2 == 1 and a[i]%2 == 1:
        ans += 1
print(ans)

Measured memory_bytes: 72592
n = int(input())
t = int(input())
mint = t
t1 = int(input())
if t1 < t:
    mint = t1
maxt = t1 - t

for i in range(2,n):
    t = int(input())
    if t -mint > maxt:
        maxt = t-mint
    
    if t < mint:
        mint = t

print(maxt)


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

int main() {
  int n = 0, count = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int keta = 0;
    while (i - pow(10, keta) >= 0) {
      keta++;
    }
    if (keta % 2 == 1) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
X,Y = input().split()
X = int(X)
Y = int(Y)
S = 0
s = [300000,200000,100000]
if X <= 3:
    S += s[X-1]
if Y <= 3:
    S += s[Y-1]
if X == 1 and Y == 1:
    S += 400000
print(S)

Measured memory_bytes: 3060