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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    VLL x(n+1,0);
    rep(i,m){
      int l,r;
      cin >> l >> r;
      l--,r--;
      x[l]++;
      x[r+1]--;
    }
    rep(i,n){
      x[i+1] += x[i];
    }
    ll ans = 0;
    rep(i,n){
      if(x[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
n = list(input())
li = list()
for i in range(2**3):
    op = ["-"]*3
    for j in range(3):
        if ((i>>j)&1):
            op[2-j] = "+"
    ans = n[0]+op[0]+n[1]+op[1]+n[2]+op[2]+n[3]
    if (eval(ans) == 7):
        print(ans+"=7")
        break

Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
s = sum(a)
cnt = 0
res = INF
b = [0] * n
for i in range(n-1):
    a[i+1] = a[i+1] + a[i]
for i in range(n):
    res = min(res,abs(s-a[i]-a[i]))
print(res)

Measured memory_bytes: 107848
N = int(input())
h = list(map(int, input().split()))

ans = [float("inf")] * N
ans[0] = 0
for i in range(N-1):
    ans[i+1] = min(ans[i+1], ans[i] + abs(h[i] - h[i+1]))
    if i + 2 > N - 1:
        continue
    ans[i+2] = min(ans[i+2], ans[i] + abs(h[i] - h[i+2]))
print(ans[-1])  

Measured memory_bytes: 52552
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

H, W = MAP()
grid = build_grid(H, W, '#', str, space=False, padding=True)

# グリッドBFS
directions = ((1,0),(-1,0),(0,1),(0,-1))
que = deque([(1, 1, 0)])
dist = list2d(H+2, W+2, INF)
while que:
    h, w, c = que.popleft()
    if dist[h][w] != INF:
        continue
    dist[h][w] = c
    for dh, dw in directions:
        h2 = h + dh
        w2 = w + dw
        if grid[h2][w2] == '#':
            continue
        que.append((h2, w2, c+1))

# ゴール到達不可
if dist[H][W] == INF:
    print(-1)
    exit()

# 経路復元
que = deque([(H, W)])
while que:
    h, w = que.popleft()
    grid[h][w] = '@'
    for dh, dw in directions:
        h2 = h + dh
        w2 = w + dw
        if dist[h2][w2] == dist[h][w] - 1:
            que.append((h2, w2))
            break

# 最短経路で通る場所以外をカウント
ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if grid[i][j] == '.':
            ans += 1
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;


int Q[8];
void printMap(){
  rep(i,8){
    rep(j,8){
      if(j == Q[i])
        cout << "Q";
      else
        cout << ".";
    }
    cout << endl;
  }

}


int main(void){
  int k; cin >> k;
  bool defaultQueen[8];
  bool v[8];
  bool skew[16];
  bool skew_N[16];
  rep(i,8){
    defaultQueen[i] = false;
    v[i] = false;
  }
  rep(i,16){
    skew[i] = false;
    skew_N[i] = false;
  }



  int a,b;
  rep(i,k) {
    cin >> a >> b;
    defaultQueen[a] = true;
    v[b] = true;
    skew[a+b] = true;
    skew_N[a+7-b] = true;
    Q[a] = b;
  }
  
  bool backFlag = false;
  bool successFlag;
  bool putFlag;
  int line_num = 0;
  int base;

  while(line_num < 8){
    successFlag = false;
    if(backFlag && defaultQueen[line_num]){
      line_num -= 1;
      continue;
    }

    if(backFlag && !defaultQueen[line_num]){

      v[Q[line_num]] = false;
      skew[line_num+Q[line_num]] = false;
      skew_N[line_num+7-Q[line_num]] = false;
    }

    if(defaultQueen[line_num]){
      line_num += 1;
      continue;
    }

    if(backFlag) base = Q[line_num]+1;
    else         base = 0;

    for(int i = base; i < 8; i ++){
        if(!v[i] && !skew[line_num + i] && !skew_N[line_num + 7 - i] && !successFlag){
          v[i] = true;
          skew[line_num+i] = true;
          skew_N[line_num+7-i] = true;
          successFlag = true;
          Q[line_num] = i;
        }
      }
    backFlag = false;

    if(!successFlag){
      backFlag = true;
      line_num -= 1;
    }else{
      line_num += 1;
    }
  }

  printMap();


  return 0;
}

Measured memory_bytes: 3072
class BellmanFord:
    INF = int(1e18)
    N = -1
    edge = []
    
    def __init__(self, N):
        self.N = N
        
    def add_edge(self, frm, to, cost):
        self.edge.append((frm, to, cost));
        
    def add_bi_edge(self, a, b, cost):
        self.add_edge(a, b, cost)
        self.add_edge(b, a, cost)
    
    def calcD(self, start):
        D = [self.INF] * self.N
        D[start] = 0
        update, cnt = True, 0
        while update:
            update = False
            cnt = cnt + 1
            if cnt > self.N:
                return 'NegativeCycle'
            
            for frm, to, cost in self.edge:
                ncost = D[frm] + cost
                if D[frm] == self.INF or ncost >= D[to]:
                    continue
                D[to] = ncost
                update = True
                
        return D

    
V, E, S = list(map(int, input().split()))
bf = BellmanFord(V)
for i in range(E):
    frm, to, cost = list(map(int, input().split()))
    bf.add_edge(frm, to, cost)
    

ans = bf.calcD(S)
if ans == 'NegativeCycle':
    print("NEGATIVE CYCLE")
else:
    for i in range(V):
        print ('INF' if ans[i] == bf.INF else ans[i])



Measured memory_bytes: 6144
class uf:

    def __init__(self, n):
        self.table = [-1] * (n + 1)
        self.size = [1] * (n + 1)

    def merge(self, r1, r2):
        self.table[r1] = r2
        self.size[r2] += self.size[r1]
        self.size[r1] = 0

    def find_root(self, k):
        path = []
        curr = k
        while self.table[curr] != -1:
            path.append(curr)
            curr = self.table[curr]
        return curr, path

    def defrag(self, r, p):
        for i in p:
            self.table[i] = r

    def defrag_all(self):
        for i in range(len(self.table)):
            if self.table[i] == -1:
                continue
            self.defrag(*self.find_root(i))

    def in_same_group(self, k1, k2):
        r1, p1 = self.find_root(k1)
        r2, p2 = self.find_root(k2)
        if r1 == r2:
            self.defrag(r1, p1 + p2)
        else:
            self.defrag(r1, p1)
            self.defrag(r2, p2)
        return r1 == r2


def cul_comb(n):
    return n * (n - 1) // 2


def solve(string):
    n, m, *ab = map(int, string.split())
    ab = ab[::-1]
    ans = [cul_comb(n)]
    table = uf(n)
    for _b, _a in zip(ab[:2 * m - 2:2], ab[1:2 * m - 2:2]):
        if table.in_same_group(_b, _a):
            ans.append(ans[-1])
        else:
            r_a, p_a = table.find_root(_a)
            r_b, p_b = table.find_root(_b)
            ans.append(ans[-1] - table.size[r_a] * table.size[r_b])
            table.merge(r_a, r_b)
            table.defrag(r_b, p_a)
            table.defrag(r_b, p_b)
    return "\n".join([str(a) for a in ans[::-1]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Measured memory_bytes: 26668
function MainD(input) {
	input = input.split("\n");
	var xyzk = input[0].split(" ");
	var x = parseInt(xyzk[0])
	var y = parseInt(xyzk[1]);
	var z = parseInt(xyzk[2]);
	var k = parseInt(xyzk[3]);

	function compare(a,b){
		return b - a;
	}
  var ax = input[1].split(" ").sort(compare);
  var by = input[2].split(" ").sort(compare);
  var cz = input[3].split(" ").sort(compare);

  var arr = [];

	//まずはbcの上位k件をサーチ
	for(var i = 0; i < y; i++){
		var cRem = Math.min(Math.floor(k / i),z);
		if(cRem){
			for(var j = 0; j < cRem; j++){
				arr.push(parseInt(by[i]) + parseInt(cz[j]));
			}
		}
	}
	arr = arr.sort(compare).slice(0,k);
	var newArr = [];

	//次にaとbcで組み合わせ
	for(var i = 0; i < x; i++){
		var cRem = Math.min(Math.floor(k / i),arr.length);
		if(cRem){
			for(var j = 0; j < cRem; j++){
				newArr.push(parseInt(ax[i]) + parseInt(arr[j]));
			}
		}
	}
	newArr = newArr.sort(compare).slice(0,k);
	for(var i in newArr){
		console.log("%d",newArr[i]);
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
MainD(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 16704
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int a,b,d,r;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	double f1,f2;
	f1=a/b;
    f2=1.0*a/b;
	cout<<d<<" "<<r<<" ";
	 printf ("%.5lf",f2);
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";
 
int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  print( min(a * n, b) );
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n,m; cin >> n >> m;
    vector<P> ab;
    priority_queue<int> pq;
    rep(i,n){
        int a,b; cin >> a >> b;
        ab.pb(P(a,b));
    }
    sort(ab.begin(),ab.end());
    // for(auto i : ab)cout << i.first << " " << i.second << endl;
    // rep(i,ab.size()) cout << ab[i].first << endl;
    int left = 0;
    ll ans = 0;
    for(int i = 0;i < m;i++){
        while(left < ab.size()){
            // cout << i  << ' ' << left << endl;
            if(ab[left].first == (i+1)){
                pq.push(ab[left].second);
                left++;
            }
            else break;
        }
        if(pq.size()){
            int temp = pq.top();pq.pop();
            ans += temp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define ge getchar 
#define pun putchar('\n')
#define pu putchar
#define puk putchar(' ')
char c;
int n,u,v;
ll p=1000000007,f,w[200008],g[50];
int sri(){c=ge();int x=0;while(c<'0')c=ge();while(c>='0')x=(x<<3)+(x<<1)+c-'0',c=ge();return x;}
void sc(ll x){int l=0;if(x==0)g[l=1]=0;while(x)g[++l]=x%10,x/=10;for(;l;l--)putchar(g[l]+'0');}
int main(){
	n=sri();f=1;
	while(n--){
		u=sri();
		if(u!=v){
			f+=w[u];if(f>=p)f-=p;
			w[u]=f,v=u;
		}
	}sc(f);
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define ll long long
using namespace std;
char str[5];
int main(){
	cin>>str;
	fu(i,0,1){
		if(str[i]!=str[i+1]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

string itos_withzero (int n)
{
	stringstream ss;
	ss << n;
	string str;
	ss >> str;

	int len = str.length();

	if (len < 8 ){
		str = string(8-len, '0') + str;
	} // end if

	return str;
} 
int stoi (string str )
{
	stringstream ss(str);
	int n;
	ss >> n;

	return n;
}

int middlesquare (int s )
{
	int res = 0;
	int m = s*s;

	string str = itos_withzero(m);

	str = str.substr (2, 4);
//	cout << str << endl;
	res = stoi (str);
//	cout << itos (m) << endl;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.ms", "r", stdin );
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		int s = 0;
		int res = 0;
		cout << "Case " << (i + 1) << ':' << endl;
		getline (cin, str );
		stringstream ss(str);
		ss >> s;

		for (j = 0; j < 10; ++j){
			res = middlesquare (s);
			cout << res << endl;
			s = res;
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
from itertools import combinations
n, a, b, c = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))
ans = 10**6
f = lambda li, k: abs(sum(li)-k)+10*(len(li)-1)
for i in range(4**n):
    li = [[] for _ in range(4)]
    for j in range(n):
        li[(i//(4**j))%4].append(l[j])
    if len(li[0])*len(li[1])*len(li[2])==0:
        continue
    ans = min(ans, f(li[0], a)+f(li[1], b)+f(li[2], c))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> ans(n);
    rep(i,k) {
        int d; cin>>d;
        rep(j,d) {
            int s; cin>>s;
            --s;
            ans[s]++;
        }
    }

    int cnt=0;
    rep(i,n) if (ans[i]==0) cnt++;
    cout << cnt << '\n';
    return 0;
}

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}
ll fact(ll x)
{
    ll res=1;
    for(ll i=2;i<=x;i++)
    {
        res=(res%md*i%md)%md;
    }
    res%=md;
    return res;
}

int main()
{
     ll n,a,b;
     cin>>n>>a>>b;
     ll res=0;
     res=(power((ll)2,n)%md-(ll)1+md)%md;
     //cout<<res<<"\n";
     ll a1=(ll)1,b1=(ll)1;
     for(ll i=1;i<=a;i++)
     {
         a1=(a1%md*(n-a+i)%md)%md;
     }
     for(ll i=1;i<=b;i++)
     {
         b1=(b1%md*(n-b+i)%md)%md;
     }
     a1=(a1%md*power(fact(a),md-(ll)2)%md)%md;
     b1=(b1%md*power(fact(b),md-(ll)2)%md)%md;
     res=(res-a1-b1+2*md)%md;
     cout<<res<<"\n";
      return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, T;
ll ans;
int main() {
    ans=inf;
    cin>>N>>T;
    REP(i,0,N){
        ll c,t;
        cin>>c>>t;
        if(t<=T){
            ans=min(ans,c);
        }
    }
    if(ans==inf){
        p("TLE");
    }else{
        p(ans);
    }
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,y=map(int,input().split())
    if x==-y:
        print(1)
    elif x*y>0:
        if x<y:
            print(y-x)
        else:
            print(x-y+2)
    elif x*y<0:
        print(abs(x+y)+1)
    else:
        if x>0:
            print(x+1)
        elif x<0:
            print(-x)
        elif y>0:
            print(y)
        else:
            print(-y+1)

if __name__=='__main__':
    main()

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  map<ll, ll> M;
  map<ll, pair<ll,ll>> ansMap;

  for (ll i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    A[i] = tmp;
    M[tmp]++;
  }

  // a 多い方
  for (auto item : M) {
    ll a = max((ll)0, item.second*(item.second-1)/2);
    ll b = max((ll)0, (item.second-1)*(item.second-2)/2);
    ansMap[item.first] = make_pair(a, b);
  }

  ll SUM = 0;
  for (auto item : ansMap) {
    SUM += item.second.first;
  }

  for (ll i = 0; i < N; i++) {
    cout << SUM - M[A[i]]+1 << endl;
  }

/*
  for (ll i = 0; i < N; i++) {
    ll ans = 0;
    for (auto item : M) {
      if (item.first == A[i]) ans += max((ll)0, (item.second-1)*(item.second-2)/2);
      else ans += max((ll)0, item.second*(item.second-1)/2);
    }
    cout << ans << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main(void){
 
  char w[10];
  char t[1000];
  char e[] = {"END_OF_TEXT"};
  int i, ii, iii;
  int c = 0;
 
  scanf("%s", w);
  ii = strlen(w);
  for(i = 0; i > -1; i++){
    for(i = 0; i < ii; i++){
      w[i] = tolower(w[i]);
    }
    scanf("%s", t);
    if(strcmp(e, t) == 0) break;
    iii = strlen(t);
    for(i = 0; i < iii; i++){
      t[i] = tolower(t[i]);
    }
    if(strcmp(w, t) == 0) c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int r = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    long[][] v = new long[r + 1][c + 1];
    for (int i = 0; i < k; i++) {
      int ri = sc.nextInt();
      int ci = sc.nextInt();
      long vi = sc.nextLong();
      v[ri][ci] = vi;
    }
    long[][][] dp = new long[r + 1][c + 1][4];
    for (int i = 1; i <= r; i++) {
      for (int j = 1; j <= c; j++) {
        dp[i][j][0] = dp[i - 1][j][0];
        dp[i][j][0] = Math.max(dp[i][j][0], dp[i - 1][j][1]);
        dp[i][j][0] = Math.max(dp[i][j][0], dp[i - 1][j][2]);
        dp[i][j][0] = Math.max(dp[i][j][0], dp[i - 1][j][3]);
        dp[i][j][0] = Math.max(dp[i][j][0], dp[i][j - 1][0]);
        dp[i][j][1] = dp[i][j - 1][1];
        dp[i][j][1] = Math.max(dp[i][j - 1][0] + v[i][j], dp[i][j][1]);
        dp[i][j][1] = Math.max(dp[i - 1][j][1] + v[i][j], dp[i][j][1]);
        dp[i][j][1] = Math.max(dp[i - 1][j][2] + v[i][j], dp[i][j][1]);
        dp[i][j][1] = Math.max(dp[i - 1][j][3] + v[i][j], dp[i][j][1]);
        dp[i][j][2] = Math.max(dp[i][j - 1][1] + v[i][j], dp[i][j - 1][2]);
        dp[i][j][3] = Math.max(dp[i][j - 1][2] + v[i][j], dp[i][j - 1][3]);
      }
    }
    long result = 0L;
    for (int i = 0; i <= 3; i++) result = Math.max(result, dp[r][c][i]);
    System.out.println(result);
  }
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int N;
  cin >> N;
  int tmp,cnt,ans;
  ans = 10000;
  rep(i, N) {
    cin >> tmp;
    cnt = 0;
    while (tmp % 2 != 1) {
      tmp /= 2;
      cnt++;
    }
    //cout << cnt << endl;
    ans = min(ans,cnt);
  }
  cout << ans;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;


*/


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

int main(){
  using ll=long long;
  int N; cin >> N;
  queue<string> q;
  map<string,ll> m;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if (m.count(S))
      m[S]++;
    else{
      m[S]=1LL;
      q.push(S);
    }
  }
  ll count=0;
  while(!q.empty()){
    for (int i=0;i<q.size();i++){
      string qf=q.front();
      q.pop();
      count+=m[qf]*(m[qf]-1LL)/2;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 16640
// https://atcoder.jp/contests/abc174/tasks/abc174_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "string"
#include "unordered_set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll K;
  cin >> K;

  ll cur = 7 % K;
  ll res = 1;

  unordered_set<ll> s;

  while (s.count(cur) == 0) {
    if (cur == 0) drop(res);

    s.insert(cur);
    cur = (10 * cur + 7) % K;
    ++res;
  }

  drop(-1);
}


Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 998244353;

int main(){
    char S;
    cin >> S;
    if(S >= 'a' && S <= 'z'){
        printf("a\n");
    }
    else{
        printf("A\n");

    }

}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>

using namespace std;

int mod_num_counter[2030];

int main()
{
  fill(mod_num_counter,mod_num_counter+2030,0);
  
  string s;
  cin >> s;
  
  int len = s.length();
  long long ans = 0;
  int p = 1;
  int num = 0;
  mod_num_counter[0] = 1;
  for(int i=len-1;i>=0;i--)
  {
    num += (s[i] - '0') * p;
    num %= 2019;
    ans += mod_num_counter[num];
    mod_num_counter[num]++;
    p = (10 * p) % 2019;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3764
import sys
import math
sys.setrecursionlimit(int(1e6))
#dprint = print
def dprint(*args):
  pass

money = 1000
stump = 0
n = list(map(int, input().split()))[0]
A = list(map(int, input().split()))
dprint('n = ', n)
dprint('A = ', A)

btm = A[0]
top = A[0]
for i in range(1, n):
  dprint('i = ', i)
  a_i = A[i]
  if (stump==0):
    # buy
    if a_i <= btm:
      btm = a_i
    else:
      p = money // btm
      stump = stump + p
      money = money - (p*btm)
      top = a_i
      btm = a_i
      dprint('[buy] stump, money', stump, money)
  else:
    # sell
    if a_i >= top:
      top = a_i
    else:
      money = money + (top*stump)
      stump = 0
      top = a_i
      btm = a_i
      dprint('[sell] stump, money', stump, money)

if (stump>0):
  money = money + (top*stump)
  dprint('[sell] stump, money', stump, money)

print(money)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll N,x;
  cin>>N>>x;
  vector<ll> a(N);
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=0;
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(x>=a[i]){
      ans++;
    }
    x-=a[i];
  }
  if(x>0) ans--;
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb 			second
#define mod 		n007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define for0(i, n) 	for(int i=0; i<n; i++)
#define fori(i,j,n) for(int i=j; i<=n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'

 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
	int k, x;
	cin >> k >> x;
	for(int i=max(-1000000, x-k+1); i<=min(1000000, x+k-1); i++)
		cout << i << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []

a = [[[0]*10 for _ in range(3)] for _ in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print('',*a[i][j])
    if i != 3:
        print('#'*20)

    


Measured memory_bytes: 5624
#include <stdio.h>

int main() {
	double x1, x2, x3, y1, y2, y3, xp, yp, z1, z2, z3;

	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
		z1 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
		z2 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
		z3 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);

		if ((z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0)){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int max = Math.max(a, b);
		int min = Math.min(a, b);
		
		if(c<=max && c>=min) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>
using namespace std;



int main()
{



     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

     

ll n,m;
cin>>n>>m;
if(n>m)
{
	for(ll i=0;i<n;i++)
		{
			cout<<m;
		}
}
else
{
	for(ll i=0;i<m;i++)
		{
			cout<<n;
		};
}




    ///////////////////////////////////////////////////////////////////////////////////////

     return 0;

}


Measured memory_bytes: 256
s = input()
devide = ["maerd", "remaerd", "esare", "resare"]

reverse_input = "".join(list(reversed(s)))
can = False
point = 0

for i in range(len(s)+1) :
    slice = reverse_input[point:i]
    if slice in devide :
        point += len(slice)
        can = True
    else :
        can = False

if can == True :
    print("YES")
else :
    print("NO")


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
queue<int> q;
int k;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>k;
	for(int i=1;i<=9;i++) q.push(i);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		k--;
		if(!k){
			cout<<x;
			break;
		}
		int a=x%10;
		for(int i=-1;i<=1;i++){
			if(a+i<0||a+i>9) continue;
			q.push(x*10+a+i);
		}
	}
	re 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
  using namespace std;
  #define ll long long
  int main()
  {
   ll a,b,c,d;
    cin>>a;
  string s;
  cin>>s;
 ll sum=0;
 ll max1=0;
   for(int i=0;i<a;i++)
     {
         if(s[i]=='I')
         {
             sum++;
         }
         else
         {
             sum--;
         }
         max1=max(sum,max1);
  }
   cout<<max1<<endl;
    return 0;
}


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

using namespace std;

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

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

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

using ll = long long;


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


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


*/


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

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


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

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

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

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}
	int n, m; cin >> n >> m;
	int k[111];
	int s[111][111];
	int p[111];

	for (int i = 0; i < m; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < k[i]; j++) {

		}
	}

*/

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

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

	}
}

*/


int main(void) {
	int n; cin >> n;

	vector<tuple<string, int,int>> v;

	string x[1000];
	int y[1000];

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		v.push_back(make_tuple(x[i], -1*y[i],i+1));
	}

	sort(v.begin(), v.end());

	for (tuple<string, int,int> A : v) {
		cout << get<2>(A) << endl;
	}

	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    vector<ll> dp(n,1e9);
    dp.at(0) = 0;
    for(i = 1;i < n;++i){
        for(j = 1;i-j >= 0 && j <= k;++j){
            dp.at(i) = min(dp.at(i), dp.at(i-j) + abs(h.at(i) - h.at(i-j)));
        }
    }
    cout << dp.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifndef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define test  \
	int t;    \
	cin >> t; \
	while (t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve()
{
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n - 1) cin >> v[i];
	sort(all(v));
	int x = v[n / 2 - 1], y = v[n / 2];
	debug() << imie(x) imie(y);
	cout << y - x << "\n";
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// test
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3960
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class AFrog1 {
    int n;
    vector<int> h;
    vector<int> dp;

    int MiniCost(int pos) {
        if (pos == n - 1) return 0;
        if (pos > n - 1) return P_INF;
        if (dp[pos] < P_INF) return dp[pos];

        int oneZump = abs(h[pos] - h[pos + 1]) + MiniCost(pos + 1);
        int twoZump = P_INF;
        if (pos + 2 <= n - 1)
            twoZump = abs(h[pos] - h[pos + 2]) + MiniCost(pos + 2);

        return dp[pos] = min(oneZump, twoZump);
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        in >> n;
        h.resize(n);
        dp.resize(n);
        for (int i = 0; i < n; ++i) {
            in >> h[i];
            dp[i] = P_INF;
        }
        out << MiniCost(0) << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    AFrog1 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10332
a = input().split()
b = []
for i in range(len(a)):
    if a[i] == "+":
        b[-2] = b[-2] + b[-1]
        b.pop()
    elif a[i] == "-":
        b[-2] = b[-2] - b[-1]
        b.pop()
    elif a[i] == "*":
        b[-2] = b[-2] * b[-1]
        b.pop()
    else:
        b.append(int(a[i]))
print(b[-1])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define FOR(n) for(int i=0;i<n;i++)
#define till(n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;



int main(){
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int h, w;cin >> h >> w;
    char a[h+1][w+1];
    int ans[h+1][w+1];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            ans[i][j] = 0;
        }
    }

    ans[h-1][w-1] = 1;

    for(int i = h-1;i>=0;i--){
        for(int j = w-1;j>=0;j--){
            if(a[i][j] == '.'){
                ans[i-1][j] = (ans[i-1][j] + ans[i][j]) % mod;
                ans[i][j-1] = (ans[i][j-1] + ans[i][j]) % mod;
            }
        }
    }

    cout << ans[0][0] << endl;

	return 0;
}


Measured memory_bytes: 5120
def cross_product(ax, ay, bx, by)
  ax * by - ay * bx
end

while line = gets
  x1, y1, x2, y2, x3, y3, xp, yp = line.chomp.split.map(&:to_f)
  s1 = cross_product(x2 - x1, y2 - y1, xp - x1, yp - y1)
  s2 = cross_product(x3 - x2, y3 - y2, xp - x2, yp - y2)
  s3 = cross_product(x1 - x3, y1 - y3, xp - x3, yp - y3)
  puts (s1 > 0 && s2 > 0 && s3 > 0 || s1 < 0 && s2 < 0 && s3 < 0) ? :YES : :NO
end

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

const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};
 
int main(void){
    int n;
    string s;
    cin>>n>>s;
    map<char, ll> mp;
    rep(i, n) mp[s[i]]++;
    mint ans = 1;
    for(auto p : mp){
        ans *= (p.second+1);
    }
    ans-=1;
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoderSolve
{
    class Solve
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Array.Sort(a);
            Array.Reverse(a);
            int cnt = 0;
            long ans = 1;

            for (var i = 1; i < N; i++) 
            {
                if (a[i - 1] == a[i])
                {
                    ans *= a[i];
                    cnt++;
                    i++;
                }
                if (cnt == 2)
                {
                    break;
                }
            }
            

            Console.WriteLine(cnt == 2 ? ans : 0);


            Console.Out.Flush();
        }
    }



    public class Calculation
    {
        
    }
}


Measured memory_bytes: 23136
N,M = [int(i) for i in input().split()]

li = [[] for _ in range(N)]
for _ in range(M):
    a,b = [int(i) for i in input().split()]
    li[a-1  ].append(b-1)

a = N+1
ans = 0
for i in range(N):
    if i == a:
        ans += 1
        a = N+1
    if len(li[i]) != 0:
        b = min(li[i])
        if a > b:
            a = b
print(ans)


Measured memory_bytes: 17968