akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    bool pos = false, neg = false;
    rep(i, N){
        if(A[i] > 0) pos = true;
        if(A[i] < 0) neg = true;
    }
    vector<pair<int, int>> ans;
    if(neg & !pos){
        int num = A.back();
        A.pop_back();
        for(int i = A.size()-1; i >= 0; i--){
            ans.push_back(make_pair(num, A[i]));
            num -= A[i];
        }
        cout << num << endl;
    }
    else if(pos & !neg){
        int num = A[0];
        for(int i = 1; i < A.size()-1; i++){
            ans.push_back(make_pair(num, A[i]));
            num -= A[i];
        }
        ans.push_back(make_pair(A.back(), num));
        cout << A.back()-num << endl;
    }
    else if(!pos & !neg){
        rep(i, N-1) ans.push_back(make_pair(0, 0));
        cout << 0 << endl;
    }
    else{
        int save = A.back();
        A.pop_back();
        int num = A[0];
        for(int i = A.size()-1; A[i] > 0; i--){
            ans.push_back(make_pair(num, A[i]));
            num -= A[i];
            A.pop_back();
        }
        A[0] = num;
        for(int i = A.size()-1; i >= 0; i--){
            ans.push_back(make_pair(save, A[i]));
            save -= A[i];
        }
        cout << save << endl;
    }
    rep(i, ans.size()) cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bitset<100005> vis;

void dfs(int v) {
	vis[v]=true;
	for (int i=0; i<adj[v].size(); i++) {
		int nv = adj[v][i];
		if (!vis[nv]) {
			dfs(nv);
		}
	}
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=0; i<m; i++) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		x--; y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans=0;
	for (int i=0; i<n; i++) {
		if (!vis[i]) {
			ans++;
			dfs(i);
		}
	}
	printf("%d\n", ans);
}


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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;
void constructXOR(int A[], int n) 
{ 
    int XOR = 0; 
    for (int i = 0; i < n; i++) 
        XOR ^= A[i]; 
  
    for (int i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 
	     
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int  a[n];
	for(int i=0;i<n;i++)
	{
	     cin>>a[i];
	}
	constructXOR(a,n);
	for(int i=0;i<n;i++)
	{
	     cout<<a[i]<<" ";
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N, M, Q;
    cin >> N >> M >> Q;
    ll MAX = 510;
    vector<vector<ll>> mat(MAX, vector<ll>(MAX, 0));
    rep(i, M) {
        ll L, R;
        cin >> L >> R;
        mat[L][R]++;
    }
    vector<vector<ll>> sum(MAX, vector<ll>(MAX, 0));
    rep(i, MAX-1) {
        rep(j, MAX-1) {
            sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + mat[i][j];
        }
    }
    rep(i, Q) {
        ll p, q;
        cin >> p >> q;
        q++;
        print(sum[q][q] - sum[p][q] - sum[q][p] + sum[p][p]);
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string clor;
  bool status=0;
  
  for(int i=0 ; i<N ; i++){
    cin >> clor;
    if(clor == "Y"){
      status=1;
      break;
    }
  }
  if(status)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
l_arr = []
r_arr = []
 
m.times do
  l, r = gets.chomp.split.map(&:to_i)
  l_arr << l
  r_arr << r
end

ans = r_arr.min - l_arr.max + 1
if ans > 0
  puts ans
else
  puts 0
end


Measured memory_bytes: 3464
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[200010], p[200010];
int main () {
    scanf ("%d", &n);
    for (int i = 1; i <= n; i++) scanf ("%d", &a[i]), p[a[i]] = i;
    int T = 0, f = 0;
    for (int i = n - 1; i >= 1; i--) {
        if (!T) {
            if (p[i] > p[i + 1]) T = 1, f = i + 1;
            continue;
        }
        if (p[f] <= p[i] && p[i] <= p[i + 1]) continue;
        if (p[i] <= p[i + 1] && p[i + 1] <= p[f]) continue;
        if (p[i + 1] <= p[f] && p[f] <= p[i]) continue;
        T++, f = i + 1;
    }
    printf ("%d\n", T);
    return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, p;
    cin >> N;
    int ans = 0, max_p = 0;
    REP(i, N) {
        cin >> p;
        ans += p;
        max_p = max(p, max_p);
    }
    cout << ans - max_p / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void computeLPSArray(char* sub, int subLength, int* lps)
{
	int len = 0;
	lps[0] = 0;
	
	int i = 1;
	while (i < subLength)
	{
		if (sub[i] == sub[len])
		{
			len++;
			lps[i] = len;
			i++;
		}
		else
		{
			if (len != 0)
			{
				len = lps[len-1];
			}
			else
			{
				lps[i] = 0;
				i++;
			}
		}
	}
}

void kmpsearch(char* sub, char* text)
{
	int subLength = strlen(sub);
	int textLength = strlen(text);
	
	int lps[subLength];
	
	computeLPSArray(sub, subLength, lps);
	
	int i = 0;
	int j = 0;
	while (i < textLength)
	{
		if (sub[j] == text[i])
		{
			i++;
			j++;
		}
		
		if (j == subLength)
		{
			printf("%d\n", i-j);
			j = lps[j-1];
		}
		else if (i < textLength && sub[j] != text[i])
		{
			if (j != 0) j = lps[j-1];
			else i = i+1;
		}
	}
}

int main()
{
	char sub[10005];
	char text[1000005];
	scanf("%[^\n]", text);
	getchar();
	scanf("%[^\n]", sub);
	getchar();
	kmpsearch(sub, text);
	return 0;
}


Measured memory_bytes: 2884
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner i = new Scanner(System.in);
        int a = i.nextInt();
        int b = i.nextInt();
        int c = i.nextInt();
        int d = i.nextInt();

        int sum = 0;

        for (int n = 1; n <= b; n++) {
            if(n <= a) {
                sum += c;
            }else{
                break;
            }
        }

        if(a > b) {
            for (int n = b; n < a; n++) {
                sum += d;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 9552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    ll N, X;
    cin >> N >> X;
    ll ans = 1;
    ll d = 0;
    for(ll i = 0; i < N; i++){
        ll l;
        cin >> l;
        d += l;
        if(d <= X)ans++;
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////
pair<ull,ull> p[100005] = {};

int main(){
	int n;
	cin >> n;
	ull cnt = 0;

    rep(i,0,n)cin >> p[n-1-i].first >> p[n-1-i].second;
    
	rep(i,0,n){
       ull a = p[i].first,b = p[i].second;
     
       if((a+cnt)%b != 0)cnt += b-((a+cnt)%b);  
            
       //cout << cnt << endl;
	}

	cout <<cnt << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x)
int main(){
    ll n, m, na = 0, nb = 0, tmp = 0; sc(n), sc(m);
    vector<ll> a(n);
    vector<P> b(m);
    for (int i = 0; i < n; i++) sc(a[i]);
    for (int i = 0; i < m; i++) sc(b[i].second), sc(b[i].first);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<P>());
    ll ans = 0;
    for (int i = 0; i < n; i++){
        if (a[na] > b[nb].first) ans += a[na], na++;
        else {
            ans += b[nb].first;
            tmp++, na++;
            if (b[nb].second == tmp) tmp = 0, nb++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
int main(){
	int a,b,c,d,x=0,y=0;
	std::cin>>a>>b>>c>>d;
	y=(a+b+c+d)%60;
	x=(a+b+c+d)/60;
	std::cout<<x<<std::endl;
	std::cout<<y<<std::endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>

using namespace std;

#define EPS (1e-10)

typedef complex<double> P;
#define EQ(a,b) (abs((a)-(b)) < EPS)
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// a1,a2ツづーツ端ツ点ツづつキツづゥツ静シツ閉ェツづ1,b2ツづーツ端ツ点ツづつキツづゥツ静シツ閉ェツづ個古ーツ債キツ板サツ津ィ
int is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
int is_orthogonal(P a1, P a2, P b1, P b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}
int main(){
	while(1){
		P p[4];
		for(int i = 0; i < 4; i++){
			double x,y;
			cin>>x>>y;
			if(cin.eof())
				return 0;
			p[i]=P(x,y);
		}
		if(is_orthogonal(p[0],p[1],p[2],p[3])){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define For(i,k,n) for(i=k;i<=n;i++)


const  ll modo=1e9+7;

int nod(int n)
{
    int i=0;
    while(n>0)
    {
        i++;
        n/=10;
    }
    return  i;
}



int main()
{
    faf;
    int n;
    cin>>n;
    int ar[n+1];
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];
    ar[0]=0;

    for(i=1;i<=n;i++)
    {
        if(ar[i]>ar[i-1])ar[i]--;
    }
    int fl=0;
    for(i=1;i<n;i++)
    {
        if(ar[i]>ar[i+1])fl=1;
    }
    if(fl)cout<<"No";
    else cout<<"Yes";




    return 0;
}

Measured memory_bytes: 640
-- http://www.lua.org/pil/11.4.html
List = {}
function List.new()
    return setmetatable({first = 0, last = -1}, {__index = List})
end

function List.clone(origin)
    local child = List.new()
    for k,v in pairs(origin) do
        child[k] = v
    end
    return child
end

function List:count()
    return self.last - (self.first - 1)
end

function List:pushleft(value)
    local first = self.first - 1
    self.first = first
    self[first] = value
end

function List:pushright(value)
    local last = self.last + 1
    self.last = last
    self[last] = value
end

function List:popleft()
    local first = self.first
    if first > self.last then error("list is empty") end
    local value = self[first]
    self[first] = nil -- to allow garbage collection
    self.first = first + 1
    return value
end

function List:popright()
    local last = self.last
    if self.first > last then error("list is empty") end
    local value = self[last]
    self[last] = nil -- to allow garbage collection
    self.last = last - 1
    return value
end

---
local q = List.new()
local N = io.read("n")
local last_is_right
for i=1,N do
    if i % 2 == 1 then
        q:pushright(io.read("n"))
        last_is_right = true
    else
        q:pushleft(io.read("n"))
        last_is_right = false
    end
end
local b = {}
if last_is_right then
    for i=1,N do
        table.insert(b, q:popright())
    end
else
    for i=1,N do
        table.insert(b, q:popleft())
    end
end
print(table.concat(b, " "))

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

int main() {
  int n, k;
  cin >> n >> k;
  int s = 1;
  rep(i,n){
    if(2*s<=s+k){
      s = s*2;
    }
    else {
      s = s+k;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

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

    int X = (int)(N / 1.08);
    if ((int)(X*1.08) == N) System.out.println(X);
    else if ((int)((X+1)*1.08) == N) System.out.println(X+1);
    else System.out.println(":(");
  }
}


Measured memory_bytes: 21844
from collections import deque
import sys
imput = sys.stdin.readline


n = int(input())
p = list(map(int, input().split()))

cost = [0] * (n * n)
for i in range(n):
    for j in range(n):
        cost[i * n + j] = min(i, j, n - i - 1, n - j - 1)

occ = [True] * (n * n)
ans = 0
for start in p:
    start -= 1
    q = deque([start])
    ans += cost[start]
    occ[start] = False
    while q:
        ij = q.popleft()
        i, j = divmod(ij, n)

        nxt_ij = (i + 1) * n + j
        if not(0 <= i + 1 < n and 0 <= j < n):
             pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)
              
        nxt_ij = (i - 1) * n + j
        if not(0 <= i - 1 < n and 0 <= j < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)

        nxt_ij = i * n + (j + 1)
        if not(0 <= i + 0 < n and 0 <= j + 1 < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)

        nxt_ij = i * n + (j - 1)
        if not(0 <= i < n and 0 <= j - 1 < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)
print(ans)

Measured memory_bytes: 115588
#include<iostream>
#include<string>

int main(){
	std::string s;
	std::cin>>s;

	int len= s.size();
	int mid= len/2;
	int left, right;
	char lPrev, rPrev;

	if(len%2==0)
		left= mid-1, right= mid;
	else
		left= mid, right= mid;

	lPrev= s[left], rPrev= s[right];

	for(; left>=0 && right<=len-1; left--, right++){
		if(s[left]!=s[right] || s[left]!= lPrev || s[right]!= rPrev)
			break;

		lPrev= s[left], rPrev=s[right];
	}
	
	std::cout<<std::max(right, len-right)<<std::endl;

	return 0;
}

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

int64_t beki(int64_t n,int64_t x){
 int64_t s,ans;
  s=(n*n)%1000000007;
  ans=(s*n)%1000000007;
  return ans;}

int main() {
int64_t n,k,a;
  a=0;
  n=3;
  cin>>k;
  vector<int64_t> ans(k);
  ans.at(k-1)=1;
  for(int64_t i=k-2;i>=0;i--){
  ans.at(i)=beki(k/(i+1),3);
    for(int64_t j=1;(i+1)*j<=k;j++){
    ans.at(i)=ans.at(i)-ans.at((i+1)*j-1);
     }
    ans.at(i)=ans.at(i)+beki(k/(i+1),3);
  }
  for(int64_t i=0;i<k;i++){a=a+(i+1)*ans.at(i);
  while(a>=1000000007){a=a-1000000007;}}
  cout<<a<<endl;
}  

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;

  int n = s.size();
  vector<int> v(26, 0);
  for(int i = n-1; i >= 0; i--){
    v[s[i] - 'a'] = 1;
  }
  if(accumulate(v.begin(),v.end(),0) != 26){
    for(char c = 'a'; c <= 'z'; c++){
      if(v[c - 'a'] == 0){
        cout << s + c << endl;
        return 0;
      }
    }
  }
  for(int i = n-1; i >= 0; i--){
    char c = s[i];
    while(v[c - 'a'] == 1){
      c++;
      if(c > 'z') break;
    }
    if(c > 'z'){
      v[s[i] - 'a'] = 0;
      continue;
    }
    else {
      s[i] = c;
      cout << s.substr(0, i+1) << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define INF 1000000007
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> v;
    int sumDist = 0;
    int maxDist = 0;
    // v[i-1]とv[i]の差を計算していって、一番でかいやつを含まないルートを通る
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (i > 0) {
            int dist = tmp - v[i-1];
            sumDist += dist;
            maxDist = max(maxDist, dist);
        }
        v.push_back(tmp);
    }
    int lastDist = k - v[n-1] + v[0];
    sumDist += lastDist;
    maxDist = max(maxDist, lastDist);
    sumDist -= maxDist;
    cout << sumDist << endl;

    return 0;
}


Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	rs := reverseString(s)
	mod := 2019
	x := 1
	tot := 0
	cnt := make([]int, mod)
	ans := 0
	for i := 0; i < len(rs); i++ {
		cnt[tot]++
		tot += int(rs[i]-'0') * x
		tot %= mod
		ans += cnt[tot]
		x = x * 10 % mod
	}
	fmt.Println(ans)
}

// func main() {
// 	r := bufio.NewReader(os.Stdin)
// 	var s string
// 	fmt.Fscan(r, &s)
// 	nums := make([]int, len(s))
// 	for i := 0; i < len(s); i++ {
// 		num, _ := strconv.Atoi(string(s[i]))
// 		nums[i] = num
// 	}

// 	// 2019 = 3 * 673
// 	c := make([]int, len(s)+2)
// 	c[1] = nums[0]
// 	for i := 1; i < len(s); i++ {
// 		c[i+1] = c[i] + nums[i]
// 	}

// 	ans := 0
// 	for i := 0; i < len(s)-4; i++ {
// 		for j := i + 4; j < len(s); j++ {
// 			tmp := c[j+1] - c[i]
// 			if tmp%3 == 0 {
// 				mul := 1
// 				num := 0
// 				for k := j; k >= i; k-- {
// 					num += nums[k] * mul
// 					mul *= 10
// 				}
// 				if num%673 == 0 {
// 					ans++
// 				}
// 			}
// 		}
// 	}

// 	fmt.Println(ans)
// }

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


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

int vacationpoints(int n,int activities[][3])
{
    if(n==1)
        return max(activities[0][0],max(activities[0][1],activities[0][2]));
    //int activities[n][3];
    
    for(int i=0;i<n;i++)
    {
        // activities[i][0]=activities[i][0];
        // activities[i][1]=activities[i][1];
        // activities[i][2]=activities[i][2];
        if(i>0)
        {
            activities[i][0]+=max(activities[i-1][1],activities[i-1][2]);
            activities[i][1]+=max(activities[i-1][0],activities[i-1][2]);
            activities[i][2]+=max(activities[i-1][0],activities[i-1][1]);
        }
    }
    // for(int j=0;j<n;j++)
    // {
    //     for(int i=0;i<3;i++)
    //         cout<<activities[j][i]<<" ";
    //     cout<<endl;
    // }
    return max(activities[n-1][0],max(activities[n-1][1],activities[n-1][2]));
}


int main()
{
    int n;
    cin>>n;
    int activities[n][3];
    for(int j=0;j<n;j++)
        for(int i=0;i<3;i++)
            cin>>activities[j][i];
    cout<<vacationpoints(n,activities)<<endl;
}

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

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


N,K = map(int,input().split())
if K == 1:
    ans = 0
else:
    ans = N-K
print(ans)


Measured memory_bytes: 6860
#include<stdio.h>

int main(){
  int x[5];
  scanf("%d%d%d%d%d",&x[0],&x[1],&x[2],&x[3],&x[4]);
  for(int i=0;i<5;i++){
   if(x[i]==0){
     printf("%d",i+1);
     break;
   }
  }
 return 0; 
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  string l; cin >> l;
  reverse(all(l));

  int n = sz(l);
  vl a(n+1),b(n+1);
  a[0] = 1; b[0] = 0;
  rep(i,n) {
    if(l[i] == '1'){
      a[i+1] = (a[i]+b[i]) + 2*a[i];
      b[i+1] = 2*b[i];
    }
    else{
      a[i+1] = a[i];
      b[i+1] = 2*(a[i] + b[i]) + b[i];
    }
    a[i+1] %= MOD;
    b[i+1] %= MOD;
  }

  cout << a[n] << endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>num(1e3+100,1);
    for(ll i=0;i<=n;i++){
        ll number=i;
        for(ll j=2;j<=i;j++){
            while(number%j==0){
                num[j]++;
                number/=j;
            }
        }
    }
    ll ans=1;
    for(ll i=2;i<=n;i++){
        ans*=num[i];
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
N = int(input())
a = list(map(int, input().split()))
# 初期値
snuke = a[0]
araiguma = sum(a) - a[0]
ans = abs(snuke - araiguma)
# 更新
for i in range(1, N - 1):
    snuke += a[i]
    araiguma -= a[i]
    ans = min(ans, abs(snuke - araiguma))
# 出力
print(ans)


Measured memory_bytes: 24832
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void solve(){
    int t[5];
    for(int i=0;i<5;i++)
        cin>>t[i];
    for(int i=0;i<5;i++){
        if(t[i]==0){
            cout<<i+1;
            return ;
        }
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 }


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

// ll fun(ll i,ll n, ll w,  vector<vector<ll>> dp)
// {

// }

int main()
{
    ll n,w;
    cin>>n>>w;
    vector<vector<ll>> wv(n,vector<ll> (2,0));
    for(int i=0;i<n;i++)
    {
        cin>>wv[i][0]>>wv[i][1];
    }
    vector<vector<ll>> dp(n+1,vector<ll> (w+1,0));
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<w+1;j++)
        {
            if(j-wv[i-1][0]>=0)
                dp[i][j]=max(dp[i-1][j],wv[i-1][1]+dp[i-1][j-wv[i-1][0]]);
            else
                dp[i][j]=dp[i-1][j];
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
  
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 83012
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] dp = new int[n+1];

		Arrays.fill(dp, -1);

		/*メモ化!!!
		int ans = fib(n,dp);

		System.out.println(ans);
		 */

		dp[0] = 1;

		dp[1] = 1;

		for(int i=2;i<=n;i++) {

			dp[i] = dp[i-1] + dp[i-2];
		}

		System.out.println(dp[n]);
	}

	/*メモ化!!!
	static int fib(int n, int[] dp) {

		if(n==0 || n==1) {

			dp[n] = 1;

			return dp[n];

		}else if(dp[n] != -1){

			return dp[n];
		}

		return fib(n-1,dp) + fib(n-2,dp);

	}*/

}



Measured memory_bytes: 26404
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////



int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  string n;cin>>n;
  int yes=0;
  for(auto&c:n)if(c=='9')yes=1;
  cout << (yes ? "Yes":"No") << nl;
  
  return 0;
};


Measured memory_bytes: 256
import numpy as np
N, H = map(int, input().split())
A, B = np.array(tuple(tuple(map(int, input().split())) for _ in range(N))).T

m = A.max()
B.sort()
C = iter(B[B > m][::-1])

count = 0

try:
    while H > 0:
        H -= next(C)
        count += 1
except StopIteration:
    Q, R = divmod(H, m)
    print(count + Q + bool(R))
else:
    print(count)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int H,N;
  cin>>H>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];

  vector<vector<ll>>dp(N+1,vector<ll>(H+1,LONG_MAX/2));
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=H;j++){
      dp[i+1][j]=min(dp[i][j],dp[i+1][max(j-A[i],0)]+B[i]);
    }
  }

  cout<<dp[N][H]<<endl;
  return 0;
}


Measured memory_bytes: 78592
#include<stdio.h>
main(){
  int a[100],i,max=0;
  for(i=0;i<100;i++)a[i]=0;
  while(scanf("%d",&i)!=EOF)a[i-1]++;
  for(i=0;i<100;i++)if(a[i]>max)max=a[i];
  for(i=0;i<100;i++)if(a[i]==max)printf("%d\n",i+1);
  return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep2(i, n) for(ll i = 2; i <=(ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    cin >> n;
    ll x[n], y[n];
    ll zmax = -1;
    ll zmin = 2*1e9;
    ll wmax = -1e9;
    ll wmin = 1e9;
    rep0(i, n-1){
        ll x,y;
        cin >> x >> y;
        zmax = max(zmax, x+y);
        wmax = max(wmax, x-y);
        zmin = min(zmin, x+y);
        wmin = min(wmin, x-y);
    }
    ll ans = max(zmax - zmin, wmax - wmin);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
//Name: Surf Smelt Fishing Contest II
//Level: 3
//Category: データ構造,分割統治,Segment Tree
//Note:

/**
 * Segment Treeなどの完全二分木を使って分割統治する。
 * ある葉が更新された時は、ノードを上へたどりながら「そのノードを根とするサブツリーでの優勝者」をメンテナンスする。
 *
 * オーダーは O(Q log N)。
 */
#include <iostream>
#include <vector>

using namespace std;

template <class T>
struct SegmentTree/*{{{*/
{
    vector<T> nodes;
    int size;
    SegmentTree(int size) : size(size) {
        nodes.resize(size*4);
    }

    T get() {
        return nodes[0];
    }

    void add_inner(int target, size_t pos, int pl, int pr, T val) {
        if(pl+1 == pr) {
            nodes[pos].first += val.first;
            nodes[pos].second += val.second;
        } else {
            const int center = (pl+pr)/2;
            if(target < center) {
                add_inner(target, pos*2+1, pl, center, val);
            } else {
                add_inner(target, pos*2+2, center, pr, val);
            }
            const auto lhs = nodes[pos*2+1];
            const auto rhs = nodes[pos*2+2];
            nodes[pos] = max(lhs, rhs);
        }
    }

    void add(int target, T val) {
        add_inner(target, 0, 0, size, val);
    }
};/*}}}*/

int nextpow2(int n) {
    int ans = 1;
    while(ans < n) {
        ans <<= 1;
    }
    return ans;
}

bool solve() {
    int N, Q;
    if(!(cin >> N >> Q)) return false;
    if(!N && !Q) return false;

    SegmentTree<pair<int,int>> tree(nextpow2(N));
    for(int i = 0; i < N; ++i) {
        tree.add(i, make_pair(0, -i));
    }
    for(int i = 0; i < Q; ++i) {
        int a, v;
        cin >> a >> v;
        tree.add(a-1, make_pair(v, 0));
        const auto ans = tree.get();
        cout << -ans.second+1 << ' ' << ans.first << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

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

int n,q;
vector<ll> rc,dp;
vector<vector<int>> child;

void dfs(int r,ll count){
    dp[r]=count+rc[r];
    for(int i:child[r]){
        dfs(i,dp[r]);
    }
}

int main(){
    cin>>n>>q;
    rc.resize(n,0);
    dp.resize(n,-1);
    child.resize(n,vector<int>(0));
    for(int i=0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        child[a-1].push_back(b-1);
    }
    for(int i=0; i<q; i++){
        ll p,x;
        cin>>p>>x;
        rc[p-1]+=x;
    }
    dp[0]=0;
    dfs(0,dp[0]);
    for(int i=0; i<n; i++){
        cout<<dp[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 22656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vaibhav ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{ vaibhav

  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];

  sort(a,a+n);
  double mu=2;
  for(int i=2;i<n;i++)
  {
    a[i]=a[i]*mu;
    mu=mu*2;
  }
  for(int i=0;i<n;i++)
  {
    a[i]=a[i]/mu;
  }
  double sso=accumulate(a,a+n,(double)0);
  cout<<setprecision(7)<<sso;


  return 0;
  
}

 

Measured memory_bytes: 256
#include <stdio.h>

int p[1000000];

int main(void)
{
	int n;
	int i, j;
	
	p[0] = p[1] = 0;
	for (i = 2; i < 1000000; i++){
		p[i] = 1;
	}
	
	for (i = 2; i * i < 1000000; i++){
		for (j = i * i; j < 1000000; j += i){
			p[j] = 0;
		}
	}
	
	for (i = 1; i < 1000000; i++){
		p[i] += p[i - 1];
	}
	
	while (scanf("%d", &n) != EOF){
		printf("%d\n", p[n]);
	}
	
	return (0);
}

Measured memory_bytes: 4496
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

for i in range(int(N**0.5)+1, 0, -1):
	if N%i == 0:
		a = i
		b = N//i
		break

print(max(len(str(a)), len(str(b))))


Measured memory_bytes: 13788
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int g[15][15];
bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	ll n;
	cin >> n;
	ll ans = n * (n - 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define MAXN 105
#define MAXM 105

char G[MAXN][MAXM];//'V' biao shi yi fang wen guo le 
char Vec[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
char ttmp;
int n,m;

void DFS(int i,int j)
{

// 	for (int ni=0;ni<n+2;++ni)
// 	{
// 		for (int mi=0;mi<m+2;++mi)
// 		{
// 			printf("%c ",G[ni][mi]);
// 		}
// 		printf("\n");
// 	}
// 	printf("%c\n",ttmp);
// 
// 
	if (G[i][j]=='V')
	{
		return ;
	}
	G[i][j]='V';
	for (int ii=0;ii<4;++ii)
	{
		if (G[i+Vec[ii][0]][j+Vec[ii][1]]==ttmp)
		{
			DFS(i+Vec[ii][0],j+Vec[ii][1]);
		}
	}
	return ;
}

int main()
{
	while (scanf("%d%d",&n,&m),n)
	{
		int res=0;
		for (int kkn=0;kkn<n+2;++kkn)
		{
			G[kkn][0]=G[kkn][m+1]='V';
		}
		for (int kkm=0;kkm<m+2;++kkm)
		{
			G[0][kkm]=G[n+1][kkm]='V';
		}
		for (int nii=0;nii<n;++nii)
		{
			for (int mii=0;mii<m;++mii)
			{
				while(scanf("%c",&G[nii+1][mii+1]),G[nii+1][mii+1]=='\n'){};
			}
		}
// 		for (int ni=0;ni<n+2;++ni)
// 		{
// 			for (int mi=0;mi<m+2;++mi)
// 			{
// 				printf("%c ",G[ni][mi]);
// 			}
// 			printf("\n");
// 		}
		for (int qn=0;qn<n;++qn)
		{
			for (int qm=0;qm<m;++qm)
			{
				if (G[qn+1][qm+1]!='V')
				{
					++res;
					ttmp=G[qn+1][qm+1];
					DFS(qn+1,qm+1);
				}
			}
		}
		printf("%d\n",res);
		n=m=0;
	}
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}

//main code

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	VL p(n), q(n);
	cin >> p >> q;
	VL a(n);
	for (int i = 0; i < n; i++) {
		a[i] = i+1;
	}
	int x,y;
	LL c = 0;
	do {
		if (a == p) {
			x = c;
		}
		if (a == q) {
			y = c;
		}
		c++;
	} while(whole(next_permutation, a));
	cout << abs(x-y) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt[100009];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    cnt[a]++;
  }
  int ans=-1;
  for(int i=1;i<=100000;i++){
    ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
  }
  cout<<ans<<endl;
  return(0);
}
    


Measured memory_bytes: 640
import bisect

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

print(d[(n // 2)] - d[(n // 2) - 1])

"""
for k in range(d[n // 2], d[(n // 2) + 1]):
    if bisect.bisect_left(d, k) == n // 2:
        ans += 1
"""

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    int n; cin >> n;
    int ans = 0;
    rep(i,n+1){
        if(i % 2 == 0) continue;
        int cnt = 0;
        for(int j = 1; j*j <= i; j++){
            if(i % j == 0){
                if(j * j == i) cnt++;
                else cnt += 2;
            }
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize
    }

    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;
 
int main() {
	ll N,T;
  	cin >> N >> T;
  	vll t(N);
  	rep(i,N){
    	cin >> t[i];
    }
  	ll ans=T;
  	rep(i,N-1){
    	if(t[i+1] - t[i] >= T) ans += T;
      	else ans += t[i+1] - t[i];
    }
  	cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int a, b;
	cin >> a >> b;
	for(int  i = 1; i <= 2000; i++) {
		int t1 = i * 0.08;
		int t2 = i * 0.1;
		if(t1 == a && t2 == b) {
			cout << i << endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, a[200][3];
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < n; k++) {
                if (a[i][j] == a[k][j] && i != k) {
                    break;
                }
                if (k == n - 1) {
                    sum += a[i][j];
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		boolean isPrime[] = new boolean[1<<15];
		for(int i=2; i<(1<<15); i++) isPrime[i] = true;
		isPrime[0] = false;
		isPrime[1] = false;
		for(int i=2; i*i<(1<<15); i++){
			if(isPrime[i]){
				for(int j=2*i; j<(1<<15); j+=i){
					isPrime[j] = false;
				}
			}
		}

		while(true){
			int n = in.nextInt();
			if(n==0) return ;
			int cnt=0;
			for(int i=2; i<=n/2; i++){
				if(isPrime[i] && isPrime[n-i]) cnt++;
			}
			System.out.println(cnt);
		}
	}
	
}

Measured memory_bytes: 12000