akhauriyash/Code-Regression huggingface dataset:
n = int(input())
say = []
for i in range(n):
    s = []
    for j in range(int(input())):
        s.append(list(map(int,input().split())))
    say.append(s)

import numpy as np
import itertools
def tfcheck(say,tf):
    if len(say)==0:
        return 0
    for i in range(len(say)):
        for j in range(len(say[i])):
            [x,y] = say[i][j]
            if tf[x-1] == -1:
                tf[x-1] = y
                continue
            if tf[x-1] != y:
                return 0
    return 1
status = [[0,1] for i in range(n)]
m = 0
for tf in itertools.product(*status):
    s = []
    for i in range(n):
        if tf[i] == 1:
            s.append(say[i])
    if tfcheck(s,tf)==1:
        if sum(tf)>m:
            m = sum(tf)
print(m)

Measured memory_bytes: 12512
/**
 *   created: 23 May 2019  17:47:19
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi > adj;
vector<int> res;

void dfs(int node){
	res[node]=0;
	queue<int> q;
	q.push(node);
	while(!q.empty()){
		int tp = q.front();
		q.pop();
		for(int x:adj[node]){
			if(res[x]==-1)
				dfs(x);
			res[node] = max(res[node],1+res[x]);
		}
	}
}
int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n,m;
		cin>>n>>m;
		adj.resize(n+1);
		while(m--){
			int a,b;
			cin>>a>>b;
			adj[a].push_back(b);
		}
		res.resize(n+1,-1);
		int maxi = 0;
		rep(i,1,n+1){
			if(res[i]==-1){
				dfs(i);
				maxi = max(res[i],maxi);
			}
		}
		cout<<maxi<<endl;
	}
	return 0;
}


Measured memory_bytes: 40960
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];

        int ans = -1;
        for (int i = 1000; i >= 1; i--)
        {
           if ((int)Math.Floor(i * 0.08) == a
                && (int)Math.Floor(i * 0.1) == b)
            {
                ans = i;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include<iostream>
using namespace std;
#define tns 1000000007

long long  pow(long long n, long long i) {
	long long r = 1, t = n;
	for(; i != 0; i >>= 1) {
		if (i&1) r = r * t % tns;
		t = t * t % tns;
	}
	return r;
}

long long fact(long long n) {
	long long r = 1;
	for(; n > 0; n--)
		r = r * n % tns;
	return r;
}

long long nct(long long n, long long t) {
	long long a = 1, b = 1;
	while(t > 0) {
		a = a * n % tns;
		b = b * t % tns;
		n--;
		t--;
	}
	return a * pow(b, tns-2) % tns;
}

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long r = pow(2, n) - 1 - nct(n, a) - nct(n, b);
	while(r < 0) r += tns;
	cout << r << endl;
}






Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC143 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = list(input())
ans = 0
i = 0
while i < n:
    tmp = s[i]
    while i < n:
        if tmp == s[i]:
            i += 1
        else:
            break
    ans += 1
print(ans)

Measured memory_bytes: 49904
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int64_t H, m = 1, c = 0;
  cin >> H;
  while (H > 0)
  {
    H = H / 2;
    c += m;
    m *= 2;
  }
  cout << c << endl;
}


Measured memory_bytes: 3124
from operator import mul
from functools import reduce
N, M=map(int, input().split())


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

if N>=2 and M>=2:
    print(combinations_count(N, 2)+combinations_count(M, 2))
elif N>=2 or M>=2:
    print(combinations_count(N, 2)+combinations_count(M, 2)-1)
else:
    print(0)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	ll L = 0, R = 0;
	int i = 0, j = N-1;
	while (i != j)
	{
		if (L < R)
			L += A[i++];
		else
			R += A[j--];
	}
	if (L < R)
		L += A[i++];
	else
		R += A[j--];
	cout << abs(L-R) << endl;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
 
int main(){
  int h,w,d,q,l,r,a[90001][2],b,i,j,k;
  long di[90001]={};
  scanf("%d %d %d",&h,&w,&d);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&b);
      a[b][0]=i;
      a[b][1]=j;
    }
  }
  for(i=d+1;i<=w*h;i++){
    di[i]+=di[i-d]+abs(a[i][0]-a[i-d][0]);
    di[i]+=abs(a[i][1]-a[i-d][1]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    printf("%ld\n",di[r]-di[l]);
  }
}


Measured memory_bytes: 2432
N, C = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

Y = [[C - i, v] for i, v in X[::-1]]

# Cumsum
x_cs = [[0, 0] for _ in range(N + 1)]
y_cs = [[0, 0] for _ in range(N + 1)]
for i in range(N):
    x_cs[i + 1][0] = X[i][0]
    x_cs[i + 1][1] = x_cs[i][1] + X[i][1]

    y_cs[i + 1][0] = Y[i][0]
    y_cs[i + 1][1] = y_cs[i][1] + Y[i][1]

fx = [v - x for x, v in x_cs]
fy = [v - x for x, v in y_cs]

gx = [0] * (N + 1)
gy = [0] * (N + 1)
for i in range(N):
    gx[i + 1] = max(gx[i], fx[i + 1])
    gy[i + 1] = max(gy[i], fy[i + 1])

X = [[0, 0]] + X
Y = [[0, 0]] + Y
ans = max(gx + gy)
for i in range(N + 1):
    ans = max(ans, gx[i] + gy[N - i] - X[i][0],
              gx[N - i] + gy[i] - Y[i][0])

print(ans)


Measured memory_bytes: 101336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

int N, K;
vector<ll> arr, pos, neg;

ll cal();
ll cal2();

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

	cin >> N >> K;
	
	arr.resize(N);

	bool allNeg = true;
	for (auto& i : arr) {
		cin >> i;
		if (i >= 0) {
			allNeg = false;
			pos.push_back(i);
		}
		else neg.push_back(i);
	}

	sort(arr.rbegin(), arr.rend());
	sort(pos.rbegin(), pos.rend());
	sort(neg.begin(), neg.end());

	//예외 케이스 1 : K = N
	if (K == N) {
		cout << cal();
		return 0;
	}

	//예외 케이스2 : 모든 A_i가 음수고, K가 홀수
	if (allNeg && (K & 1)) {
		cout << cal();
		return 0;
	}

	//그 외엔 언제나 product의 최댓값이 음이 아닌 정수다
	cout << cal2();

	return 0;
}

ll cal() {
	ll ret = 1;
	for (int i = 0; i < K; i++) {
		ret = ret * arr[i] % MOD;
	}
	if (ret < 0) ret += MOD;
	return ret;
}

ll cal2() {
	ll ret = 1;

	int L = -1, R = -1;
	while (L + R + 2 <= K - 2) {
		if (L + 1 >= pos.size()) {
			ret = ret * neg[R + 1] % MOD;
			ret = ret * neg[R + 2] % MOD;
			R += 2;
		}
		else if (R + 2 >= neg.size()) {
			ret = ret * pos[L + 1] % MOD;
			L += 1;
		}
		else if (neg[R + 1] * neg[R + 2] > pos[L + 1] * pos[L + 2]) {
			ret = ret * neg[R + 1] % MOD;
			ret = ret * neg[R + 2] % MOD;
			R += 2;
		}
		else {
			ret = ret * pos[L + 1] % MOD;
			L += 1;
		}
	}
	
	if (L + R + 2 == K - 1) ret = ret * pos[L + 1] % MOD;

	if (ret < 0) ret += MOD;

	return ret;
}

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

int main() {

	int X;
	cin >> X;
	double theta = X * 2.0 * 3.141592653589793238462643383279 / 360.0;
	double x, y, vx, vy, ct, st, eps;
	x = 0.0;
	y = 1.0;
	vx = 0.0;
	vy = 1.0;
	ct = cos(theta);
	st = sin(theta);
	eps = 0.000001;
	int count = 1;
	while ((x*x + y * y) > eps) {
		double vvx = vx;
		vx = vx * ct - vy * st;
		vy = vvx * st + vy * ct;
		x += vx;
		y += vy;
		count++;
//		cout << "(" << x << "," << y << ")" << endl;
	}
	cout << count << endl;
	return(0);
}


Measured memory_bytes: 3876
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N;
	cin >> N;
	string W[101];

	for (int i = 1; i <= N; i++) {
		cin >> W[i];
	}

	for (int i = 2; i <= N; i++) {
		for (int j = 1; j < i; j++) {
			if (W[i] == W[j]) {
				cout << "No";
				return 0;
			}
		}
		if (W[i][0] != W[i - 1][W[i - 1].length() - 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
//
//  main.cpp
//  adsfdsgsg
//
//  Created by h3037175 on 2017/07/31.
//  Copyright ?? 2017??´ h3037175. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
#define nan -100000
using namespace std;
int main() {
    int n,s,p,o,a,count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>p;
        if(s%p==0){
            cout<<p<<endl;
        }
        else if(s>=p){
            cout<<s%p<<endl;
        }
        else{
            cout<<s<<endl;
        }
    }
    return 0;
}

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

using ll = long long;
#define f first
#define s second

#ifndef LOCAL
	#define cerr if(0) cerr
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	
	ll n, d;
	cin >> n >> d;
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ll x, y;
		cin >> x >> y;

		if (sqrt(x * x + y * y) <= d)
			++ans;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <algorithm>
#include <string>

using namespace std;
const int max_n = 100;
int n, m;
struct edge
{
	int start, end, cost;
};
vector<edge> edges;
int all_cost[max_n][max_n];

void init_all_cost()
{
	for (int i = 0; i < max_n; i++)
	{
		for (int j = 0; j < max_n; j++)
		{
			all_cost[i][j] = 100 * 1000;//inf
		}
	}

	for (auto e : edges)
	{
		all_cost[e.start][e.end] = e.cost;
		all_cost[e.end][e.start] = e.cost;
	}
}

void wf()
{
	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				int costikj = all_cost[i][k] + all_cost[k][j];
				if (all_cost[i][j]>costikj)
				{
					all_cost[i][j] = all_cost[j][i] = costikj;
				}
			}
		}
	}
}

int count_unnecessary_edges()
{
	int ans = 0;
	for (auto e : edges)
	{
		if (all_cost[e.start][e.end]<e.cost)
		{
			ans++;
		}
	}

	return ans;
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		edges.push_back({ a-1,b-1,c });
	}
	getchar();

	init_all_cost();
	wf();
	int ans = count_unnecessary_edges();

	printf("%d\n", ans);
#ifdef _DEBUG
	printf("Press enter to exit\n");
	getchar();
#endif
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
p = [0 for i in range(N)]
q = [0 for i in range(N)]
for i in range(N):
    x[i],y[i] = map(int, input().split())
    p[i]=x[i]
    q[i]=y[i]
x.sort()
y.sort()
S = [[0 for i in range(N+1)]for i in range(N+1)]
for n in range(N):
    for i in range(N):
        for j in range(N):
            if p[n]<=x[i] and q[n]<=y[j]:
                S[i+1][j+1]+=1
R=(x[N-1]-x[0])*(y[N-1]-y[0])
for a in range(N):
    for b in range(N):
        for c in range(a,N):
            for d in range(b,N):
                if (S[a][b]+S[c+1][d+1]-S[a][d+1]-S[c+1][b])>=K:
                    if (x[c]-x[a])*(y[d]-y[b])<R:
                        R=(x[c]-x[a])*(y[d]-y[b])
print(R)


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  int mat[1001][1001] = {{}};
  for(int i = 0; i < N; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    mat[x1][y1]++;
    mat[x1][y2]--;
    mat[x2][y1]--;
    mat[x2][y2]++;
  }


  int ret = 0;
  for(int i = 0; i < 1001; i++) {
    for(int j = 0; j < 1001; j++) {
      if(i) mat[i][j] += mat[i - 1][j];
      if(j) mat[i][j] += mat[i][j - 1];
      if(i && j) mat[i][j] -= mat[i - 1][j - 1];
      ret = max(ret, mat[i][j]);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 7020
#include <bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); ++(i))
#define Rep(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define ALLIN(v) rep(i,v.size())cin>>v[i]
#define bet(a,x,b) a<=x&&x<b
#define fi first
#define se second
using namespace std;

using arr=vector<int>;
using mat=vector<arr>;
using pi=pair<int,int>;
template<typename T>
using vec=vector<T>;
template<typename T>
using pq=priority_queue<T>;
template<typename T>
using rpq=priority_queue<T,vec<T>,greater<T>>;

template<typename T>
struct edge{
  int to;
  T cost;
};

template<typename T>
struct WeightedGraph{
  int size;
  vector<vector<edge<T>>> graph;
  
  WeightedGraph(int N):size(N){
    graph.resize(size);
  }
  
  void u_add(int s,int t,T c){
    graph[s].emplace_back((edge<T>){t,c});
    graph[t].emplace_back((edge<T>){s,c});
  }
};

template<typename T>
vec<T> Dijkstra(WeightedGraph<T> gr,int s){
  const auto INF=numeric_limits<T>::max();
  vec<T> res(gr.size,INF);
  
  using PI=pair<T,int>;
  rpq<PI> q;
  res[s]=0; q.emplace(res[s],s);
  while(!q.empty()){
    T cost; int idx;
    tie(cost,idx)=q.top();
    q.pop();
    if(res[idx]<cost) continue;
    for(auto &e:gr.graph[idx]) {
      auto next_cost = cost + e.cost;
      if(res[e.to] <= next_cost) continue;
      res[e.to] = next_cost;
      q.emplace(res[e.to], e.to);
    }
  }
  return res;
}

int main(){
  int N,M,R; cin>>N>>M>>R;
  vec<pi> r(R);
  rep(i,R){
    int x; cin>>x;
    r[i]=pi(x-1,i);
  }
  WeightedGraph<int> g(N);
  mat h(R,arr(R,0));
  rep(i,M){
    int A,B,C; cin>>A>>B>>C;
    --A,--B;
    g.u_add(A,B,C);
  }
  //for(auto &e:r) cout<<"("<<e.fi<<","<<e.se<<") ";
  //cout<<endl;
  rep(i,R){
    auto v=Dijkstra(g,r[i].fi);
    //for(auto &e:v) cout<<e<<" ";
    //cout<<endl;
    rep(j,R){
      h[i][r[j].se]=v[r[j].fi];
    }
  }
  mat dp(1<<R,arr(R,INT_MAX));
  rep(i,R) dp[1<<i][i]=0;
  Rep(i,1,1<<R){
    rep(j,R){
      if(dp[i][j]==INT_MAX) continue;
      //else cout<<i<<" "<<j<<" :"<<endl;
      rep(k,R){
        if((i&(1<<k))==0){
          //cout<<"  "<<k<<" Do"<<endl;
          dp[i|(1<<k)][k]=min(dp[i][j]+h[j][k],dp[i|(1<<k)][k]);
        }
      }
    }
  }
  /*
  rep(i,R){
    rep(j,R){
      cout<<h[i][j]<<" ";
    }
    cout<<endl;
  }
  rep(i,1<<R){
    rep(j,R){
      if(dp[i][j]==INT_MAX) cout<<"INF ";
      else cout<<setw(3)<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  int ans=INT_MAX;
  rep(i,R) ans=min(ans,dp[(1<<R)-1][i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 1068
n=input()
if n=='SUN':
  print(7)
elif n=="MON":
  print(6)
  
elif n=="TUE":
  print(5)
elif n=="WED":
  print(4)
elif n=="THU":
  print(3)
elif n=="FRI":
  print(2)
elif n=="SAT":
  print(1)

  


Measured memory_bytes: 2940
N = int(input())
 
A = []
max1 = 0
max2 = 0
for _ in range(N):
    ai = int(input())
    if max1 < ai:
        max1 = ai
    elif max2 < ai:
        max2 = ai
 
    A.append((ai, max2, max1))

for i in range(N):
    ai, _, _ = A[i]


    if max1 == ai:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 26824
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    double s = 0;
    for (int i = 0; i < n; i++) {
        double a; std::cin >> a;
        s += 1. / a;
    }
    printf("%.12f\n", 1. / s);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int ans=1,n,k;
	cin>>n>>k;
	for(register int i=1;i<=n;i++)
		ans+=ans<k?ans:k;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t r, D, x[11];
    int64_t ans = 0;

    scanf("%"PRId64"%"PRId64"%"PRId64, &r, &D, &x[0]);

    for (int i = 1; i <=10 ; i++) {
        x[i] = r * x[i - 1] - D;
    }

    for (int i = 1; i <=10; i++) {
        printf("%"PRId64"\n", x[i]);
    }
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int r,d,x;
    int s=0;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++)
    {
        s=(r*x)-d;
        cout<<s<<"\n";
        x=s;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;
  int M[MAX][MAX];
  int  k, c, u, v;
  int minv;
  int d[MAX];
  int vis[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > d[u] + M[u][v] ){
	  d[v] = d[u] + M[u][v];
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}



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

int N, A, B, C;
vector<int> l;
int ans = 1e9;

void dfs(int depth, int a, int b, int c, int merge) {
  if (depth == N) {
    if (a && b && c)
      ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + merge * 10);
    return;
  }
  dfs(depth + 1, a, b, c, merge);
  dfs(depth + 1, a + l.at(depth), b, c, merge + bool(a));
  dfs(depth + 1, a, b + l.at(depth), c, merge + bool(b));
  dfs(depth + 1, a, b, c + l.at(depth), merge + bool(c));
}

int main() {
  scanf("%d%d%d%d", &N, &A, &B, &C);
  l.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &l.at(i));
  }
  dfs(0, 0, 0, 0, 0);
  printf("%d", ans);
  return 0;
}


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

int main() {
  long int n;
  cin >> n;
  long int ans=0;
  rep(i,n){
    if(i%3 !=0 && i%5 !=0){
      ans = ans +i;
    }
  }
  
  cout << ans << endl;
  

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
template<class T>
struct BIT{
    //0-indexed
    vector<T> data;
    BIT(int size){
        data.assign(size+1,0);
    }
    T sum(int k){
        //[0,k]
        T res=0;
        for(++k;k>0;k-=k&-k){
            chmax(res,data[k]);
        }
        return res;
    }
    void add(int k,T x){
        data[k++]=x;
        for(;k<data.size();k+=k&-k){
            chmax(data[k],x);
        }
    }
};
int main(){
    int n;
    cin>>n;
    vi h(n);
    priority_queue<P,vp,greater<P>> que;
    REP(i,n){
        cin>>h[i];
        que.push({h[i],i});
    }
    BIT<ll> tr(n);
    vl a(n);
    REP(i,n){
        cin>>a[i];
    }
    while(que.size()){
        P p=que.top();que.pop();
        tr.add(p.se,tr.sum(p.se-1)+a[p.se]);
    }
    cout<<tr.sum(n-1)<<endl;
    return 0;
}

Measured memory_bytes: 8172
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int z=0,b=0,c=1<<30;
		if(s[0]==1){ }
		else if(a[0]==0){}
		else if(a[0]>0){
			s[0]++;
			Array.Resize(ref a,a.Length+1);
			for(int j=s[0]-1;j>0;j--){a[j]=a[j-1];}
			a[0]=0;
			z=0;
			s[1]++;
		}
		else if(a[s[0]-1]==0){}
		else if(a[s[0]-1]<0){
			s[0]++;
			Array.Resize(ref a,a.Length+1);
			a[s[0]-1]=0;
			z=s[0]-1;
			s[1]++;
		}
		else{
			for(int i=0;i<s[0]-1;i++){
				if(a[i]==0){break;}
				else if(a[i]<0&&a[i+1]>0){
					s[0]++;
					Array.Resize(ref a,a.Length+1);
					for(int j=s[0]-1;j>i;j--){a[j]=a[j-1];}
					a[i+1]=0;
					z=i+1;
					s[1]++;
					break;
				}
			}
		}

		for(int i=Math.Max(0,z-s[1]+1);i<s[0]&&i+s[1]-1<s[0];i++){
			b=Math.Abs(a[i]-a[i+s[1]-1]);
			if(a[i]!=0&&a[i+s[1]-1]!=0){
				b+=Math.Min(Math.Abs(a[z]-a[i]),Math.Abs(a[z]-a[i+s[1]-1]));
			}
			c=Math.Min(c,b);
		}
		if(s[0]==1){c=Math.Abs(a[0]);}
		Console.WriteLine("{0}",c);
	}
}

Measured memory_bytes: 20704
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  ll x;
  cin>>x;
  ll m=100;
  ll ans=0;
  while(m<x){
    m+=m/100;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/


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

	if (6 <= a && a <= 12) {
		cout << b / 2 << endl;
	}
	else if (a <= 5) {
		cout << 0 << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long double
using namespace std;
ll d,t,s;
int32_t main()
{
	cin>>d>>t>>s;
	if(d/t<=s)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    for ( int i = 0 ; i < 3; i++ ){
        for ( int j = 0 ; j < 3 ; j++ ){
            char c; cin >> c;
            if ( i == j ) cout << c;
        }
    }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll now = 0;
    int ans = n;
    rep(i,n){
        now += a[i];
        if(now > x){
            ans = i;
            break;
        }
    }

    if(ans==n&&now!=x) cout << (n-1) << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

int find(int x){
    if(par[x] == x) return x;
    else{
        par[x] = find(par[x]);
        return par[x];
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/

int main(){

	int N;
	cin >> N;
	int A[100];
	int B[100];
	int C[100];

	int X;
	cin >> X;
	for(int i=0;i<X;i++){
		int a;
		cin >> A[i];
	}
		int Y;
		cin >> Y;
	for(int i=0;i<Y;i++){
		int b;
		cin >> B[i];
	}
		int Z;
		cin >> Z;
	for(int i=0;i<Z;i++){
		int a;
		cin >> C[i];
	}

	int answer = Z;
	for(int i=0;i<Z;i++){
		for(int j=0;j<X;j++){

			if(C[i] == A[j]){
				int count = 0;
				for(int k=0;k<Y;k++){
					if(B[k] == A[j]){
						count++;
					}
				}
				if(count == 0){
					answer--;
				}
			}
		}
	}

	cout << answer << endl;
    return 0;
}


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

int main(){
  int X,a,b,c,d,e,f,g;
  cin >> X;
  a = X/500;
  c = a*1000;
  b = X%500;
  d = b/5;
  e = d*5;
  cout << c+e << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define rep0(i,n) for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;
/*ビットxにi番目のフラグが立っているかどうか
if(x & (1 << i))
↑ a << b == a*pow(b,2)
/*{0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1 << n); ++bit)
*/

int main(){
  ll n,q;  cin >> n >> q;
  string s;  cin >> s;
  vll l(n+1),r(n+1);
  rep1(i,q){
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }
  vi t(n+1,0);
  rep0(i,s.size()-1){
    if(s[i] == 'A' and s[i+1] == 'C'){
      t[i+1] = t[i] + 1;
    }else{
      t[i+1] = t[i];
    }
  }
  rep1(i,q){
    cout << t[r[i]] - t[l[i]] << endl;
  }
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
	int a;
	scanf("%d", &a);
	int b = a;
	a*=100;
	a/=108;
//	cout <<a<<endl;
	if (a*108 - a*108%100 == b*100) {
		printf("%d\n", a);
	} else if ((a+1)*108 - (a+1)*108%100 == b*100) {
		printf("%d\n", a+1);
	} else {
		printf(":(\n");
	}
	return 0;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <class Monoid, class OperatorMonoid = Monoid> class LazySegmentTree {
  using F = std::function<Monoid(Monoid, Monoid)>;
  using G = std::function<Monoid(Monoid, OperatorMonoid, int)>;
  using H = std::function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;

  private:
    int n;
    std::vector<Monoid> seg;
    std::vector<OperatorMonoid> lazy;

    const F f;
    const G g;
    const H h;
    const Monoid M1;
    const OperatorMonoid OM1;

    void lazyUpdate(int k, int l, int r) {
      if(lazy[k] == OM1) return;

      seg[k] = g(seg[k], lazy[k], r - l);
      if(r - l > 1) {
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
        lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
      }
      lazy[k] = OM1;
    }

  public:
    LazySegmentTree(int sz, const F f, const G g, const H h, const Monoid &M1, const OperatorMonoid &OM1) : f(f), g(g), h(h), M1(M1), OM1(OM1) {
      n = 1;
      while(n < sz) n *= 2;
      seg.resize(2 * n - 1, M1);
      lazy.resize(2 * n - 1, OM1);
    }

    void update(int a, int b, Monoid x, int k = 0, int l = 0, int r = -1) {
      if(r < 0) r = n;

      lazyUpdate(k, l, r);

      if(b <= l || r <= a) return;

      if(a <= l && r <= b) {
        lazy[k] = h(lazy[k], x);
        lazyUpdate(k, l, r);
      }
      else {
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
      }
    }

    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
      if(r < 0) r = n;

      lazyUpdate(k, l, r);

      if(b <= l || r <= a) return M1;
      if(a <= l && r <= b) return seg[k];
      Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return f(vl, vr);
    }
};

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

  int n, q;
  cin >> n >> q;
  LazySegmentTree<int> seg(n, [](int a, int b){ return min(a, b); },
                              [](int a, int b, int len){ return b; },
                              [](int a, int b){ return b; }, INT_MAX, INT_MAX);
  rep(i, 0, q) {
    int c;
    cin >> c;
    if(c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s, t + 1, x);
    }
    else {
      int x;
      cin >> x;
      cout << seg.query(x, x + 1) << endl;
    }
  }
}


Measured memory_bytes: 4956
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, y) = listOfString()
    println(when{
        x > y -> ">"
        x < y -> "<"
        else -> "="
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37792
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    cout<<((x+1)/2)*(x/2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[44][440][440];
void chmin(int &a,int b){
    if(a > b)a = b;
}
const int INF = 1e18;
signed main(){
    int n,ma,mb;cin >> n >> ma >> mb;
    rep(i,44)rep(j,440)rep(k,440)dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i,n){
        int c;
        int a,b;cin >> a >> b >> c;
        rep(j,440)rep(k,440){
            if(j+a < 440 &&k + b< 440)chmin(dp[i+1][j+a][k+b],dp[i][j][k] + c);
            chmin(dp[i+1][j][k],dp[i][j][k]);
        }
    }
    int ret = INF;
    for(int i = 1;i < 500;i++){
        if(ma*i >= 440 || mb*i >= 440)break;
        chmin(ret,dp[n][ma*i][mb*i]);
    }
    if(ret == INF)ret = -1;
    cout << ret << endl;
    return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  rep(i,n) {
    int price;
    cin >> price;
    pq.push(price);
  }
  int max;
  rep(i,m) {
    max = pq.top();
    pq.pop();
    pq.push(max/2);
  }
  ll ans = 0;
  rep(i,n) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#168 - F
import sys
import numpy as np
#from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    #X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    #Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    X = np.unique(np.concatenate([D, [-INF, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


#@njit
def cal_area(A, B, C, D, E, F, X, Y):
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1

    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    A = A.tolist()
    B = B.tolist()
    C = C.tolist()
    D = D.tolist()
    E = E.tolist()
    F = F.tolist()
    X = X.tolist()
    Y = Y.tolist()
    DX = DX.tolist()
    DY = DY.tolist()

    LenX = len(X)
    LenY = len(Y)

    visit = [[False] * LenY for _ in range(LenX)]
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    for x1, x2, y in zip(A, B, C):
        for x in range(x1, x2):
            LineY[x][y] = True

    for x, y1, y2 in zip(D, E, F):
        for y in range(y1, y2):
            LineX[x][y] = True

    while queue:
        x, y = queue.pop()

        if x == 0 or x == LenX - 1 or y == 0 or y == LenY - 1:
            area = 0
            break
        
        #area += (X[x + 1] - X[x]) * (Y[y + 1] - Y[y])
        area += DX[x] * DY[y]

        if not LineX[x][y] and not visit[x - 1][y]:
            visit[x - 1][y] = True
            queue.append((x - 1, y))
        if not LineY[x][y] and not visit[x][y - 1]:
            visit[x][y - 1] = True
            queue.append((x, y - 1))
        if not LineX[x + 1][y] and not visit[x + 1][y]:
            visit[x + 1][y] = True
            queue.append((x + 1, y))
        if not LineY[x][y + 1] and not visit[x][y + 1]:
            visit[x][y + 1] = True
            queue.append((x, y + 1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


Measured memory_bytes: 65912
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout << v.at(n / 2) - v.at(n / 2 - 1);

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int ans[10];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < 3; i++) ans[i] = -1;
	for (int i = 0; i < M; i++) {
		int s, c;
		cin >> s >> c;
		s--;
		if (ans[s] != -1 && c != ans[s]) {
			cout << -1 << endl;
			return 0;
		}
		if (N != 1 && s == 0 && c == 0) {
			cout << -1 << endl;
			return 0;
		}
		ans[s] = c;
	}
	if (N == 1 && M == 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (i == 0 && ans[i] == -1) cout << 1;
		else if (ans[i] == -1) cout << 0;
		else cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;
 
// ====================================================================
 
int main() {
  ll n;
  cin >> n;
  string s = to_string(n);
  int naka = (n - (s[0] - '0') * pow(10, s.size() - 1)) / 10;
  // cout << naka << endl;
 
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    // 裏返したときの先頭と最後を求める
    int top = i % 10;
    int bottom = i;
    while (bottom / 10) bottom /= 10;
 
    if (top == 0) continue;  // 先頭が0
 
    // 1文字も考えれるとき用
    if (top == bottom && top <= n) ans++;
 
    int len = 2;
    while (len < s.size()) {  // 短い時は中身を単純に000~999のようにできる
      ans += pow(10, len - 2);
      len++;
    }
 
    // nと同じ長さになった時の話をする
    if (s.size() == 1) continue;  // 間に突っ込むという概念がない
    if (top < s[0] - '0')         // 先頭が既に小さいので数字が自由
      ans += pow(10, len - 2);
    else if (top == s[0] - '0') {               // 先頭が同じ！
      if (n % 10 < bottom) {                    // けつがでかいのでnakaはすこし小さい値まで
        if (naka - 1 > 0) ans += naka + 1 - 1;  // 短すぎ予防
      } else {                                  // 先頭も後ろも同じ
        if (len == 2)
          ans += 1;
        else
          ans += naka + 1;
      }
    }  // 先頭がでかかったら何も出来ないので
    // cout << i << " " << top << " " << bottom << " " << ans << endl;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define INF 1000000
int main(){
  int unused __attribute__((unused));
  int K, N, i, max = 0;
  int *A;

  unused = scanf("%d %d", &K, &N);
  A = (int *)malloc(sizeof(int)*N);
  if(A==NULL) exit(0);
  for(i=0; i<N; i++) unused = scanf("%d", &A[i]);

  for(i=0; i<N-1; i++){
    if(max < abs(A[i+1] - A[i])) max = abs(A[i+1] - A[i]);
    //printf("max = %d\n", max);
  }
  if(max < abs(K - A[N-1]) + A[0]) max = abs(K - A[N-1]) + A[0];

  printf("%d", K-max);
  free(A);
  return 0;
}

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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;
typedef vector<ll>              vl;
typedef vector<vl>              vvl;








int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
  cin >> n >> m;
    vip a;
    REP(i,m){
        int b,c;
        cin >> b >> c;
        a.push_back({c,b});
    }
    sort(a.begin(), a.end());
    int t = 0;
    int ans = 0;
    REP(i,m){
        if(t <= a.at(i).second){
            ans++;
            t = a.at(i).first;
        }
    }

    cout << ans << endl;






    return 0;
}

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

using namespace std;

double a[100];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	double n;
	double mean = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		mean += a[i];
	}
	mean /= n;
	if (mean - 0.5 <= floor(mean)) mean = floor(mean);
	else mean = ceil(mean);
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] != mean) ans += ((a[i] - mean) * (a[i] - mean));
	}
	cout << (int) ans << '\n';
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
def isPrime(num):
    a = 2
    if num == 1:
        return False

    while num >= a*a:
        if num%a == 0:
            return False
        a += 1

    return True

if __name__ == '__main__':
    q = int(input())
    a = []
    b = {}
    c = []
    for tmp in range(q):
        l, r = map(int, input().split())
        a.append((l,r))

    for tmp in range(1, (10**5)+1):
        factor = (tmp+1)/2
        if isPrime(tmp) and factor == int(factor) and isPrime(factor):
            b[tmp] = 1
        else:
            b[tmp] = 0
    
    c.append(b[1])
    for tmp in range(2,(10**5)+1):
        if b[tmp]:
            c.append(c[len(c)-1]+1)
        else:
            c.append(c[len(c)-1])

    for tmp in a:
        threshold = tmp[0]-2
        if threshold < 0:
            print(c[tmp[1]-1])
        else:
            print(c[tmp[1]-1]-c[threshold])

Measured memory_bytes: 28652
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    map<int,int>m1;
    int sum = 0;
    rep(i,0,n){
        int x;
        cin>>x;
        m1[x]++;
        sum+=x;
    }
    int q;
    cin>>q;
    while(q--){
        int prev,next;
        cin>>prev>>next;
        sum-=m1[prev]*prev;;
        sum+=m1[prev]*next;
        m1[next]+=m1[prev];
        m1.erase(prev);
        cout<<sum<<endl;


    }

 

 
    
 
    return 0;
}


Measured memory_bytes: 7552
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  const char* a[] = {
    "Christmas Eve Eve Eve",
    "Christmas Eve Eve",
    "Christmas Eve",
    "Christmas"
  };

  int D;

  std::cin >> D;

  std::cout << a[D - 22] << std::endl;

  return 0;
}


Measured memory_bytes: 256