akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

struct Edge {
	long long int to;
	long long int cost;
};

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

	cin >> N >> M >> K;
	vector<vector<Edge>>edge(N + 1);
	vector<long long int>dis(N + 1, MOD);
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H;
		edge[L].push_back({ R,H });
		edge[R].push_back({ L,H });
	}
	priority_queue<pair<long long int, int>, vector<pair<long long int, int>>, greater<pair<long long int, int>>>PQ;
	for (int i = 0; i < K; i++) {
		cin >> L;
		dis[L] = 0;
		PQ.push({ 0,L });
	}
	while (!PQ.empty()) {
		int cn = PQ.top().second;
		long long int c = PQ.top().first;
		PQ.pop();
		if (c > dis[cn])continue;
		for (auto i : edge[cn]) {
			if (dis[i.to] > dis[cn] + i.cost) {
				dis[i.to] = dis[cn] + i.cost;
				PQ.push({ dis[i.to],i.to });
			}
		}
	}
	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, dis[i]);
		for (auto j : edge[i]) {
			if (abs(dis[i] - dis[j.to]) < j.cost) {
				long long int box = j.cost - abs(dis[i] - dis[j.to]);
				box = box / 2 + (box & 1);
				ans = max(ans, max(dis[i], dis[j.to] + box));
			}
		}
	}
	cout << ans << endl;
	return 0;
} 


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

using namespace std;

int main(){
    char s[101];
    cin >> s;

    int i=0;
  	int l=strlen(s);
    bool ans=true;
    while(s[i]!='\0'){
		if(i%2==0+1){
          if(s[i]=='R'){
            ans=false;
            break;
          }
        }else{
          if(s[i]=='L'){
			ans=false;
            break;
          }
        }
             i++;
    }
    
      
    if(ans){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 256
list = [int(i) for i in input().split()]
money = 0

for i in range(len(list)):
    if list[i] == 1:
        money += 300000
    elif list[i] == 2:
        money += 200000
    elif list[i] == 3:
        money += 100000

if list[0] * list[1] == 1:
    money += 400000

print(money)

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i <= n - 3; i++) {
   if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
   }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll a;
    ll b;
    cin >> a >> b;
    ll  x = a * b;
    int temp;
    if (a < b) {
        temp = a;
        a    = b;
        b    = temp;
    }
    ll r = a % b;

    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    cout << x / b << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
M = [list(str(input())) for _ in range(H)]

cnt = 0
for i in range(H):
    for j in range(W):
        if M[i][j]=="#":
            cnt += 1
if cnt!=H+W-1:
    print("Impossible")
else:
    def dfs(x, y):
        if x==W-1 and y==H-1:
            return 1
        ret = 0
        if x+1<W and M[y][x+1]=='#':
            ret += dfs(x+1, y)
        if y+1<H and M[y+1][x]=="#":
            ret += dfs(x, y+1)
        return ret
    
    if dfs(0, 0)>0:
        print('Possible')
    else:
        print('Impossible')

Measured memory_bytes: 62056
import copy

n = int(input())
p = list(map(int, input().split()))
p_new = copy.copy(p)
for i in range(n-1):
  if p[i] > p[i+1]:
    min_val = min(p[i+1:])
    for j in range(n):
      if p[j] == min_val:
        p_new[i] = min_val
        p_new[j] = p[i]
        break
    break

if p_new == sorted(p):
  print('YES')
else:
  print('NO')

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

string s;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    
    for(int i=0;i<s.size();i++)
    {
    	cout<<'x';
	}
    
	return 0;
	
	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B, K, tmpA, tmpB;
    cin >> A >> B >> K;

    for(int i = 0; i < K; i++){
        if(A % 2 != 0){
            A = A - 1;
            tmpA = A / 2;
        }else{
            tmpA = A / 2;
        }
        A = A - tmpA;
        B = B + tmpA;
//        cout << A << B << endl;
        i = i + 1;
        if (i > K - 1) break;
//        cout << i << endl;
        if(B % 2 != 0){
            B = B - 1;
            tmpB = B / 2;
        }else{
            tmpB = B / 2;
        }
        B = B - tmpB;
        A = A + tmpB;
    }
    cout << A << " " <<B << endl;
}

Measured memory_bytes: 256
using System.Linq;using static System.Console;class K{int[]G=>ReadLine().Split().Select(i=>int.Parse(i)-1).ToArray();int N;int[]X=>new int[N];static void Main()=>new K().Z();void Z(){var I=G;N=I[0]+1;WriteLine(string.Join(" ",C(G,G,I[1]).Select(i=>i+1)));}int[]C(int[]p,int[]q,int K){int[]P=I(p),Q=I(q),x=E(M(q,P,Q,p),K/6),y=I(x);switch(K%6){case 0:return M(x,p,y);case 1:return M(x,q,y);case 2:return M(x,q,P,y);case 3:return M(x,q,P,Q,y);case 4:return M(x,q,P,Q,p,Q,y);default:return M(x,q,P,Q,p,p,Q,y);}}int[]I(int[]a){var c=X;for(var i=0;i<N;i++)c[a[i]]=i;return c;}int[]M(params int[][]l)=>l.Aggregate((a,b)=>{var p=X;for(var i=0;i<N;i++)p[i]=a[b[i]];return p;});int[]E(int[]a,int b){int[]p=X,f=X,l=X;for(var i=0;i<N;i++)if(f[i]<1){int x=i,C=0;while(f[x]<1){l[C++]=x;f[x]=1;x=a[x];}for(var j=0;j<C;j++)p[l[j]]=l[(j+b)%C];}return p;}}

Measured memory_bytes: 38728
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;


void main(){
    long a, b, c, d, e, f;
    readlnTo(a, b, c, d, e, f);

    auto dp = new bool[][](3001, 3001);
    dp[0][0] = true;
    long ansTotal = 100*a;
    long ansSugar = 0;
    foreach(total; iota(f+1)) {
        foreach(sugar; iota(f+1)) {
            if(100 * sugar > e * (total - sugar)) {
                continue;
            }
            if(total >= 100 * a) {
                dp[total][sugar] |= dp[total-100*a][sugar];
            }
            if(total >= 100 * b) {
                dp[total][sugar] |= dp[total-100*b][sugar];
            }
            if(sugar >= c) {
                dp[total][sugar] |= dp[total-c][sugar-c];
            }
            if(sugar >= d) {
                dp[total][sugar] |= dp[total-d][sugar-d];
            }
            if(dp[total][sugar] && sugar * ansTotal > total * ansSugar) {
                ansTotal = total;
                ansSugar = sugar;
            }
        }
    }
    writeln(ansTotal);
    writeln(ansSugar);
}



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

#include<set>
using namespace std;
int n, m;
int x, y;
int p[108000];
set<int> nums[108000];
int ans;
int u[108000];
int r(int x){
	if(u[x] == x)return x;
	return u[x] = r(u[x]);
}

int unite(int x, int y){
	x = r(x);
	y = r(y);
	u[x] = y;
}

int main(){
	for(int i = 0;i < 108000;i++)u[i] = i;
	cin >> n >> m;
	for(int i = 0;i < n;i++)cin >> p[i], p[i]--;
	for(int i = 0;i < m;i++){
		cin >> x >> y;x--,y--;
		unite(x, y);
	}

	for(int i = 0;i < n;i++){
		nums[r(i)].insert(i);
	}

	for(int i = 0;i < n;i++){
		set<int>::iterator it;
		for(it = nums[i].begin();it != nums[i].end();it++){
			if(nums[i].count(p[*it]))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10752
import math

def dist(X1,X2):
  d=[abs(X1[i]-X2[i]) for i in range(len(X1))]
  d=[x**2 for x in d]
  d=sum(d)
  d=math.sqrt(d)
  return d
 
count=int(0)
N,D=map(int,input().split())
X=list(range(N))
for i in range(N):
  X[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(i+1,N):
    d=dist(X[i],X[j])
    if d.is_integer():
      count=count+1
print(count)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, M;

    cin >> N >> M;

    if(N==M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

class Prime
{
public:
    static bool is_prime(long long n) {
        if (n == 1) return false;
        for (ll a = 2; a * a <= n; ++a) if (n % a == 0) return false;
        return true;
    }
    static std::vector<long long> listup(long long n) {
        std::vector<long long> ret;
        for (long long i = 1; i * i < n; ++i) {
            if (n % i == 0) ret.push_back(i);
            long long other = n / i;
            if (other != i) ret.push_back(other);
        }
        std::sort(ret.begin(), ret.end());
        return ret;
    }
    static std::vector<std::pair<long long, long long>> factorize(long long n) {
       std::vector<pair<long long, long long>> res;
        for (long long a = 2; a * a <= n; ++a) {
            if (n % a != 0) continue;
            long long ex = 0;
            while (n % a == 0) {
                ++ex;
                n /= a;
            }
            res.push_back({a, ex});
        }
        if (n != 1) res.push_back({n, 1});
        return res;
    }
};

void solve() {
    ll n; cin >> n;
    ll ret = 1;
    FOR(i, 2, n+1) {
        if (Prime::is_prime(i)) {
            ll multiplier = 1;
            for (ll x = n; x /= i; multiplier += x) {};
            ret = ret * multiplier % MOD;
        }
    }
    cout << ret << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin>>b;
  int l=b.length(),x=0,j;
  for(j=0;j<l;j++){
    if(b[j]=='g') x++;
    else if(b[j]=='p') x--;
  }
  cout<<x/2<<endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

#define x first
#define y second

int getArea(int x1, int y1, int x2, int y2, int x3, int y3) {
    return abs((x1-x2)*(y3-y2)-(x3-x2)*(y1-y2));
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    while (cin >> n, n) {
        map<int, bool> has;

        vector<pair<int,int> > co(n);
        for (int i=0; i<n; ++i) {
            cin >> co[i].x >> co[i].y;
            has[co[i].x+10000*co[i].y] = true;
        }
        sort(co.begin(), co.end());

        int area = 0, mxhyp = 0;
        for (int i=0; i<(int)co.size(); ++i) {
            for (int j=i+1; j<(int)co.size(); ++j) {
                int dx = co[j].x - co[i].x;
                int dy = co[j].y - co[i].y;
                if (mxhyp < dx * dx + dy * dy) {
                    int x3 = co[j].x - dy;
                    int y3 = co[j].y + dx;
                    int x4 = co[i].x - dy;
                    int y4 = co[i].y + dx;
                    if (has.count(x3+10000*y3) && has.count(x4+10000*y4)) {
                        area = max(area, getArea(co[i].x, co[i].y, co[j].x, co[j].y, x3, y3));
                        mxhyp = dx * dx + dy * dy;
                    }
                }
            }
        }
        cout << area << endl;
    }
    return 0;
}

Measured memory_bytes: 1368
#include<bits/stdc++.h>
using namespace std;
void print_err() {
	cerr << "\n";
}
template <class T, class... Arg>
void print_err(T x, Arg&&... args) {
	cerr << x << " ";
	print_err(args...);
}
#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#else
#define debug(...)
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define mll map<ll,ll>
#define mllrev map<ll,ll,greater<int>>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) ll t;cin>>t;while(t--)
#define fo(i,n) for(ll i=0;i<n;++i)
#define foab(i,a,b) for(ll i=a;i<b;++i)
#define inp cin>>
#define pr cout<<
#define fastio ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
class Graph {
public:
	list<ll> *adj_list;
	ll v;
	Graph(ll v) {
		this->v = v;
		adj_list = new list<ll>[v];
	}
	void add_edge(ll u, ll v, bool bidirectional = true) {
		adj_list[u].push_back(v);
		if (bidirectional) {
			adj_list[v].push_back(u);
		}
	}
	void print();
	void connected_compo();
	void dfs(ll v, bool visited[]);
	void bfs(ll v, bool visited[]);
};
ll dp[101][100001];
ll recurese(ll n, ll w, ll* val, ll* wt) {
	if (n == 0 or w == 0) {
		return 0;
	}
	if (dp[n][w] != -1) {
		return dp[n][w];
	}
	if (wt[n - 1] <= w) {
		return dp[n][w] = max(val[n - 1] + recurese(n - 1, w - wt[n - 1], val, wt), recurese(n - 1, w, val, wt));
	} else if (wt[n - 1] > w) {
		return dp[n][w] = recurese(n - 1, w, val, wt);
	}
	return dp[n][w];
}
void solve() {
	// // http://codeforces.com/problemset/problem/445/A
	// inp n >> m;
	// fo(i, n) {
	// 	fo(j, m) {
	// 		inp ch[i][j];
	// 	}
	// }
	ll n, w;
	inp n >> w;
	ll val[n], wt[n];
	fo(i, n) {
		inp wt[i];
		inp val[i];
	}
	memset(dp, -1, sizeof(dp));
	// ll ans=
	cout << recurese(n, w, val, wt) << endl;
	return ;
}
int main() {
	fastio
#ifdef local
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	solve();
	return 0;
}
// ll n, m;
// char ch[100][100];
// bool istrue = false;
// ll dx[] = { -1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
// void dfs(ll row, ll col, char ch) {
// 	if (ch[row][col] == 'B' or ch[row][col] == 'W' or ch[row][col] == '-' or istrue) {
// 		return;
// 	}
// 	fo(i, 4) {
// 		if (isvalid(ch, row + dx[i], col + dy[i])) {
// 			if (ch == 'B') {
// 				dfs(row + dx[i], col + dy[i], 'W');
// 			} else if (ch == 'W') {
// 				dfs(row + dx[i], col + dy[i], 'B');
// 			}
// 		}
// 	}
// }

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

int main() {
  int a;
  int b;
  cin >> a >> b;
  if(a<b) cout << "a < b" << endl;
  if(a>b) cout << "a > b" << endl;
  if(a==b) cout << "a == b" << endl;
  
}

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

int main() {
    int n;
    cin>>n;
    int v[n],c[n],t[n],s=0;
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    for(int i=0;i<n;++i){
        cin>>c[i];
    }
    for(int i=0;i<n;++i){
        if(v[i]-c[i]>0){
            s+=v[i]-c[i];
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
k = input()
s = raw_input()

if k==0:
    print s
    exit(0)
if len(s) % (k+1) == 0:
    p = len(s) / (k+1)
    print max(int(s[i:i+p]) for i in xrange(0,len(s),p))
    exit(0)

l = len(s) / (k+1)
r = (len(s)+k) / (k+1)
left = (10**l-1)/9
right = 10**r
while right-left > 1:
    mid = (left + right) / 2
    cnt = 0
    mid_c = str(mid)
    cp = idx = 0
    for c in s:
        if not cp and idx < len(mid_c) and c != mid_c[idx]:
            cp = 1 if c > mid_c[idx] else -1
        idx += 1
        if (idx == len(mid_c) and cp == 1) or idx > len(mid_c):
            cnt += 1
            idx = 1; cp = 0
            if int(c) > mid:
                cnt = 100003
                break
            if c != mid_c[0]:
                cp = 1 if c > mid_c[0] else -1
    if cnt > k:
        left = mid
    else:
        right = mid
print left+1


Measured memory_bytes: 2948
#include<iostream>
#include<string>
using namespace std;
string s, o;
void J() {
	string st = s[s.size() - 1] + s.substr(0, s.size() - 1);
	s = st;
	return;
}
void C() {
	string st = s.substr(1, s.size() - 1) + s[0];
	s = st;
	return;
}
void E() {
	string a, b, st;
	int k = (s.size() - s.size() % 2) / 2;
	a = s.substr(0, k);
	if (s.size() % 2)st = s[k];
	b = s.substr(k + s.size() % 2, k);
	s = b + st + a;
	return;
}
void A() {
	string st;
	for (int i = s.size() - 1; i >= 0; i--)st += s[i];
	s = st;
	return;
}
void P() {
	string st;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')st += '9';
		else if (s[i] == '1')st += '0';
		else if (s[i] == '2')st += '1';
		else if (s[i] == '3')st += '2';
		else if (s[i] == '4')st += '3';
		else if (s[i] == '5')st += '4';
		else if (s[i] == '6')st += '5';
		else if (s[i] == '7')st += '6';
		else if (s[i] == '8')st += '7';
		else if (s[i] == '9')st += '8';
		else st += s[i];
	}
	s = st;
	return;
}
void M() {
	string st;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')st += '1';
		else if (s[i] == '1')st += '2';
		else if (s[i] == '2')st += '3';
		else if (s[i] == '3')st += '4';
		else if (s[i] == '4')st += '5';
		else if (s[i] == '5')st += '6';
		else if (s[i] == '6')st += '7';
		else if (s[i] == '7')st += '8';
		else if (s[i] == '8')st += '9';
		else if (s[i] == '9')st += '0';
		else st += s[i];
	}
	s = st;
	return;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> o >> s;
		for (int j = o.size() - 1; j > -1; j--) {
			if (o[j] == 'J')J();
			else if (o[j] == 'C')C();
			else if (o[j] == 'E')E();
			else if (o[j] == 'A')A();
			else if (o[j] == 'P')P();
			else if (o[j] == 'M')M();
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
int n,x,y;

signed abs(int i){
  if(i<0) return -i;
  return i;
}

signed dist(int i,int j){
  return min(abs(i-x)+abs(j-y)+1, abs(j-i));
}

signed main(){
  cin >> n >> x >> y;
  int ans[2002]={};
  LOOP1(i,n-1){
    FOR(j,i+1,n+1){
      ans[dist(i,j)]++;
      // cerr << i << "-" << j << ";" << dist(i,j) << endl;
    }
  }
  LOOP1(i,n-1){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r,D,x;
    cin >> r >> D >> x;
    ll v = x;
    rep(i,0,10){
        v = r * v - D;
        print(v);

    }
    
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
    
    ans = 0
    for x in arr:
        if x >= k:
            ans += 1
    
    print(ans)
    
    return 0

main()


Measured memory_bytes: 11896
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int k;
  cin >> k;
  int a=7%k;
  rep(i, k){
    if(a==0){
      cout << i+1 << endl;
      return 0;
    }
    a=(10*a+7)%k;
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  int ocnt = 0;
  int ecnt = 0;
  forn(n0,n) {
    ll t;
    cin >> t;
    if(t % 2 == 0) {
      ecnt++;
    }
    else {
      ocnt++;
    }
  }

  bool res = false;
  if(ocnt == 1 && ecnt == 0) {
    res = true;
  }
  else {
    if(ocnt % 2 == 0) {
      res = true;
    }
  }
  cout << (res?(string)"YES":(string)"NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
long dp[maxn][maxn];

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int l = n - 1; l >= 0; --l) {
        for (int r = l; r < n; ++r) {
            dp[l][r] = max(a[l] - (l + 1 <= r ? dp[l + 1][r] : 0), a[r] - (r - 1 >= l ? dp[l][r - 1]: 0));
        }
    }
    cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 70016
N, M, X = map(int, input().split(" "))
B_list = []


for Books in range(N):
    B_list.append(list(map(int, input().split(" "))))
# print(B_list)

bug = []
for k in range(M + 1):
    bug.append(0)
# print(bug)
ways = []

for way in range(2**N):
    for book in range(N):
        if ((way >> book) & 1) == 1:
            for i in range(M + 1):
                bug[i] += B_list[book][i]

    # print(bug)
    O = bug.pop(0)
    clear = [l for l in bug if l >= X]
    # print(clear)

    if len(bug) == len(clear):
        ways.append(O)

    bug = []
    for k in range(M + 1):
        bug.append(0)

if len(ways) == 0:
    print(-1)
else:
    print(min(ways))


Measured memory_bytes: 9240
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,pi
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n=ii()

print(2*3.14159265*n)






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

using namespace std;
int n, k, a[101];
bool can[200001];
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = k + 1; i <= k + k; i++){
        can[i] = 1;
    }
    for(int i = k; i >= 0; i--){
        bool mn = 1;
        for(int j = 1; j <= n; j++){
            mn = min(can[a[j] + i], mn);
        }
        if(!mn){
            can[i] = 1;
        }
    }
    if(can[0]){
        cout << "First";
    }
    else{
        cout << "Second";
    }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		double a = in.nextDouble();
		double b = in.nextDouble();

		System.out.print((int)(a/b) + " " + (int)(a%b) + " ");
		System.out.printf("%f", (a/b));


	}

}



Measured memory_bytes: 28152
#include <stdio.h>

#define ll long long
#define FALSE 0
#define TRUE 1 

const ll INF = 1LL << 50;

int main(void){
    int N, M;
	int a[2000], b[2000], ne[2000] = {FALSE};
    ll c[2000], dist[2000], ans;
    
    int i, loop;
    
    scanf("%d%d", &N, &M);
    for(i = 0; i < M; i++){
        scanf("%d%d%lld", &a[i], &b[i], &c[i]);
        c[i] = -c[i];
    }
    
    for(i = 0; i < N; i++){
        dist[i] = INF;
    }
	dist[0] = 0;
	
	for(loop = 0; loop < N -1; loop++){
		for(i = 0; i < M; i++){
			if(dist[a[i]] - 1 == INF) continue;
			
			if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
			}
		}
	}
	ans = dist[N -1];
	
	for(loop = 0; loop < N; loop++){
		for(i = 0; i < M; i++){
			if(dist[a[i]] - 1 == INF) continue;
			
			if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
				ne[b[i] - 1] = TRUE;
			}
			
			if(ne[a[i] - 1] == TRUE){
				ne[b[i] - 1] = TRUE;
			}
		}
	}
	if(ne[N -1])	printf("inf\n");
	else			printf("%lld", -ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a[100010],c,d;
  cin >>n;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  if(a[n-1]%2==0){
    fr(i,n){
      if(a[i]>=(a[n-1]/2)){
        c=i;
        break;
      }
    }
    if(a[c]-(a[n-1]/2)<(a[n-1]/2)-a[c-1]) d=a[c];
    else d=a[c-1];
  }
  else{
    fr(i,n){
      if(a[i]>(a[n-1]/2)){
        c=i;
        break;
      }
    }
    if(a[c]-1-(a[n-1]/2)<(a[n-1]/2)-a[c-1]) d=a[c];
    else d=a[c-1];
  }
  cout<<a[n-1]<<" "<<d;
}

Measured memory_bytes: 1024
import java.io.PrintWriter
val pw = PrintWriter(System.out)

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

fun func() {
    val n = nextInt()

    if (n < 10) {
        println(n)
    } else if (n < 100) {
        println(9)
    } else if (n < 1000) {
        println(n - 90) // - 10..99
    } else if (n < 10000) {
        println(9+900)
    } else if (n < 100000) { // 10000..99999
        println(n - 10000 + 1 + 900 + 9)
    } else { // 100000...
        println(90000 + 900 + 9)
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

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

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int cnt=0;
    for(auto i:s)if(i=='o')++cnt;
    if(cnt+15-s.size()>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
 
N = int(input())
MOD = 10**9+7
mp = defaultdict(int)
for i in range(2, N+1) :
  x = i
  for j in range(2, x+1): 
    while x%j == 0:
      x /= j
      mp[j] += 1
      
ans = 1
for v in mp.values():
  ans = (ans * (v+1)) % MOD
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;

  int l = S.length();

  int ans = 100000;
  for(int i=0;i<l-2;i++){
  	string sub = S.substr(i, 3);
  	int candidate = atoi(sub.c_str());
 // 	cout << sub <<endl;
  	ans = min(ans, abs(753-candidate));
  }

  cout << ans <<endl;
   
  

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin>>s;
    bool flag=false;
    do{
        s.pop_back();
        s.pop_back();
        int n=s.size()/2;
        if(s.substr(0,n)==s.substr(n)){
            flag=true;
        }
    }while(!flag);
    cout<<s.size()<<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){

        int N = nextInt();
        int A = nextInt();
        int B = nextInt();

        println(Math.min(N*A, B));
    }

    static int nextInt(){
        return Integer.parseInt(sc.next());
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 24020
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(a,b,c)=input.split(" ")
    if(a==b){
      c
    }else if(b==c){
      a
    }else{
      b
    }
  }
}


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

const int MAX_N = 1000000;

// p[i] := i ツ氾板姪堋づ個素ツ青?
vector<int> p;
// is_p[i] := i ツつェツ素ツ青板づ個づ?つォ true
bool is_p[MAX_N+1] = {false,false};
// cnt_p[i] := i ツ暗按可コツづ個素ツ青板づ個青?
int cnt_p[MAX_N+1];

// ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
void sieve(){
	for(int i = 2 ; i <= MAX_N ; i++ )
		is_p[i] = true;
	for(int i = 2 ; i*i <= MAX_N ; i++ ){
		if( is_p[i] ){
			p.push_back( i );
			for(int j = i+i ; j <= MAX_N ; j += i ){
				is_p[j] = false;
			}
		}
	}
	// ツ任ツ暗督づ?i ツ暗按可コツづ個素ツ青板づ個古つ青板づーツ仰?づ淞づゥ(i <= MAX_N)
	int cnt = 0;
	for(int i = 0 ; i <= MAX_N ; i++ ){
		if( is_p[i] ){
			cnt++;
		}
		cnt_p[i] = cnt;
	}
}

int main(){
	sieve();
	int n;
	while( cin >> n , n ){
		cout << (cnt_p[2*n] - cnt_p[n]) << endl;
	}
}

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

#define fi first
#define se second
#define ep emplace_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s, t; cin >> s >> t;

  if (si(s) != si(t)) {
    if (si(s) < si(t)) cout << "LESS" << endl;
    else cout << "GREATER" << endl;

    return (0);
  }

  rep(i, si(s)) {
    if (s[i] < t[i]) {
      cout << "LESS" << endl;
      return (0);
    } else if (s[i] > t[i]) {
      cout << "GREATER" << endl;
      return (0);
    }
  }

  cout << "EQUAL" << endl;
  
  return (0);
}

Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    int n, m;
    string s[100], t[100];
    cin >> n;
    rep(i, n) cin >> s[i];
    cin >> m;
    rep(i, m) cin >> t[i];
    int ma = 0;
    rep(i, n)
    {
        int sum = 0;
        rep(j, n)
        {
            if (s[i] == s[j]) sum++;
        }
        rep(j, m)
        {
            if (s[i] == t[j]) sum--;
        }
        ma = max(ma, sum);
    }
    cout << ma << endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  while(true) {
    string s;
    cin >> s;
    if(s == "0") break;

    int n = s.size();
    int now = 0, cnt[15] = {}, ans = 0;
    cnt[0] = 1;
    REP(i, n) {
      if(i%2==0) now += (s[i]-'0')*10;
      else now += (s[i]-'0');
      now %= 11;
      if(i+1<n && s[i+1]!='0') {
        ans += cnt[now%11];
        cnt[now%11]++;
      } else {
        ans += cnt[now%11];
      }
      // cout << i << " " << s[i] << " " << now << "," << cnt[now%11] << "," << ans << endl;
    }

    cout << ans << endl;
  }

  return 0;
}



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

int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    /*
    "dream"
    "dreamer"
    "erase"
    "eraser"
    */
    int start_pos = 0;

    bool result = false;
    while(true)
    {
        /* std::cout << in_str.length() << " " << start_pos << std::endl; */
        if(in_str.length() <= start_pos)
        {
            result = true;
            break;
        }

        auto tmp_str = in_str.substr(start_pos, 5);
        /* std::cout << "tmp: " << tmp_str << " " << start_pos + 5 << std::endl; */
        if(tmp_str == "dream")
        {
            auto era = in_str.substr(start_pos + 5, 3);
            /* std::cout << era << std::endl; */

            if(era.substr(0, 2) == "er")
            {
                if(era == "era")
                {
                    start_pos += 5;
                }
                else
                {
                    start_pos += 7;
                }
            }
            else
            {
                start_pos += 5;
            }
        }
        else if(tmp_str == "erase")
        {
            auto era = in_str.substr(start_pos + 5, 3);
            /* std::cout << era << std::endl; */
            if(era.substr(0, 1) == "r")
            {
                start_pos += 6;
            }
            else
            {
                start_pos += 5;
            }
        }
        else
        {
            result = false;
            break;
        }
    }
    if(result)
    {
        std::cout << "YES" << std::endl;
    }
    else
    {
        std::cout << "NO" << std::endl;
    }

}

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

int main()
{
  int n;
  cin >> n;
  int x, y, z, dp[n][3]={};
  cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
  for(int i=1; i<n; i++)
  {
    cin >> x >> y >> z;
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + x;
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + y;
    dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + z;
  }
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
  return 0;
}

Measured memory_bytes: 1408
/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;


#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000
#define NMAX                    100005


ll power(ll base,ll p){ll mul=1;for(ll i=1;i<=p;i++)mul*=base;return mul;}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll H ;
    cin >> H ;
    ll p = log2(H) + 1 ;
    
    cout << power(2,p) - 1 << endl ;

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

ll N;
PL d[100000];
int main(void){
    cin >> N;
    rep(i, N) cin >> d[i].first;
    SORT(d,N);
    cout << d[N/2].first - d[N/2-1].first << endl;

    return 0;
}



Measured memory_bytes: 1792
import numpy as np
s = input()
y = 2019
dp = np.zeros(y, dtype="int64")
tmp = np.zeros(y, dtype="int64")
k = 1
r = 0
for c in s[::-1]:
    i = int(c)*k%y
    tmp[i:] = dp[:y-i]
    tmp[:i] = dp[y-i:]
    tmp[i] += 1
    dp, tmp = tmp, dp
    r += dp[0]
    k *= 10
    k %= y
print(r)

Measured memory_bytes: 27172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <unsigned int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    ModInt inverse() const { return pow(mod - 2); }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
};

const int mod = 998244353;
using Mint = ModInt<mod>;

Mint dp[3030][3030];

void solve() {
    int n, s;
    cin >> n >> s;
    vector<int> A(n);
    vector<Mint> dp(s + 1, 0);
    Mint ans = 0;
    rep(i, n) cin >> A[i];
    rep(i, n) {
        dp[0] += 1;
        for (int j = s; j >= 0; j--) {
           if (j + A[i] > s) continue;
            dp[j + A[i]] += dp[j];
        }
        ans += dp[s];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 75416
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

// ===========Disjoint Set Union================
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
// =======================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  dsu d(N);
  vector<vector<ll>> P(N);
  set<ll> y_remain;
  vector<ll> X(N), Y(N);
  vector<ll> y_to_index(N + 1);
  for (ll i = 0; i < N; ++i) {
    cin >> X.at(i) >> Y.at(i);
    P.at(i) = {X.at(i), Y.at(i), i};
    y_to_index.at(Y.at(i)) = i;
    y_remain.insert(Y.at(i));
  }
  sort(P.begin(), P.end());
  for (ll i = 0; i < N; ++i) {
    vector<ll> now = P.at(i);
    ll x = now.at(0), y = now.at(1), index = now.at(2);
    auto itr1 = y_remain.lower_bound(y);
    if (itr1 == y_remain.end() || *itr1 != y) {
      continue;
    }
    y_remain.erase(y);
    auto itr = y_remain.lower_bound(y);
    while (itr != y_remain.end()) {
      ll temp_y = *itr;
      if (d.same(y_to_index.at(y), y_to_index.at(temp_y))) {
        break;
      }
      d.merge(y_to_index.at(y), y_to_index.at(temp_y));
      // cout << y_to_index.at(y) << ' ' << y_to_index.at(temp_y) << "\n";
      itr++;
    }
  }
  for (ll i = 0; i < N; ++i) {
    cout << d.size(i) << "\n";
  }
}


Measured memory_bytes: 29064
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b,x=0;
    cin>>a>>b;
    for(int i=a;i<=b;++i){
        string s=to_string(i);
        x+=(s[0]==s[4] && s[1]==s[3]);
    }
    cout<<x<<endl; 
    return 0;
}


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

int main(void)
{
	int i,j,round,m_score,f_score;
	char m[30],f[30];
	
	scanf("%d",&round);
	m_score = 0;
	f_score = 0;
	
	for(i=0;i<round;i++)
	{
		scanf("%s %s",m,f);
		
		if(m[0]-f[0] > 0)
			m_score += 3;
		else if(m[0]-f[0] < 0)
			f_score += 3;	
		
		else
		{
			if(strcmp(m,f)==0)
			{
				m_score += 1;
				f_score += 1;
			}
			else
			{
				j=1;
				while(m[j]-f[j]==0)
					j++;
				if( (m[j]=='\0' && f[j]!='\0') || m[j]-f[j] < 0)
					f_score += 3;
				else if( (m[j]!='\0' && f[j]=='\0')|| m[j]-f[j] > 0)
					m_score += 3;
			}
			
		}
	}
	
	printf("%d %d\n",m_score,f_score);
	
	
	return 0;
}

Measured memory_bytes: 604