akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
 

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    int n,k;
    cin>>n>>k;
    if(k==0)
    {
        cout<<n*n;
    }
    else
    {
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            ans-=(n/i)*(min(k-1,i-1)+1);
            ans-=(min(k-1,n%i))+1;
            ans+=n+1;
        }
        cout<<ans<<endl;
    }
    
    
}

Measured memory_bytes: 3608
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x;
    cin>>x;
    if(x>=400 && x<=599)
    cout<<8<<"\n";
    if(x>=600 && x<=799)
    cout<<7<<"\n";
    if(x>=800 && x<=999)
    cout<<6<<"\n";
    if(x>=1000 && x<=1199)
    cout<<5<<"\n";
    if(x>=1200 && x<=1399)
    cout<<4<<"\n";
    if(x>=1400 && x<=1599)
    cout<<3<<"\n";
    if(x>=1600 && x<=1799)
    cout<<2<<"\n";
    if(x>=1800 && x<=1999)
    cout<<1<<"\n";
    
    return 0;
}


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

int d_sum(int n)
{
	int sum = 0;
	while (n > 0)
	{
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int  main()
{
	int n; cin >> n;
	if (n % d_sum(n) == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

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

Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(N)]

AB.sort(reverse=True)
CD.sort()

res = 0
for a,b in AB:
    tmp = -1
    for i in range(N):
        if CD[i] != -1:
            c,d = CD[i]
            if a < c and b < d:
                if tmp == -1:
                    tmp = i
                else:
                    if CD[tmp][1] > CD[i][1]:
                        tmp = i
    if tmp != -1:
        CD[tmp] = -1
        res += 1
print(res)

Measured memory_bytes: 39280
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll p;
mat t;
vll d;

lli depth(lli x){
    if(p[x] == -1) return d[x] = 0;
    if(d[x]) return d[x];
    return d[x] = depth(p[x]) + 1;
}

int main(){
    cin >> n;
    p = vll(n,-1);
    t = mat(n);
    d = vll(n);
    for(lli i = 0;i < n;i++){
        lli node,k;
        cin >> node >> k;
        for(lli j = 0;j < k;j++){
            lli c;
            cin >> c;
            t[node].push_back(c);
            p[c] = node;
        }
    }
    for(lli i = 0;i < n;i++){
        cout << "node " << i << ": ";
        cout << "parent = " << p[i] << ", ";
        cout << "depth = " << depth(i) << ", ";
        if(p[i] == -1) cout << "root, ";
        else if(t[i].size() == 0) cout << "leaf, ";
        else cout << "internal node, ";
        cout << "[";
        for(lli j = 0;j < t[i].size();){
            cout << t[i][j];
            if(++j < t[i].size()) cout << ", ";
        }
        cout << "]" << endl;
    }
    return 0;
}

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

int main(){
	int N; cin>>N;
	int ans = 0;
	int count = 0;
	int pre, now; cin>>pre;;
	for(int i=1; i<N; ++i){
		cin>>now;
		ans = max(ans, (count = pre>=now? count+1: 0));
		pre = now;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

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

using namespace std;

const int inf = 6e3;

int n, k;
int a[5000];
int dp[5001][5000];

int judge(int x){
  fill_n((int*)dp, 5001 * 5000, 0);
  dp[0][0] = 1;
  for(int i = 1; i <= n; ++i){
    rep(j, k){
      dp[i][j] = dp[i - 1][j];
      if(i - 1 != x && j >= a[i - 1]){
        dp[i][j] = dp[i - 1][j - a[i - 1]] || dp[i][j];
      }
    }
  }
  for(int i = max(k - a[x], 0); i < k; ++i){
    if(dp[n][i]){
      return true;
    }
  }
  return false;
}

int main(){
  cin >> n >> k;
  rep(i, n){
    cin >> a[i];
  }
  sort(a, a + n);

  int l = -1;
  int r = n;
  while(r - l > 1){
    int m = (l + r) / 2;
    if(judge(m)){
      r = m;
    }
    else{
      l = m;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 97920
#include<stdio.h>
#include<math.h>
main()
{
    int n;
    scanf("%d",&n);
    int ans;
    for(long long i=1;i<=n;i++)
    {
        if((i)*(i+1) >=2*n)
        {
            printf("%lld",i);
            return 0;
        }
    }

}


Measured memory_bytes: 128
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
using ll = long long;
template <typename T = int> using P = pair<T, T>;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T = int>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n, m;
  cin >> n >> m;

  int _l = 0, _r = getINF<int>();
  for(int _ = 0; _ < m; _++) {
    int l, r;
    cin >> l >> r;
    _l = max(_l, l);
    _r = min(_r, r);
  }

  if(_r - _l + 1 <= 0) cout << 0 << endl;
  else cout << _r - _l + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

struct league{
	string name;
	int win,lose,draw,point;	
};

int main(){
	int n,cnt=0;
	while(cin>>n,n){
		if(cnt>0)cout<<endl;
		league inp[n],alt;
		string s;
		int w,l,d;
		rep(i,n){
			cin>>s>>w>>l>>d;
			inp[i].name=s;
			inp[i].win=w;
			inp[i].lose=l;
			inp[i].draw=d;
			inp[i].point=inp[i].win*3+inp[i].draw;
		}
		rep(i,n){
			for(int j=n-2;j>=i;j--){
				if(inp[j+1].point>inp[j].point){
					alt=inp[j+1];
					inp[j+1]=inp[j];
					inp[j]=alt;
				}
			}
		}
		rep(i,n){
			cout<<inp[i].name<<","<<inp[i].point<<endl;
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 1212
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
if n == 2
  puts (arr[0] - arr[1]).abs
  exit 0
end
kuma = arr.inject(&:+)
sunuke = 0
min = 10**9

arr[0..-2].each do |i|
	sunuke += i
	kuma -= i
	diff = (kuma-sunuke).abs

	if diff==0
		puts 0
		exit 0
	end
	min = diff if min>diff
end
puts min

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

using CP = complex<long double>;
#define X real()
#define Y imag()
const long double PI = acos(-1);
const long double EPS = 1e10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }

CP intersection(CP a, CP b, CP c, CP d) {
  return a + (b - a) * (cross(d - c, c - a) /
                        cross(d - c, b - a));
}

bool on_seg(CP a, CP b, CP p) {
  // if not use end point, dot(a - p, b - p) < 0
  return abs(cross(a - p, b - p)) <= 1e-10 &&
         dot(a - p, b - p) <= 0;
}

// crossing lines? (a,b) and (c,d)
bool iscross(CP a, CP b, CP c, CP d) {
  // parallel
  if(abs(cross(a - b, c - d)) <= 1e-10) {
    return on_seg(a, b, c) || on_seg(a, b, d) ||
           on_seg(c, d, a) || on_seg(c, d, b);
  }
  CP isp = intersection(a, b, c, d);
  return on_seg(a, b, isp) && on_seg(c, d, isp);
}

struct convex_hull {
  vector<CP> ch;
  int psize;
  convex_hull() {}
  convex_hull(vector<CP> &ps) { calculation(ps); }
  void calculation(vector<CP> &ps) {
    auto lmd = [&](const CP &l, const CP &r) {
      if(l.X != r.X) return l.X < r.X;
      return l.Y < r.Y;
    };
    psize = ps.size();
    sort(ps.begin(), ps.end(), lmd);
    int k = 0;
    ch.resize(psize * 2);
    for(int i = 0; i < psize; ++i) {
      while(k > 1 && cross(ch[k - 1] - ch[k - 2],
                           ps[i] - ch[k - 1]) <= 0)
        --k;
      ch[k++] = ps[i];
    }
    for(int i = psize - 2, t = k; i >= 0; --i) {
      while(k > t && cross(ch[k - 1] - ch[k - 2],
                           ps[i] - ch[k - 1]) <= 0)
        --k;
      ch[k++] = ps[i];
    }
    ch.resize(k - 1);
    psize = ch.size();
  }
};

long long n;
vector<CP> v;
convex_hull now;

long double solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v.push_back(CP(x, y));
  }
  cout << fixed << setprecision(12);
  cout << solve() << endl;
  return 0;
}

long double solve() {
  now.ch.push_back(CP(0, 0));
  now.psize = 1;
  for(int i = 0; i < n; ++i) {
    vector<CP> tmp;
    for(int j = 0; j < now.psize; ++j) {
      CP nextp = now.ch[j];
      tmp.push_back(nextp);
      tmp.push_back(nextp + v[i]);
    }
    now = convex_hull(tmp);
  }
  long double ans = 0.0;
  for(int i = 0; i < now.psize; ++i)
    ans = max(ans, abs(now.ch[i]));
  return ans;
}

Measured memory_bytes: 384
n, q = list(map(int, input().split(" ")))
s = input()
l = q*[0]
r = q*[0]
for i in range(q):
    l[i], r[i] = list(map(int, input().split(" ")))


AC = (n)*[0]
for i in range(len(s)-1):
    if(s[i:i+2] == "AC"): AC[i+1] += AC[i] + 1
    else: AC[i+1] = AC[i]

for i in range(q):
    print(AC[r[i]-1]-AC[l[i]-1])

Measured memory_bytes: 14212
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n, m, x, c[13], a[13][13];

ll dfs(vector<bool> used) {
  if (used.size() == n) {
    ll sum = 0;
    ll spec[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    rep(i, n) {
      if (used[i]) {
        sum += c[i];
        rep(j, m) {
          spec[j] += a[i][j];
        }
      }
    }
    rep(i, m) {
      if (spec[i] < x) {
        return 100000000;
      }
    }
    return sum;
  }
  vector<bool> used1 = used;
  used1.push_back(false);
  vector<bool> used2 = used;
  used2.push_back(true);
  return min(dfs(used1), dfs(used2));
}

int main() {
  cin >> n >> m >> x;
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }

  vector<bool> used;
  ll result = dfs(used);
  if (result > 10000000) {
    cout << "-1" << endl;
    return 0;
  }

  cout << result << endl;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

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

    bool tkhs = false;

    while (true)
    {
        c -= b;
        if (c <= 0)
        {
            tkhs = true;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            tkhs = false;
            break;
        }
    }
    if(tkhs) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3596
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String S = line;
        int placeofW = -1;
        for(int i = S.Length - 1; i >= 0; i--)
        {
            // 最奥のWを見つける
            if (S[i] == 'W')
            {
                placeofW = i;
                break;
            }
        }
        if (placeofW == -1)
        {
            // 動かせない
            Console.WriteLine("0");
            return;
        }
        long count = 0; //動かした回数
        for(int i = placeofW - 1; i >= 0; i--)
        {
            if (S[i] == 'B')
            {
                count += placeofW - i;
                placeofW--;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13240
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()
s = sum(a)
b = 0

for i in a:
    if i >= s/(4*m):
        b+=1

if b >= m:
    print('Yes')
else:
    print('No')

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    bool yes = false;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            if (4 * i + 7 * j == N) {
                yes = true;
                break;
            }
        }
        if (yes) {
            break;
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a,b,q;cin >>a >>b >>q;
    vl s(a),t(b);
    rep(i,a)cin >> s[i];
    rep(i,b)cin >> t[i];
    rep(i,q){
        ll x;cin >> x;
        ll sr=lower_bound(all(s),x)-s.begin();
        ll sl=sr-1;
        ll tr=lower_bound(all(t),x)-t.begin();
        ll tl=tr-1;
        ll ans=INF;
        if(sl>=0&&tl>=0){
            ll l=min(s[sl],t[tl]);
            chmin(ans,x-l);
        }
        if(sr<a&&tl>=0){
            ll l=s[sr]-t[tl]+min(s[sr]-x,x-t[tl]);
            chmin(ans,l);
        }
        if(sr<a&&tr<b){
            ll l=max(s[sr],t[tr]);
            chmin(ans,l-x);
        }
        if(sl>=0&&tr<b){
            ll l=t[tr]-s[sl]+min(t[tr]-x,x-s[sl]);
            chmin(ans,l);
        }
        cout <<ans <<endl;
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  int N;
  cin >> N;

  vector<int> ans(10050, 0);

  for(int i = 1; i < 105; i++) {
    for(int j = 1; j < 105; j++) {
      for(int k = 1; k < 105; k++) {
        int v = i*i + j*j + k*k + i*j + j*k + k*i;
        if(v < 10050) {
          ans[v] += 1;
        }
      }
    }
  }

  for(int i = 0; i < N; i++) {
    cout << ans[i+1] << endl;
  }

  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int totalW = s.back() == 'W';
    vi numsW(n);
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'W') {
            ++totalW;
            numsW[i + 1] = numsW[i] + 1;
        } else {
            numsW[i + 1] = numsW[i];
        }
    }
    int ans = 1e9;
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        cur = numsW[i] + (n - totalW) - (i - numsW[i]);
        if (s[i] == 'E') --cur;
        ans = min(cur, ans);
    }
    cout << ans << endl;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 1812
# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int, input().rstrip().split(' ')))

while True:
    min_value = min(A)
    flag_update = False
    pop_indices = []
    for i, v in enumerate(A):
        if v != min_value:
            flag_update = True
            A[i] = v % min_value
            if A[i] == 0:
                pop_indices.append(i)
    
    for i in pop_indices[::-1]:
        A.pop(i)
            
    if flag_update == False:
        break

print(min_value)
    

Measured memory_bytes: 15020
N = int(input())
c = input()

d = list(c)

i = 0
j = N - 1
result = 0
while True:
    while i < N and d[i] != 'W':
        i += 1
    while j > 0 and d[j] != 'R':
        j -= 1
    if i == N or j == -1 or i >= j:
        break
    d[i] = 'R'
    d[j] = 'W'
    result += 1
print(result)


Measured memory_bytes: 10700
#include <stdio.h>

int main(){
  int h, w;  scanf("%d %d", &h, &w);
  char field[103][103];
  for(int i=0; i<h; i++)
    scanf("%s", field[i]);
  for(int i=0; i<w+2; i++)  printf("#");  puts("");
  for(int i=0; i<h; i++)
    printf("#%s#\n", field[i]);
  for(int i=0; i<w+2; i++)  printf("#");  puts("");

  return 0;
}


Measured memory_bytes: 128
MOD = 1000000007
n = gets.to_i
chars = gets.chomp.split("")
_ = gets.chomp
prev_char = ""
nums = []
chars.each do |char|
  if prev_char == ""
    prev_char = char
  elsif prev_char == char
    nums << 2
    prev_char = ""
  else
    nums << 1
    prev_char = char
  end
end
nums << 1 if prev_char != ""

ans = []
prev_num = 0
if nums.shift == 1
  ans << 3
  prev_num = 1
else
  ans << 6
  prev_num = 2
end

nums.each do |num|
  if prev_num == 1 && num == 1
    ans << 2
  elsif prev_num == 1 && num == 2
    ans << 2
  elsif prev_num == 2 && num == 1
    ans << 1
  else
    ans << 3
  end
  prev_num = num
end

puts ans.inject(1) { |res, num| res * num % MOD }


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
string s,t;
int ans=10000; 
int main()
{
    cin>>s;
    cin>>t;
    for(int i=0;i<s.length()-t.length()+1;i++)
    {
        int c=0;
        for(int j=0;j<t.length();j++)
        {
           if(t[j]!=s[j+i]) c++;
           //cout<<t[j]<<" "<<s[j+i]<<"    ";
        }
        //cout<<endl;
        if(c<ans) ans=c;
    }
    if(ans==10000) cout<<"0";
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define MOD (1000000007)

int main(int argc, char **argv) {
	int n;
	cin >> n;
	ll res = 1;
	REP(i, n) res = (res * (i + 1)) % MOD;
	cout << res << endl;
	return 0;
}


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

#define ull unsigned long long

const int MaxN(2003);
const int MaxL(4000003);
const int Mod(1e9 + 7);

int F[MaxN][MaxN];
int fac[MaxL], rfac[MaxL];

int fexp(int x, int k)
{
	int res = 1;
	for(; k; k >>= 1, x = (ull) x * x % Mod)
		if(k & 1) res = (ull) res * x % Mod;
	return res;
}

inline int C(int n, int m)
{
	return n < m ? 0 : (ull) fac[n] * rfac[m] % Mod * rfac[n - m] % Mod;
}

int main()
{
	int n, K;
#ifdef zxp
	freopen("ball.in", "r", stdin);
	freopen("ball.out", "w", stdout);
#endif
	scanf("%d%d", &n, &K);
	if(K == 1) return puts("1"), 0;
	for(int i = fac[0] = 1; i <= n * K; i++)
		fac[i] = (ull) fac[i - 1] * i % Mod;
	rfac[n * K] = fexp(fac[n * K], Mod - 2);
	for(int i = n * K; i; i--)
		rfac[i - 1] = (ull) rfac[i] * i % Mod;
	F[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++)
		{
			F[i][j] = F[i - 1][j];
			if(j) F[i][j] = (F[i][j] + (ull) (n - j + 1) * C((K - 1) * (n - j + 1) + n - i - 1, K - 2) % Mod * F[i][j - 1]) % Mod;
		}
	printf("%d\n", F[n][n]);
	return 0;
}


Measured memory_bytes: 47104
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    N = int(input())
    if N == 0:
        break
    member = [list(map(int,input().split(" ")))[1:] for i in range(0,N)]
    leaked = list(map(int,input().split(" ")))
    leak_list = [0 for i in range(leaked[0])]
    ans = -1
    for i in range(N):
        count = 0
        for m in member[i]:
            if m in leaked[1:]:
                count += 1
        if count == len(leaked[1:]):
            if ans != -1:
                print(-1)
                break
            else:
                ans = i + 1
    else:
        print(ans)



    

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    ll N;
    cin >> N;
    ll a;
    map<ll, ll> n;
    REP(i, N){
        cin >> a;
        n[a]++;
    }      
    int flag = 0;
    for(auto i : n) {
        if(i.second >= 2){
            flag = 1;
        }
    }  
    if(flag == 1){
        cout << "NO" << endl;
    }else {
        cout << "YES" << endl;
    }

    

    
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 12800
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int bit[50];
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A(N);
    for (auto &i: A) cin >> i;
    for (int j = 0; j < 50; j++) bit[j] = 0;
    for (auto i: A)
    {
        for (int j = 0; i; j++)
        {
            bit[j] += i % 2;
            i /= 2;
        }
    }
    unsigned long long ans = 0, n, ansx = 0, x;

    for (int j = 49; j >= 0; j--)
    {
        n = (unsigned long long)(1) << j;
        cerr << bit[j] << " " << n << " ";
        if (ansx + n > K)
        {
            x = n * bit[j];
        }
        else
        {
            if (bit[j] > N - bit[j]) x = n * bit[j];
            else
            {
                x = n * (N - bit[j]);
                ansx += n;
            }
        }
        cerr << x << endl;
        ans += x;
    }


    cout << ans << endl;
    return 0;
}

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

int n;

int main() {
  cin >> n;
  vector<int> a(3*n);
  rep (i, 3*n) {
    cin >> a[i];
  }
  ll ans = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    ans += a[3*n-i*2-2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4252
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    set<int> st;
    for(int i=0; i<3; i++){
        int a; cin>>a;
        st.emplace(a);
    }

    cout << (st.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int main(){
	ll a,b;
	cin>>a>>b;
	if(a>b)
	cout<<"safe\n";
	else
	cout<<"unsafe\n";
	return 0;
}


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

char s[10][10];

int main(){
	int h, w, cnt1, cnt2;
	scanf("%d %d",&h,&w);
	for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (s[i][j] != '#' || (i == 1 && j == 1) || (i == h && j == w)) continue;
			cnt1 = cnt2 = 0;
			if (i > 1 && s[i - 1][j] == '#') cnt1++;
			if (j > 1 && s[i][j - 1] == '#') cnt1++;
			if (i < h && s[i + 1][j] == '#') cnt2++;
			if (j < w && s[i][j + 1] == '#') cnt2++;
			if (cnt1 != 1 || cnt2 != 1){
				printf("Impossible\n");
				return 0;
			}
		}
	}
	cnt2 = 0;
	if (s[2][1] == '#') cnt2++;
	if (s[1][2] == '#') cnt2++;
	if (s[1][1] != '#' || cnt2 != 1){
		printf("Impossible\n");
		return 0;
	}
	cnt1 = 0;
	if (s[h - 1][w] == '#') cnt1++;
	if (s[h][w - 1] == '#') cnt1++;
	if (s[h][w] != '#' || cnt1 != 1){
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S[2];int k,n,x[4][99999][2],sum,p[4]={1,10,100,1000},q[4],i,j,l,h;char T[15]="0123456789ixcm";
int main(){
cin>>n;
for(i=0;i<n;i++){
cin>>S[0]>>S[1];
for(h=0;h<2;h++){
k=1;
for(l=0;l<S[h].size();l++){
for(j=0;j<14;j++){
if(S[h][l]==T[j]){
if(j/10){
x[j-10][i][h]+=k;k=1;
}
else{
k=j;
}
}
}
}
}
sum=0;
for(j=0;j<4;j++){sum+=(x[j][i][0]+x[j][i][1])*p[j];}
for(j=0;j<4;j++){q[j]=(sum/p[j])%10;}
for(j=3;j>=0;j--){if(q[j]>=2){cout<<q[j];}if(q[j]){cout<<T[10+j];}}cout<<endl;
}
}

Measured memory_bytes: 1280
n = int(input())
search = list(map(int,input().split()))
search.sort()
double = set([])
for i in range(n-1):
    if search[i+1] == search[i]:
        double.add(search[i])
dp = [1]*(search[-1]+1)
for i in search:
    if not dp[i]:
        continue
    if i in double:
        dp[i] = 0
    k = 2*i
    while k <= search[-1]:
        dp[k] = 0
        k += i
print(sum((dp[i] for i in search)))

Measured memory_bytes: 32208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int c=1;
  for(int i=1;i<n;i++)
    if(s.at(i-1)!=s.at(i))
      c++;
  cout<<c<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int count_even(int A[], int k){
  int cnt = 0;
  REP(i, k) if((A[i] & 1) == 0) cnt++;
  return cnt;
}

int main(void){
  int A[3]; vREP(ele, A) cin >> ele;
  sort(A, A+3);
  if(count_even(A, 3) == 0) cout << (lli)A[0] * A[1];
  else cout << "0";
  cout << BR;
  return 0;
}

Measured memory_bytes: 632
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>

# define FILE
using namespace std;

const int N = 1e5 + 100;

int n, d[N];

int main()
{
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );

    cin >> n;
    for( int i = 0; i < n; i ++ ){
        cin >> d[i];
    }
    sort( d, d + n );

    cout << d[n/2]-d[n/2-1] << endl;
}


Measured memory_bytes: 640
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=105;
const int maxm=10005;
int h,w,n,pos,dir;
int a[maxm],ans[maxn][maxn];

int main(){
	ios::sync_with_stdio(false);
	cin>>h>>w;
	cin>>n;
	REP(i,n)cin>>a[i];
	int cur=0;
	REP(i,n){
		while(a[i]--){
			if(!dir){
				ans[pos][cur]=i;
				pos++;
				if(pos==h)pos--,cur++,dir^=1;
			}
			else{
				ans[pos][cur]=i;
				pos--;
				if(pos<0)pos++,cur++,dir^=1;
			}
		}
	} 
	rep(i,h){
		rep(j,w)cout<<ans[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repk(i,n,k) for(int i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    bool flag=0;
    ll temp,ans=1;
    rep(i,n){
        cin >> temp;
        if(temp==0){
            flag = 0;
            ans = 0;
            break;
        }
        if(ans > LINF/temp || ans >= LINF+1){
            flag = 1;
            ans = 1;
        }
        ans *= temp;
    }
    if(flag) print(-1);
    else print(ans);

    return 0;
}

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

using namespace std;
string x , y;
int f[3003][3003];
int trace[3003][3003][2];
char q[3003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>x>>y;
    int l = x.length();
    int r = y.length();
    for (int i = 0; i <= max(l, r); i++) {
        f[0][i] = 0;
        f[i][0] = 0;
    }

    for(int i = 1 ;i <= l ; i++)
    {
        for(int j = 1; j <= r; j++)
        {
            if(x[i-1] == y[j-1])
            {
                f[i][j] = f[i-1][j-1] +1;
                trace[i][j][0] = i - 1;
                trace[i][j][1] = j - 1;
            }
            else
            {
                if (f[i-1][j] > f[i][j-1]) {
                    f[i][j] = f[i-1][j];
                    trace[i][j][0] = i-1;
                    trace[i][j][1] = j;
                } else {
                    f[i][j] = f[i][j-1];
                    trace[i][j][0] = i;
                    trace[i][j][1] = j - 1;
                }
            }
        }
    }

    int g = 1;
    int a = l;
    int b = r;
    while(a > 0 && b > 0)
    {
        int next_a = trace[a][b][0];
        int next_b = trace[a][b][1];

        if (next_a + 1 == a && next_b + 1 == b) {
            q[g] = x[a-1];
            g++;
        }
        a = next_a;
        b = next_b;
    }
    //cout<<g-1;
    for(int i = g-1; i>= 1; i--)
    {
        cout<<q[i];
    }
    return 0;
}


Measured memory_bytes: 105856
n = int(input())
b = list(map(int,input().split()))

ans = []

while len(b) > 0:
    check = -1
    for i in range(len(b)):
        if b[i] == i+1:
            check=i
    if check==-1:
        print(-1)
        exit()
    ans.append(check+1)
    b = b[:check] + b[check+1:]
for i in range(n):
    print(ans[n-i-1])


Measured memory_bytes: 3064
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2 60
10 10
100 100
---+/
/+---test
3 60
10 10
10 20
10 30
---+/
/+---test
3 60
30 10
30 20
30 30
---+/

void main(string[] args) {
  int N, T;
  readf(" %d %d ", &N, &T);

  struct Item { long c, v; }
  auto items = new Item[N];
  foreach (ref item; items) readf(" %d %d ", &item.c, &item.v);

  auto dp0 = new long[T], dp1 = new long[T];
  foreach (i; 0..N) {
    foreach_reverse (t; 0..T) if (t + items[i].c < T) {
      dp1[t+items[i].c] = dp1[t+items[i].c].max(dp1[t] + items[i].v);
    }

    foreach (t; 0..T) dp1[t] = dp1[t].max(dp0[t] + items[i].v);

    foreach_reverse (t; 0..T) if (t + items[i].c < T) {
      dp0[t+items[i].c] = dp0[t+items[i].c].max(dp0[t] + items[i].v);
    }
  }
  long ans;
  dp0.each!(x => ans = ans.max(x));
  dp1.each!(x => ans = ans.max(x));
  ans.writeln;
}


Measured memory_bytes: 2300
#include <stdio.h>

int current;

void pushBack(int x, int *A);
void randomAccess(int p, int *A);
void popBack(int *A);

int main(void)
{
    int q;
    int a,b;
    
    scanf("%d\n",&q);
    int A[q];

    while(scanf("%d",&a) != -1){
        
        if(a == 0 || a == 1){
            scanf("%d", &b);
        }
        switch(a){
            case 0:
            pushBack(b, A);
            current++;
            break;
            
            case 1:
            randomAccess(b, A);
            break;
            
            case 2:
            popBack(A);
            current--;
            break;
            
        }
    }

	return 0;
}

void pushBack(int x, int *A){
    A[current] = x;
}

void randomAccess(int p, int *A){
    printf("%d\n",A[p]);
}

void popBack(int *A){
    A[current - 1] = '\0';
}



Measured memory_bytes: 2564
#include<stdio.h>

#define MAX_W 30

int main(void)
{
	int bou[MAX_W];
	int w, n, a, b;
	int i, tmp;
	
	scanf( "%d", &w );
	for( i=0; i<w; i++ ) {
		bou[i] = i + 1;
	}
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%d,%d", &a, &b );
		tmp = bou[a - 1];
		bou[a - 1] = bou[b - 1];
		bou[b - 1] = tmp;
	}
	
	for( i=0; i<w; i++ ) {
		printf( "%d\n", bou[i] );
	}
	
	return 0;
}

Measured memory_bytes: 596
import collections as cc
import sys
import bisect as bi
I=lambda:list(map(int,input().split()))
n,=I()
l=I()
curmax=l[0]
ans=0
for i in range(1,n):
	if l[i]<curmax:
		ans+=abs(l[i]-curmax)
	else:
		curmax=l[i]
print(ans)


Measured memory_bytes: 106504
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int main(){
	vector<int>a;
	int n, m;
	int x, y;
	int k, ans;
	k = 0;
	ans = 0;
	scanf("%d %d", &n,&m);
	for (int i = 0; i < n; i++){
		scanf("%d %d", &x,&y);
		k = max(k, x);
		a.push_back(y);
	}
	sort(a.begin(), a.end(), greater<int>());

for (int i = 0; i < n; i++){
		if (a[i] > k&&m>0){
			ans++;
			m -= a[i];
		}
		else break;
	}
	if(m>0)ans += (m + k - 1) / k;

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 892
x,y = map(int,input().split())
li = list(map(int,input().split()))	
minmin = x - (li[0] + x - li[y-1])
for i in range(len(li)-1):
    if minmin > x - (li[i+1] - li[i]):
        minmin =  x - (li[i+1] - li[i])
    else:
      continue
print(minmin)

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

int main(){
	
	int A, B, C;
	cin >> A >> B >> C;
	if ( A == B ){
		cout << C << endl;
	} else if ( A == C ){
		cout << B << endl;
	} else if ( B == C ){
		cout << A << endl;
	} else {
		cout << A << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	map<string,int> ct;
	int most=0;
	for (int i=0; i<N; i++) {
		string S; cin>>S;
		ct[S]++;
		most=max(most,ct[S]);
	}
	for (auto it : ct)
		if(it.second==most)
			cout<<it.first<<"\n";
	return 0;
}

Measured memory_bytes: 23808
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int N, B[110];
int main()
{
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
	int an = B[0] + B[N - 2];
	for (int i = 0; i < N - 2; i++) {
		an += min(B[i], B[i + 1]);
	}
	cout << an;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,r,p,c,i,j,k;
		int card[],temp[];
		while(true){
			n=sc.nextInt();
			r=sc.nextInt();
			if(n+r==0) break;
			card=new int[n];
			for(i=0;i<n;i++){
				card[i]=i;
			}
			for(k=0;k<r;k++){
				p=sc.nextInt();
				c=sc.nextInt();
				temp=new int[p-1];
				j=n-1;
				for(i=0;i<p-1;i++){
					temp[i]=card[j--];
				}
				j=n-1;
				for(i=0;i<c;i++){
					card[j]=card[j-p+1];
					j--;
				}
				for(i=0;i<p-1;i++){
					card[j--]=temp[i];
				}
			}//end for
			System.out.println(card[n-1]+1);
		}
	}
	static void print(String str,int c[]){
		System.out.print(str+":");
		for(int i=0;i<c.length;i++){
			System.out.print(" "+c[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (L[i] != L[j]) & (L[j] != L[k]) & (L[k] != L[i]):
        if (L[i] < L[j] + L[k]) & (L[j] < L[i] + L[k]) & (L[k] < L[i] + L[j]) :
          ans += 1
print(ans)

Measured memory_bytes: 9120
n=int(input())
L=list(map(int,input().split()))
ans=[0 for i in range(n)]

L=[i*2 for i in L]

m=n//2
a=L[m]

for i in range(1,(n+1)//2):
  a=L[m-i]+L[m+i]-a

ans[0]=a//2

for i in range(1,n):
  ans[i]=L[i-1]-ans[i-1]

print(*ans)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
vector<ll>vals;
bool check(ll len){
    ll cnt=0;
    for(auto el:vals){
        if(el>len){
            cnt+=(el+len-1)/len-1;
        }
    }
    return cnt<=k;
}
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        ll el;cin>>el;vals.push_back(el);
    }
    ll l=1,r=1000*1000*1000,ans=-1;
    while(l<=r){
        ll m=(l+r)/2;
        if(check(m)){
            ans=m;
            r=m-1;
        }else{
            l=m+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		else {
			if (m == -1 || f == -1) {
				cout << "F" << "\n";

			}
			else {
				if (m + f >= 80) {
					cout << "A" << "\n";
				}
				else if (m + f < 80 && m + f >= 65) {
					cout << "B" << "\n";
				}
				else if (m + f < 65 && m + f >= 50) {
					cout << "C" << "\n";
				}
				else if (m + f < 50 && m + f >= 30) {
					if (r >= 50) {
						cout << "C" << "\n";
					}
					else {
						cout << "D" << "\n";
					}
				}else{
					cout << "F" << "\n";
				}
			}
		}
	}
	
	return 0;
}


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

int main(){
    int a,b,c,k; cin>>a>>b>>c>>k;
    int d = max(a,max(b,c));
    long long ans = a+b+c-d;
    ans += d*pow(2,k);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
	int n; scanf("%d",&n);
	int d=0;
	int sq[300];
	int r[200000]={0};
	rep(i,0,300) sq[i]=i*i;
	rep(a,1,145){
		rep(b,1,145){
			rep(c,1,145){
				int v=(sq[a+b]+sq[b+c]+sq[c+a])/2;
				r[v]++;
			}
		}
	}
	rep(i,1,n+1) printf("%d\n",r[i]);
}


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

using namespace std;

int main(){
    using ll = long long;
    int N;
    cin >> N;
    ll sum = 0;
    for(int i=0; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3620
class Scanner {
    private var stack = [String]()
    private var index = 0
    
    func peek() -> String {
        if stack.count == index {
            stack += readLine()!.split(separator: " ").map{ String($0) }
        }
        return stack[index]
    }
    
    func next() -> String {
        let value = peek()
        index += 1
        return value
    }
    
    func nextInt() -> Int {
        return Int(next())!
    }
    
    func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()

let X = scanner.nextInt()
let N = scanner.nextInt()
let P = (0 ..< N).map { _ in scanner.nextInt() }

let answer = (-200 ... 200).filter {
    i in !P.contains(i)
}.min { (i, j) in
    (abs(X - i), i) < (abs(X - j), j)
}!

print(answer)


Measured memory_bytes: 7912
from collections import Counter

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

lenght = len(set(A))-K
ans = 0
if lenght<=0:print(ans), exit()
else:
    for k, v in Counter(A).most_common()[::-1][:lenght]:
        ans += v
print(ans)

Measured memory_bytes: 48640