akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
#define fastio cin.tie(0); cin.sync_with_stdio(0);
#define MAXN 505

int N,arr[MAXN*MAXN],dis[MAXN][MAXN],vals[MAXN][MAXN],moves[4][2] = {{0,1},{1,0},{-1,0},{0,-1}};

inline void bfs(int r, int c){
    deque<pii> q;
    q.push_back(make_pair(r,c));
    while(q.size()){
        int x = q.front().first, y = q.front().second; q.pop_front();
        for(int i=0; i<4; i++){
            int nx = x+moves[i][0], ny = y+moves[i][1];
            if(dis[nx][ny] > dis[x][y]+vals[x][y]){
                dis[nx][ny] = dis[x][y]+vals[x][y];
                if(vals[nx][ny] == 0) q.push_front(make_pair(nx,ny));
                else q.push_back(make_pair(nx,ny));
            }
        }
    }
}

int main(){
    fastio; cin >> N;
    for(int i=1; i<=N*N; i++){
        cin >> arr[i];
        arr[i]--;
    }
    for(int i=1; i<=N; i++){
        for(int k=1; k<=N; k++){
            dis[i][k] = min({i-1,k-1,N-i,N-k});
            vals[i][k] = 1;
        }
    }
    ll res = 0;
    for(int i=1; i<=N*N; i++){
        int r = arr[i]/N+1, c = arr[i]%N+1;
        vals[r][c] = 0; bfs(r,c);
        res+=dis[r][c];
    }
    cout << res << '\n';
}

Measured memory_bytes: 7480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    vpii c(m);
    map<int,int> year;
    map<int,string> id;
    rep(i,m){
        int p,y;cin>>p>>y;
        c[i]=mp(p,y);
        year[i]=y;
    }
    sort(all(c));
    int tmp=1;
    int cs;
    int tmps;
    rep(i,m){
        if(i>0&&c[i].first==c[i-1].first){
            tmp++;
            string s;
            cs=to_string(c[i].first).size();
            tmps=to_string(tmp).size();
            rep(j,6-cs)s+='0';
            s+=to_string(c[i].first);
            rep(j,6-tmps)s+='0';
            s+=to_string(tmp);
            id[c[i].second]=s;
        }
        else{
            tmp=1;
            string s;
            cs=to_string(c[i].first).size();
            rep(j,6-cs)s+='0';
            s+=to_string(c[i].first);
            s+="000001";
            id[c[i].second]=s;
        }
    }
    rep(i,m)cout<<id[year[i]]<<endl;
}

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

using namespace std;

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

    int counter[26] = {};

    for (int i = 0; i < s.size(); ++i) {
        counter[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; ++i) {
        if (counter[i] % 2 == 1) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N,A;
  int cnt = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    while(A == (A/2)*2){
      ++cnt;
      A /= 2;
    }
  }

  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 256
def cipher(char):
    if ord(char) <= ord('y') and ord(char) >= ord('a'):
        return str(chr(ord(char) + 1))
    elif char == 'z':
        return 'a'
    else:
        return char
while True:
    try:
        sent = raw_input()
    except EOFError:
        break
    while((sent.find('the') == -1) and (sent.find('this') == -1) and (sent.find('that') == -1)):
        sent = ''.join(map(cipher, sent))
    print sent

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {

    ll n, a, b;

    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }

    if (n == 1 && a != b) {
        cout << 0 << endl;
        return 0;
    }

    ll mi = a + b + (a * (n - 2));
    ll ma = a + b + (b * (n - 2));

    cout << ma - mi + 1 << endl;

}




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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

int main(){
    int N;
    cin>>N;
    vector<int> dp(N+1);
    dp[0]=0;
    FOR(i,1,N+1){
        dp[i]=pow(10,9);
        dp[i]=min(dp[i],dp[i-1]+1);
        int power=6;
        while(power<=i){
            dp[i]=min(dp[i],dp[i-power]+1);
            power*=6;
        }
        power=9;
        while(power<=i){
            dp[i]=min(dp[i],dp[i-power]+1);
            power*=9;
        }
    }
    cout<<dp[N]<<endl;
}

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

int64_t gyaku(int64_t a){
  int64_t s = 1;
  vector<int64_t> v(40);
  v[0] = a % 1000000007;
  rep(i, 39) v[i+1] = v[i] * v[i] % 1000000007;
  string t = "111011100110101100101000000101";
  rep(i, t.size()){
    if(t[t.size()-1-i] == '1'){
    s *= v[i];
    s %= 1000000007;
    }
  }
  return s;
}

int main() {
  map<int64_t, int64_t> m;
  int64_t n;
  cin >> n;
  vector<int64_t> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n){
    int64_t a = v[i];
    for(int64_t j = 2; j <= pow(v[i], 0.5); ++j){
      int64_t b = 0;
      while(a % j == 0){
        a /= j;
        ++b;
      }
      if(b != 0) m[j] = max(m[j], b);
      if(a == 1) break;
    }
    if(a != 1 && !m.count(a)) m[a] = 1;
  }
  int64_t t = 1, s = 0, mod = 1000000007;
  for(auto p: m){
    rep(i, p.second){
      t *= p.first;
      t %= mod;
    }
  }
  rep(i, n){
    s += t * gyaku(v[i]);
    s %= mod;
  }
  cout << s << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x=4,ans=0;
  map<char,int> mapa;
  while(x--){
  char c;
  cin>>c;
  mapa[c]++;
  if(mapa[c]==2) ans++;}
  (ans==2)?cout<<"Yes"<<endl:cout<<"No"<<endl;
  
  return 0;
}

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

int main() {
    cin >> N;
    w.resize(N);
    for (int i = 0; i < N; i++) cin >> w[i];
    long long minsum = 1 << 30;
    for (int t = 0; t < N-1; t++) {
        long long S1 = 0;
        long long S2 = 0;
        for (int i = 0; i <= t; i++) S1 += w[i];
        for (int i = t+1; i < N; i++) S2 += w[i];
        long long temp = abs(S1 - S2);
        minsum = min(temp, minsum);
    }
    cout << minsum << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
K = int(input())

L = [A,B,C,D,E]

for i in range(len(L)):
    for j in range(i+1,len(L)):
        if(abs(L[i]-L[j])>K):
            print(":(")
            exit()


print("Yay!")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int int64_t
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define F first
#define S second
#define T  third
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
using namespace std;
int max(int32_t a, int b){
   return max((int)a, b);
}
int max(vector<int> x){
    return *max_element(x.begin(), x.end());
}


int32_t main(){
    int n;
    cin >> n;
    cout.precision(10);
    vector<double> ar(n);
    for(int i = 0; i < n; i ++)
        cin >> ar[i];
    sort(ar.begin(), ar.end());
    double x = ar[0];
    for(int i = 0; i < n; i++){
        x += ar[i];
        x /= (double)2;
    }
    cout << fixed << x;
}




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

int main(){
  int a,b;
  cin>>a>>b;
  for(int i=1;i<=1000000;i++)
      if(i*8/100==a&&i*10/100==b){
          cout<<i;
          return 0;
      }
  cout<<"-1";

}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

mod = 10**9+7
n,k = na()
a = na()
a.sort()

ans = 1

if k == 1:
    print(a[-1])
    exit()

if a[-1] <= 0 and k%2==1:
    for i in range(n-k,n):
        ans = ans*a[i]%mod
    print(ans%mod)
    exit()

s = 0
e = -1

while k > 0:
    if k == 1:
        if a[s] >= a[e]:
            ans = ans*a[s]%mod
        else:
            ans = ans*a[e]%mod
        break
    p = a[s]*a[s+1]
    q = a[e]*a[e-1]
    if p >= q:
        ans = p%mod*ans%mod
        s+=2
    else:
        ans = q%mod*ans%mod
        e-=2
    k-=2

print(ans%mod)

Measured memory_bytes: 104500
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main()
{
	int a = 0, b = 0, c = 0, sum = 0;
	scanf("%d %d %d", &a, &b, &c);
	sum = a+b;
	if(sum >= c)
	{
		printf("Yes\n");
	}
	if(sum < c)
	{
		printf("No\n");
	}
      return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    fast;
    /*ll n, count=0;
    cin>>n;
    string s;
    cin>>s;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(s[i]==s[j])
                continue;
            for(ll k=0;k<n;k++)
            {
                if(s[k]==s[j])
                    continue;
                else if(s[i]==s[k])
                   continue;
                else if(2*j==(i+k))
                   continue;
                else
                    count++;
            }
        }
    }             
    cout<<count;*/
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        ans=ans+i;
    }
    cout<<ans;
        return 0;
}

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_A(){
    int n;
    cin >> n;
    int i = 1;
    while(1){
        if(i * 1000 >= n){
            break;
        }
        i ++;
    }

    cout << i *1000 - n<< endl;
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

const int M=1000000007;
int main(){
	int n,t;
	cin>>n>>t;
	vi a(n);
	REP(i,n){
		cin>>a[i];
	}
	sort(ALL(a));
	vector<ll> dp(n);
	dp[0]=1;
	FOR(i,1,n){
		ll cnt=a.begin()+i-lower_bound(ALL(a),a[i]-t)+1;
		dp[i]=dp[i-1]*cnt%M;
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 2328
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    vector<int> ref(n);
    iota(ref.begin(), ref.end(), 1);
    bool f = equal(a.begin(), a.end(), ref.begin());

    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            swap(a[i], a[j]);
            f |= equal(a.begin(), a.end(), ref.begin());
            swap(a[j], a[i]);
        }
    }

    if (f) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
mod = 10**9 + 7

def egcd(a, b):
    lastremainder, remainder = abs(a), abs(b)
    x, lastx, y, lasty = 0, 1, 1, 0
    while remainder:
        lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
        x, lastx = lastx - quotient*x, x
        y, lasty = lasty - quotient*y, y
    return lastremainder, lastx * (-1 if a < 0 else 1), lasty * (-1 if b < 0 else 1)


def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise ValueError('modinv for {} does not exist'.format(a))
    return x % m

n = int(input())
A = [int(i) for i in input().split()]
ans = sum(A)**2 % mod
for i in A:
    ans -= i**2
    ans %= mod
ans *= modinv(2, mod)
ans %= mod
print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int X;
    cin >> X;

    int ans = 0;
    ans += X / 500 * 1000;
    X %= 500;
    ans += X / 5 * 5;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 8000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int x[51], y[51];
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    int ans = INF2;
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                rep(s, N) {
                    int x1 = min({x[i], x[j], x[k], x[s]});
                    int x2 = max({x[i], x[j], x[k], x[s]});
                    int y1 = min({y[i], y[j], y[k], y[s]});
                    int y2 = max({y[i], y[j], y[k], y[s]});
                    int cnt = 0;
                    rep(t, N) {
                        if (x1 <= x[t] && x[t] <= x2 && y1 <= y[t] && y[t] <= y2) cnt++;
                    }
                    if (cnt >= K) ans = min(ans, (x2 - x1) * (y2 - y1));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = []
s.append(int(input()))
A = set()
i = 0
A.add(s[0])

while True:
    if s[i] % 2 == 0:
        s.append(s[i] // 2)
    else:
        s.append(3*s[i] + 1)
    if s[i + 1] in A:
        print(i + 2)
        break
    else:
        A.add(s[i + 1])
    i += 1

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    
    bool flg = false;
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < 16; j++){
            if(4 * i + 7 * j == n) flg = true;
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	string s;
	cin >> s;

	int ans = 999;
	int n = 753;
	for (size_t i = 0; i < s.size() - 2; i++)
	{
		int tmp = 0;
		tmp = stoi(s.substr(i, 3));
		ans = min(ans, abs(n - tmp));
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int ans = a + b;
		int tmp = a - b;
		ans = Math.max(ans, tmp);
		tmp = a * b;
		ans = Math.max(ans, tmp);
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	string s; cin>>s;
  	sort(all(s));
	cout << (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[3]? "Yes" : "No") << ednl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    ll N, X; cin>>N>>X;
    vector<ll> x(N);
    for (int i = 0; i < N; ++i) {
        ll tmp; cin>>tmp;
        x[i] = abs(tmp-X);
    }
    ll GCD=x[0];
    for (int i = 1; i < N; ++i) {
        GCD = __gcd(GCD, x[i]);
    }

    cout<<GCD<<endl;


    return 0;
}

Measured memory_bytes: 1024
N=int(input())

x = []
y = []
for i in range(0,N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
def d(e,f,g,h):
  return ((g-e)**2+(h-f)**2)**(1/2)
sum=0
for i in range(0,N-1):
  for j in range(i+1,N):
    sum=sum+d(x[i],y[i],x[j],y[j])
import math
print(sum*2/N)




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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    char X, Y; cin >> X >> Y;
    if ((X - 'A') == (Y - 'A')){
        cout << "=" << endl;
    } else if ((X - 'A') > (Y - 'A')){
        cout << ">" << endl;
    } else {
        cout << "<" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>

int main()
{
	int A, B = 0;
	std::cin >> A >> B;

	if (A < 1 || A > 9 || B < 1 || B > 9)
	{
		std::cout << -1 << "\n";
	}
	else
	{
		std::cout << A * B << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
let input f = stdin.ReadLine() |> f
let inputs f = stdin.ReadLine().Split() |> Array.map f

let N = input int
let ans = Array.create N 0
for x in inputs int do
    ans.[x - 1] <- ans.[x - 1] + 1

for i in 0..N-1 do 
    printfn "%d" ans.[i]

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    if( b - a >= 2019 ){
        cout << 0 << endl;
        return 0;
    }

    a %= 2019;
    b %= 2019;

    if( a > b ){
        cout << 0 << endl;
        return 0;
    }

    int ans = INF;
    FOR( i, a, b ){
        FOR( j, i + 1, b + 1 ){
            chmin( ans, i * j % 2019 );
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = [int(input()) for i in range(m)]
mod = 1000000007

a = [0] * (n+1)
for i in x:
    a[i] = 1

dp = [1]

if a[1] == 1:
    dp.append(0)
else :
    dp.append(1)

for i in range(2, n+1):
    if a[i] == 1:
        dp.append(0)
    else:
        dp.append(dp[i-1] + dp[i-2])
        dp[i] %= mod

print(dp[n])


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

using namespace std;

int a,b;
vector<pair<long long,bool> > v;
vector<long long> x,y;

long long ab(long long e)
{
    if(e>=0) return e;
    else return -e;
}

pair<int,int> bin(long long d,int tp) //1-v,2-a,3-b
{
    if(tp==1)
    {
        int l=-1,r=a+b;
        while(l<r-1)
        {
            int mid=(l+r)/2;
            if(v[mid].first>d) r=mid;
            else l=mid;
        }
        return make_pair(l,r);
    }
    if(tp==2)
    {
        int l=-1,r=a;
        while(l<r-1)
        {
            int mid=(l+r)/2;
            if(x[mid]>d) r=mid;
            else l=mid;
        }
        return make_pair(l,r);
    }
    if(tp==3)
    {
        int l=-1,r=b;
        while(l<r-1)
        {
            int mid=(l+r)/2;
            if(y[mid]>d) r=mid;
            else l=mid;
        }
        return make_pair(l,r);
    }
    return make_pair(0,0);
}

long long solve(long long d)
{
    pair<int,int> p=bin(d,1);
    int l=p.first,r=p.second;
    long long res=1000000000000000000;
    if(l>=0)
    {
        long long m=ab(d-v[l].first);
        if(v[l].second==0)
        {
            pair<int,int> s=bin(v[l].first,3);
            int lx=s.first,rx=s.second;
            if(lx==-1) m+=ab(v[l].first-y[rx]);
            else if(rx==b) m+=ab(v[l].first-y[lx]);
            else m+=min(ab(v[l].first-y[rx]),ab(v[l].first-y[lx]));
        }
        else
        {
            pair<int,int> s=bin(v[l].first,2);
            int lx=s.first,rx=s.second;
            if(lx==-1) m+=ab(v[l].first-x[rx]);
            else if(rx==b) m+=ab(v[l].first-x[lx]);
            else m+=min(ab(v[l].first-x[rx]),ab(v[l].first-x[lx]));
        }
        res=min(res,m);
    }
    if(r<a+b)
    {
        long long m=ab(d-v[r].first);
        if(v[r].second==0)
        {
            pair<int,int> s=bin(v[r].first,3);
            int lx=s.first,rx=s.second;
            if(lx==-1) m+=ab(v[r].first-y[rx]);
            else if(rx==b) m+=ab(v[r].first-y[lx]);
            else m+=min(ab(v[r].first-y[rx]),ab(v[r].first-y[lx]));
        }
        else
        {
            pair<int,int> s=bin(v[r].first,2);
            int lx=s.first,rx=s.second;
            if(lx==-1) m+=ab(v[r].first-x[rx]);
            else if(rx==b) m+=ab(v[r].first-x[lx]);
            else m+=min(ab(v[r].first-x[rx]),ab(v[r].first-x[lx]));
        }
        res=min(res,m);
    }
    return res;
}

int main()
{
    int q;
    cin >> a >> b >> q;
    for(int i=0;i<a;i++)
    {
        long long temp;
        cin >> temp;
        x.push_back(temp);
        v.push_back(make_pair(temp,0));
    }
    for(int i=0;i<b;i++)
    {
        long long temp;
        cin >> temp;
        y.push_back(temp);
        v.push_back(make_pair(temp,1));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<q;i++)
    {
        long long temp;
        cin >> temp;
        cout << solve(temp) << endl;
    }
    return 0;
}


Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf						scanf	
 
const ll m=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

///////////// TEMPLATE END /////////////////////////////////

 


void solve()
{    
	ll n;
	cin>>n;
	
	vll a(n);
	fr(i,n)
	{
		cin>>a[i];
	}
	ll ans=0;
	fr1(i,n-1)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	
}



int main()
{
    fastio
   
//    int t;
//    cin>>t;
//    wh(t--)
    {
//        cout<<"Case "<<i<<":"<<endl;
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 4780
<?php
$n = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$map = [];
foreach($A as $a){
  if(!isset($map[$a]))$map[$a] = 0;
  $map[$a]++;
}
$sum = 0;
foreach($map as $num => $count){
  $sum += $count * ($count - 1) / 2;
}
foreach($A as $a){
  echo $sum + 1 - $map[$a],"\n";
}


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

int main() {
  int a, b, c, d, L, R;
  cin >> a >> b >> c >> d;
  L=a+b, R=c+d;
  if (L>R)
    cout << "Left" << endl;
  else if (R>L)
    cout << "Right" << endl;
  else
    cout << "Balanced" <<endl;

}



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

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vl> vvl;
typedef vector<vs> vvs;

#define f(i, start, end) for (i = start; i < end; i++)
#define trav(v) for (auto &x : v)
#define deb(x) cerr << #x << ":" << x << "\n"
#define nl cout << "\n"

int main()
{

    ios::sync_with_stdio(0);
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        ll n, i;
        str s;
        cin >> n;
        cin >> s;
        f(i, 0, s.size())
        {
            if (s[i] + n > 'Z')
                s[i] = 'A' + (s[i] + n - 1) % 'Z';
            else
                s[i] += n;
        }
        cout << s;
        nl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define X first
#define Y second
#define maxn 100002
#define eps 0.0000001
#define inf 1e9
#define pb push_back
#define maxD 15
#define ll long long
using namespace std;
ll n,k;
ll a[maxn];
ll gcd(ll x, ll y){
	if(x==0) return y;
	return (gcd(y%x,x));
}
main(){
	cin >> n >> k;
	ll g;
	For(i,1,n) {
		scanf("%d",a+i);
		if(i==1) g = a[1];
		else g = gcd(g,a[i]);
	}
//	cout << g;
	string ans = "IMPOSSIBLE";
	For(i,1,n){		
		if((a[i]==k)||(a[i]>k && (a[i]-k)%g==0)){
			ans = "POSSIBLE";
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;
ll n,t[200010][2],mx = 100000000000000,dp[100010],x[100010],y[100010];
void update(ll p,ll a,int x){
	for(t[p+=n][x] = a;p>1;p >>= 1){
		t[p>>1][x] = min(t[p][x],t[p^1][x]);
	}
}

ll query(int l, int r,int x){
	ll mn = mx;
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) mn = min(mn,t[l++][x]);
		if(r&1) mn = min(mn,t[--r][x]);
	}
	return mn;
}

int main(){
	ll i,e,T;
	cin >> n >> e >> T;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	x[0] = 0; dp[0] = 0;
	int l = -1;
	for(i=0;i<=n;i++){
		while(2*(x[i] - x[l + 1])>T && l<n-1) l++;
		y[i] = l;
	}
	update(0,-x[0] - 2*x[1],0); update(0,-x[0],1);
	for(i=1;i<=n;i++){
		dp[i] = min(3*x[i] + query(0,y[i],0),x[i] + T + query(y[i],i,1));
		update(i,dp[i] - x[i] - 2*x[i + 1],0);
		update(i,dp[i] - x[i],1);
	}
	cout << dp[n] + e - x[n] << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int now = 0;
  REP(i, N) {
    int a;
    cin >> a;
    A[i] = a;
    if (i > 0) {
      if (A[i] > 1 + A[i - 1]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i - 1] + 1) {
      ans++;
    } else {
      ans += A[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
#include <sstream>
typedef long long ll;
#define vi vector<int>
using namespace std;


int count(int x) {
	int i;
	int cnt = 0;
	for (i = 1; i * i < x; i++) {
		if (x % i == 0) {
			cnt += 2;
		}
	}
	return i * i == x ? cnt + 1 : cnt;
}


int main() {
	int N;
	cin >> N;
	ll ans = 0;
	for (int i = 1; i < N; i++) {
		ans += count(i);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3632
import math

while True:
  (r, n) = map(int, raw_input().split())
  if r + n == 0: break

  hs = {}
  for i in range(-22, 22 + 1):
    hs[i] = 0

  for _ in range(n):
    (xl, xr, h) = map(int, raw_input().split())
    for i in range(xl, xr):
      hs[i] = max(hs[i], h)

  ans = 10 ** 9
  for i in range(-r, r):
    p = i
    if i < 0: p += 1
    rr = hs[i] + r - math.sqrt(r * r - p * p)
    ans = min(ans, rr)

  print "%.10f" % max(0, ans)

Measured memory_bytes: 4400
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std ;

const int N=1e5+100;

char s[N];
char t[N];
int top ;
int n ;
int res;

int main ()
{
	int i ;
	gets(s+1),n=strlen(s+1);
	for ( i=1 ; i<=n ; i++ ) 
		if ( top>0 && t[top]!=s[i] ) top--,res+=2;
		else t[++top]=s[i];
	printf("%d\n",res);
	return 0 ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
 
int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<int> res(n,0);
 
    rep(i,n){
        if(s[i] == 'R'){
            int cnt = 0;
            int j = i;
            while(s[j] != 'L' && j < n){
                cnt++;
                j++;
            }
            while(cnt > 0){
                if(cnt&1)res[j-1]++;
                else res[j]++;
                cnt--;
            }
            i = j;
        }
    }
    reverse(s.begin(),s.end());
 
    rep(i,n){
        if(s[i] == 'L'){
            int cnt = 0;
            int j = i;
            while(s[j] != 'R' && j < n){
                cnt++;
                j++;
            }
            while(cnt > 0){
                if(cnt&1)res[n-j]++;
                else res[n-j-1]++;
                cnt--;
            }
            i = j;           
        }
    }    
 
    for(auto e : res){
        cout << e << " ";
    }                                                                                                                                                                   
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    if (a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    ll sum = 0;
    rep(i, n-1) {
        if (a[i] >= a[i+1]) {
            ans += sum;
            sum = a[i+1];
        }
        else if (a[i+1] > sum + 1) {
            cout << -1 << endl;
            return 0;
        }
        else {
            sum += (a[i+1] - a[i]);
        }
    }
    ans += sum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> 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)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    input!{ n: usize, i:usize}
    println!("{}", n-i+1);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    string a,b,c;
    int d,e,fl;
    cin >> a;
    d = a.length();
    e = (d - 1)/2;
    vector<char> vec(d);
    vector<char> tor(e);
    for(int i = 0;i < d /2;i++){
        int ii = d - 1 - i;
        if(a.at(i) == a.at(ii)){
            fl = 1;
        }else{
            fl = 0;
            break;
        }

    }
    if(fl == 1){
        for(int i = 0;i < e / 2;i++){
        int ii = e - 1 - i;
        if(a.at(i) == a.at(ii)){
            fl = 2;
        }else{
            fl = 1;
            break;
        }
        }
    }else{
        cout << "No" << endl;
    }
    if(d == 3 && a.at(0) == a.at(2)){
        fl = 2;
    }
    if(fl == 2){
        cout << "Yes" <<endl;
    }else if(fl == 1){
        cout << "No" <<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n,m;
ll dp[700][700];
void add(ll &a,ll b)
{
	b%=m;
	a+=b;
	if(a>=m)a-=m;
}
int upb[700],lwb[700],od[700];
bool less2(int a,int b)
{
	int va=(a<n)?lwb[a]:upb[a];
	int vb=(b<n)?lwb[b]:upb[b];
	if(va!=vb) return va<vb;
	return a>b;
}
int main()
{
	cin>>n>>m;
	upb[0]=n*2-1;
	lwb[0]=n-1;
	for(int i=1;i<n;i++)
	{
		upb[i]=upb[i-1];
		lwb[i]=lwb[i-1];
		while((upb[i]*upb[i]+i*i)>4*n*n)upb[i]--;
		while((lwb[i]>=0)&&((lwb[i])*(lwb[i])+i*i)>=n*n)lwb[i]--;
	}
	for(int i=n;i<n*2;i++)
	{
		upb[i]=upb[i-1];
		while((upb[i]*upb[i]+i*i)>4*n*n)upb[i]--;
	}
	for(int i=0;i<n*2;i++)
	{
//		cout<<i<<" "<<lwb[i]<<" "<<upb[i]<<endl;
	}
//	system("pause");
	for(int i=0;i<n*2;i++)
	{
		od[i]=i;
	}
	ll ans=0;
	sort(od,od+n*2,less2);
	for(int k=0;k<=n;k++)
	{
	//	cout<<"dp "<<k<<endl;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<n*2;i++)
		{
			int ri=od[i];
			for(int j=0;j<=k&&j<=i;j++)
			{
				if(ri>=n)
				{
					add(dp[i+1][j],dp[i][j]*(upb[ri]+1-(j+(2*n)-ri-1)%m));
				//	cout<<i<<" "<<j<<" "<<ri<<" "<<upb[ri]+1<<" "<<(j+2*n-ri-1)<<endl;
				//	system("pause");
				}
				else
				{
					//up
					if(j+ri>=k)
					{
						add(dp[i+1][j],dp[i][j]*(upb[ri]+1-(n+k+n-ri-j-1))%m);
				//		cout<<i<<" "<<j<<" "<<ri<<" "<<upb[ri]+1<<" "<<n+k+n-ri-j-1<<" "<<n+k-1<<" "<<n-ri-j<<endl;
				//		system("pause");
					}
					//lw
					if(j+1<=k)
					{
						add(dp[i+1][j+1],dp[i][j]*(lwb[ri]+1-(i-(n-ri-j)+1))%m);
				//		cout<<i<<" "<<j<<" "<<ri<<" "<<lwb[ri]+1<<" "<<i-(n-ri-j)+1<<endl;
				//		system("pause");
					}
				}
			}
		}
		ll val=dp[n*2][k];
		if(k&1)val=m-val;
		add(ans,val);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4224
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

double tab[100005];

///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	sort(tab, tab + n);
	
	double ans = tab[0];
	
	for(int i = 1; i < n; i++){
		ans = (ans + tab[i]) / 2;
	}
	
	cout << ans << '\n';













	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
	ll ch[102][5][2];
int main() {
	string s;
	cin>>s;
	ll m;cin>>m;

	ch[0][0][0]=1;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'0';
		for(ll j=0;j<10;j++){
			for(ll k=0;k<4;k++){
				if(j==0){
					if(now==0){
						ch[i+1][k][0]+=ch[i][k][0];
						ch[i+1][k][1]+=ch[i][k][1];
					}
					else{
						ch[i+1][k][1]+=ch[i][k][0];
						ch[i+1][k][1]+=ch[i][k][1];
					}
				}
				else{
					if(j<now){
						ch[i+1][k+1][1]+=ch[i][k][0];
						ch[i+1][k+1][1]+=ch[i][k][1];						
					}
					else if(j==now){
						ch[i+1][k+1][0]+=ch[i][k][0];
						ch[i+1][k+1][1]+=ch[i][k][1];							
					}
					else{
						ch[i+1][k+1][1]+=ch[i][k][1];							
					}
				}
			}
		}
	}
	cout << ch[s.size()][m][0]+ch[s.size()][m][1];
	// your code goes here
	return 0;
}

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

int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll max = INT_MAX, min = INT_MIN, count=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(i==0){
            count++;
            max = a[i];
            min = a[i];
        }
        else{
            if(a[i]<=min){
                count++;
                min = a[i];
            }
            else if(a[i]>=max){
                max = a[i];
            }
        }
    }
    cout<<count<<endl;

return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <string.h>
#include <set>
#include <map>

using namespace std;
vector< vector<int> > v(100001);
int n, m;
int f[100001] = {0};
int r = 0;

void dfs(int a) {
	if (f[a] == 0) { f[a] = r; }
	else { return; }
	for (int i = 0;i < v[a].size();i++) {
		if (f[v[a][i]] == 0) { dfs(v[a][i]); }
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0;i < m; i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}	

	for (int i = 0; i < n;i++) {
		if (f[i] == 0) { r++; }
		dfs(i);
	}

	int q; cin >> q;
	vector<string> Ans(q);
	for (int i = 0; i < q; i++) {
		int s, t; cin >> s >> t;
		if (f[s] == f[t]) { Ans[i] = "yes"; }
		else { Ans[i] = "no";}
	
	}
	for (int i = 0; i < q;i++) { cout << Ans[i] << endl; }
	return 0;
}

Measured memory_bytes: 12352
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
// 125

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    ll x, y;
    ios::sync_with_stdio(false);
    cin >> x >> y;
    if(x % y == 0) {
        cout << -1;
        return 0;
    }
    cout << x;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  long long int K, X;

  scanf("%lld%lld", &K, &X);

  if(500*K >= X){
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
  
  return 0;
}

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

int main() {
    string S , N = {"CODEFESTIVAL2016"};
    cin >> S;
    int count = 0;
    for (int i = 0; i < 16; ++i) {
        if(S.at(i) != N.at(i)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
 ll a,b,c,k,s=0;
 cin>>a>>b>>c>>k;
 if(k<=a){
     cout<<k<<"\n";
     return 0;
 }
 else{
     s+=a;
     k-=a;
     if(k>b){
         s-=(k-b);
         cout<<s<<"\n";
         return 0;
     }
     else{
         cout<<s<<"\n";
         return 0;
     }
 }
    return 0;
}


Measured memory_bytes: 3632