akhauriyash/Code-Regression huggingface dataset:
using System;

public class Test
{
	public static void Main()
	{
        string[] str = Console.ReadLine().Split(' ');
        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);
        char[,] s = new char[h,w];
        string str1="";
        for(int i = 0;i<h;i++){
        	str1 = Console.ReadLine();
        	for(int j =0;j<w;j++){
        		s[i,j] = str1[j];
        	}
        }
        char[,] c = new Char[h*2,w];
        for(int i=1;i<=h*2;i++){
        	for(int j = 1;j<=w;j++){
        		double d = (i - 1)/2.0;
        		int b = (int)Math.Floor(d);
        		c[i-1,j-1] = s[b,j-1];
        		//Console.Write(d);
        		Console.Write(c[i-1,j-1]);
        	}
        	Console.WriteLine();
        }
	}
}

Measured memory_bytes: 2776
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(int argc, char const* argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	vector<int> dp(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int in_size = min(n - 1, k);
	for (int i = 0; i <= in_size; i++) {
		dp[i] = abs(arr[i] - arr[0]);
	}
	for (int i = k + 1; i < n; i++) {
		int ans = INT_MAX;
		for (int j = 1; j <= k; j++) {
			ans = min(ans, dp[i - j] + abs(arr[i] - arr[i - j]));
		}
		dp[i] = ans;
	}
	cout << dp[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 1024
#木DP, 木上の数え上げ

#前処理
#隣接リストを作る
#隣接頂点が最も多い頂点を根にして木を作る

#




def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    #頂点:0~N-1
    N = int(input())
    adj = [[] for _ in range(N)] #頂点数, 場合によって変える
    for _ in range(N-1):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)

    #隣接する頂点が一番多い頂点を根にする
    root = -1
    l = -1
    for i in range(N):
        t = len(adj[i])
        if t > l:
            l = t
            root = i

    #木を作る, c[i]:iの子
    c = [[] for _ in range(N)]
    #x:i, y:iの親
    def ch(x, y):
        for e in adj[x]:
            if e == y:
                continue
            c[x].append(e)
            ch(e, x)
    ch(root, -1)

    #dp[i][b, w]:iを根とする木の場合の数
    #bはiが黒, wはiが白のとき
    dp = [[-1, -1] for _ in range(N)]

    #xが葉の場合は1が返される
    #dp[x][0=b]を返す
    def black(x):
        if dp[x][0] != -1:
            return dp[x][0]
        res = 1
        for e in c[x]:
            res = white(e) * res %mod
        dp[x][0] = res
        return dp[x][0]

    #dp[x][0=w]を返す
    def white(x):
        if dp[x][1] != -1:
            return dp[x][1]
        res = 1
        for e in c[x]:
            res = ((black(e)+white(e))%mod) * res %mod
        dp[x][1] = res
        return dp[x][1]

    print((black(root)+white(root))%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 139028
# 解き直し
from collections import defaultdict
N = int(input())
c = defaultdict(int)
for _ in range(N):
    s = input()
    c[s] += 1
max_cnt = max(c.values())

anss = []
for k, v in c.items():
    if v == max_cnt:
        anss.append(k)

for ans in sorted(anss):
    print(ans)

Measured memory_bytes: 33364
unittest
{
	assert( [ "5", "2 4", "1 9", "1 8", "4 9", "3 12" ].parse.expand.solve == "Yes" );
	assert( [ "3", "334 1000", "334 1000", "334 1000" ].parse.expand.solve == "No" );
	assert( [ "30", "384 8895", "1725 9791", "170 1024", "4 11105", "2 6", "578 1815", "702 3352", "143 5141", "1420 6980", "24 1602", "849 999", "76 7586", "85 5570", "444 4991", "719 11090", "470 10708", "1137 4547", "455 9003", "110 9901", "15 8578", "368 3692", "104 1286", "3 4", "366 12143", "7 6649", "610 2374", "152 7324", "4 7042", "292 11386", "334 5720" ].parse.expand.solve == "Yes" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abs = new long[ 2 ][ n ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( abs );
}

auto solve( long[ 2 ][] abs )
{
	// 締め切りの遅い順にスケジューリングしてみる
	auto t = long.max;
	foreach( ab; abs.sort!( ( x, y ) => y[ 1 ] < x[ 1 ] ) )
	{
		if( ab[ 1 ] < t ) t = ab[ 1 ];
		t -= ab[ 0 ];
		if( t < 0 ) return "No";
	}
	return "Yes";
}


Measured memory_bytes: 5500
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	int n, m, x, y;
	cin >> n  >> m;
	bool go1[n] = {}, go2[n] = {};
	REP(i, m){
		cin >> x >> y;
		if (x == 1){
			go1[y] = true;
		}else if (y == 1){
			go1[x] = true;
		}
		if (x == n){
			go2[y] = true;
		}else if (y == n){
			go2[x] = true;
		}
	}
	REP(i, n){
		if (go1[i] && go2[i]){
			cout << "POSSIBLE" << "\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef pair<int,int> P;

struct query{
	int day;
	int l,r;
	int type;
	int id;
	query(){}
	query(int dd,int ll,int rr,int tt,int ii){
		day=dd;
		l=ll;
		r=rr;
		type=tt;
		id=ii;
	}
	bool operator<(const query &q)const{
		return day<q.day;
	}
};

struct segtree{
	static const int N=1<<18;
	int dp[1<<19];
	int lazy[1<<19];
	segtree(){}
	void lazy_eval(int k){
		if(lazy[k]==0)return;
		dp[k]=lazy[k];
		if(k<N-1){
			lazy[k*2+1]=lazy[k]/2;
			lazy[k*2+2]=lazy[k]/2;
		}
		lazy[k]=0;
	}
	void lazy_upd(int k){
		dp[k]=dp[k*2+1]+dp[k*2+2];
	}
	void update(int a,int b,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(b<=l || r<=a)return;
		if(a<=l && r<=b){
			lazy[k]=r-l;
			lazy_eval(k);
			return;
		}
		int mid=(l+r)/2;
		update(a,b,k*2+1,l,mid);
		update(a,b,k*2+2,mid,r);
		lazy_upd(k);
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(b<=l || r<=a)return 0;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		lazy_upd(k);
		return vl+vr;	
	}
};

int n,m,q;
int d,e;
segtree seg;
vector<query> vec;
bool ans[100001];

int main(void){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<m;i++){
		int d,a,b;
		scanf("%d%d%d",&d,&a,&b);
		a--;
		d*=2;
		d++;
		vec.push_back(query(d,a,b,0,-1));
	}
	for(int i=0;i<q;i++){
		int e,s,t;
		scanf("%d%d%d",&e,&s,&t);
		s--;
		e*=2;
		vec.push_back(query(e,s,t,1,i));
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		if(vec[i].type==0){
			seg.update(vec[i].l*2+1,vec[i].r*2-1);
		}else{
			if(vec[i].l+1>=vec[i].r){
				ans[vec[i].id]=true;
				continue;
			}
			int val=seg.query(vec[i].l*2+1,vec[i].r*2-1);
			//printf("%d %d\n",vec[i].id,val);
			if(val==(vec[i].r-vec[i].l)*2-2)ans[vec[i].id]=true;
		}
	}
	for(int i=0;i<q;i++){
		printf("%s\n",ans[i]?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 10196
import math
t = int(input())
if t<2:
    print(2)
    exit()
for i in range(t,t+250):
    v = int(math.sqrt(i))
    f=0
    for j in range(2,v+1):
        if i%j==0:
            f=1
            break
    if(f==0):
        print(i)
        break

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

void print_array(int* A, int n){
   for(int i = 0; i < n; i++){
      cout << A[i];
      if(i != n - 1){
         cout << " ";
      }
   }
   cout << endl;
}

void InsertionSort(int* A, int n){
   for(int i = 1; i < n; i++){
      int v = A[i];
      
      int j = i - 1;

      while(j >= 0 && A[j] > v){
         A[j + 1] = A[j];
         j--;
      }

      A[j + 1] = v;

      print_array(A, n);

   }
}

int main(){

   int n;
   int A[100];

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

   print_array(A, n);

   InsertionSort(A, n);

   return 0;
}


Measured memory_bytes: 3108
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrepa(i,a,n) for (int i = n; i >= a; i--)
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
	int n;
  	cin>>n;
  	int temp=n%1000;
      if(temp!=0)
  	    temp=1000-temp;
  	cout<<temp<<endl;
  	
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int fpow(int a, int b){
  if(b == 0) return 1;
  int x = fpow(a, b / 2);
  if(b % 2 == 1) return mul(a, mul(x, x));
  else return mul(x, x);
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int x, y;
  cin >> x >> y;
  vi fac(1e6 + 1);
  fac[0] = 1;
  for(int i = 1; i <= 1e6; i++){
    fac[i] = mul(i, fac[i - 1]);
  }
  int n = max(x, y);
  int res = 0;
  for(int i = 0; i <= n; i++){
    int tx = i, ty = 2 * i;
    int need = (x - tx) / 2;
    if(need < 0) continue;
    tx += 2 * need;
    ty += need;
    if(tx == x && ty == y){
      int inva = fpow(fac[i], mod - 2);
      int invb = fpow(fac[need], mod - 2);
      int ab = fac[i + need];
      res = add(res, mul(ab, mul(inva, invb)));
    }
  }
  cout << res;
}


Measured memory_bytes: 4224
while 1:
  try:
    n = int(input())
    count = 0
    for a in range(10):
      for b in range(10):
        for c in range(10):
          for d in range(10): 
            if a + b + c + d == n:
              count += 1
    print(count)
  except EOFError:
    break


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

int main(){
  vector<char>data(4);
  for(char i=0;i<4;i++)
    cin>>data.at(i);
  int a=data.at(0)-'0';
  int b=data.at(1)-'0';
  int c=data.at(2)-'0';
  int d=data.at(3)-'0';
  if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl; 
  else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl; 
  else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  long long int x;
  cin>>x;
  long long int ans=x/11*2;
  if(x%11==0){
    
  }
  else if(x%11<=6){
    ans++;
  }else{
    ans+=2;
  }
  cout<< ans <<endl;
}


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

int main(){
    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    cout << "A" << S[1].at(0) << "C" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,k,m,n;
string s;
int main(){
    getline(cin,s);
    int len=s.size();
    if(s[0]==s[len-1]){
        if(len%2==1)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
    else {
        if(len%2==1)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
N = int(raw_input().rstrip())
a = map(int, raw_input().rstrip().split())
c = [0,0,0]
for i in range(N):
    if a[i] % 4 == 0:
        c[2] += 1
    elif a[i] % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1
if c[1] > 0:
    print 'Yes' if c[2] >= c[0] else 'No'
else:
    print 'Yes' if c[2] >= c[0] - 1 else 'No'

Measured memory_bytes: 11320
N = int(input())
A = list(map(int, input().split()))

pattern = 1
hats = [0, 0, 0]
for a in A:
    if pattern >= 1000000007:
        pattern = pattern % 1000000007
    if pattern == 0:
        break
    i = 0
    for j in range(3):
        if a == hats[j]:
            i += 1
    pattern *= i
    for j in range(3):
        if a == hats[j]:
            hats[j] += 1
            break

print(pattern % 1000000007)

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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


void regi(ll key, ll value, map<ll, ll>& m){
    if(m.find(key) == m.end()){
        m[key] = value;
    }
    else{
        m[key] = min(m[key], value);
    }
}


int main(){
    int T;  cin >> T;
    while(T--){
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;

        priority_queue<ll> q;
        map<ll, ll> mp;
        map<ll, bool> hist;
        mp[n] = 0;
        q.push(n);
        while(!q.empty()){
            ll x = q.top(); q.pop();
            if(hist.find(x) != hist.end()){
                continue;
            }
            hist[x] = true;
            if(x == 1){
                int p = 10;
            }
            if(x < INT32_MAX){
                if(mp.find(0) == mp.end()){
                    mp[0] = mp[x] + x * d;
                }
                else {
                    mp[0] = min(mp[0], mp[x] + x * d);
                }
                if(x * d < a && x * d < b && x * d < c) continue;
            }
            for(ll i = -4; i <= 4; i++){
                ll value = x + i;
                if(value < 0)   continue;

                ll cost = (i > 0) ? i * d : -i * d;
                if(value % 2 == 0){
                    regi(value / 2, a + cost + mp[x], mp);
                    q.push(value / 2);
                }
                if(value % 3 == 0){
                    regi(value / 3, b + cost + mp[x], mp);
                    q.push(value / 3);
                }
                if(value % 5 == 0){
                    regi(value / 5, c + cost + mp[x], mp);
                    q.push(value / 5);
                }
            }
        }

        cout << mp[0] << endl;
    }


    return 0;
}


Measured memory_bytes: 9496
def b():
    # N 個の都市があり、M 本の道路があります。
    # i(1≦i≦M) 番目の道路は、都市 ai と 都市 bi (1≦ai,bi≦N) を双方向に結んでいます。
    # 同じ 2 つの都市を結ぶ道路は、1 本とは限りません。
    # 各都市から他の都市に向けて、何本の道路が伸びているか求めてください。
    #
    # 制約
    # 2≦N,M≦50
    # 1≦ai,bi≦N
    # ai≠bi
    # 入力は全て整数である。
    n, m = map(int, input().split())
    city = [0]*n
    for i in range(m):
        ai, bi = map(int, input().split())
        city[ai-1] += 1
        city[bi-1] += 1
    for c in city: print(c)
    pass

b()

Measured memory_bytes: 2940
n=int(input())
#n,p=map(int,input().split())
pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mn=pl[0]

mnl=[]
count=1
for i in range(n):
    mn=min(mn,pl[i])
    mnl.append(mn)

for i in range(1,n):
    if pl[i]<=mnl[i-1]:
        count+=1
print(count)

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a) 

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

// -----



int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    bool fl = false;
    for(int i = 1; i * k <= b; ++i)
    {
        if(i * k >= a && i * k <= b)
        {
            fl = true;
            break;
        }
    }
    pl(fl ? "OK" : "NG");
}


Measured memory_bytes: 3624
M, D = map(int, raw_input().strip().split())
ans = 0
for d in xrange(1, D+1):
  d1 = d % 10
  d10 = d / 10
  if d1 >= 2 and d10 >= 2 and d1 * d10 <= M:
    ans += 1
print ans


Measured memory_bytes: 2568
N,W=map(int,input().split())
dp=[[0 for i in range(W+1)]for j in range(N+1)]
goods=[]
for i in range(N):
    v,w=map(int,input().split())
    goods.append([v,w])

    
for i in range(N):
    v=goods[i][0]
    w=goods[i][1]
    for j in range(W+1):
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
        next_w=j+w
        next_v=dp[i][j]+v
        if(next_w<=W and next_v>dp[i+1][next_w]):
            dp[i+1][next_w]=next_v

ans=0
for i in range(W+1):
    ans=max(ans,dp[N][i])
print(ans)


Measured memory_bytes: 25976
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    REP(i,N)cin >> H[i];
    int count = 0;
    REP(i,N)if(H[i] >= K)count++;
    cout <<count<< "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = int;
  using U = int;
  static void ap(T& a, const U& g) { a += g; }
  // static void ap(U& f, const U& g) { f += g; }
  static constexpr U id() { return 0; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  int n;
  V<T> t;
  V<U> u;

  ST(int n) : n(n) {
    t.assign(n, 0);
    u.assign(n, M::id());
  }

  void _ap(int i, const U& f) {
    if (i < n) M::ap(u[i], f);
    else M::ap(t[i - n], f);
  }

  T get(int i) {
    T res = t[i];
    for (i += n; i >>= 1;) M::ap(res, u[i]);
    return res;
  }

  void set(int l, int r, const U& f) {
    stack<int> s;
    for (int i = l + n; i >>= 1;) s.push(i);
    for (int i = r + n - 1; i >>= 1;) s.push(i);
    while (!s.empty()) {
      int i = s.top(); s.pop();
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) _ap(l++, f);
      if (r & 1) _ap(--r, f);
    }
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  struct seg { int l, r; };
  V<seg> a(n); for (int i = 0; i < n; i++) cin >> a[i].l >> a[i].r;
  sort(a.begin(), a.end(), [](seg a, seg b) { return a.r - a.l < b.r - b.l; });
  ST<M> res(m + 1), st(m + 1);
  int i = 0;
  for (int d = 1; d < m + 1; d++) {
    while (i < n and a[i].r - a[i].l + 1 <= d) {
      st.set(a[i].l, a[i].r + 1, 1);
      res.set(1, d, 1);
      i++;
    }
    for (int x = 0; x < m + 1; x += d) res.set(d, d + 1, st.get(x));
  }
  for (int d = 1; d < m + 1; d++) cout << res.get(d) << '\n';
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define Task "C"

using namespace std;
const int maxN = 1e5 + 5;
int n, k, q, a[maxN];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> q;
    int val;
    for(int i = 1; i<=q; ++i){
        cin >> val;
        a[val]++;
    }
    for(int i = 1; i<=n; ++i){
        a[i] = a[i] + k - q;
        if (a[i] > 0) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    rep(i ,N) cin >> A[i];
    sort(A, A+N);
    int ans = 0;
    rep(i, N) {
        int count = 1;
        while (A[i] == A[i+1]) {
            count++;
            i++;
        }
        if (count % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int ans = 1;
    int sum = 0;
    for(int i = 0; i < N-1; i++) {
        if((A[i]+sum)*2 >= A[i+1]) {
            ans++;
        }
        else {
            ans = 1;
        }
        sum+=A[i];
    }
    cout << ans << endl;
}


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

string S;

int main(int argc, char **argv) {
  cin >> S;

  vector<int> cnt(S.size() + 1, 0);
  char prev, cur;

  cnt[0] = 0;
  cnt[1] = 1;
  if (S[0] != S[1])
    cnt[2] = 2;
  else
    cnt[2] = 1;
  for (int i = 2; i < S.size(); i++) {
    int j = i + 1;
    if (S[i] != S[i - 1]) {
      cnt[j] = cnt[j - 1] + 1;
    } else {
      cnt[j] = cnt[j - 3] + 2;
    }
  }

  cout << cnt[S.size()] << endl;

  return 0;
}


Measured memory_bytes: 1412
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1;
    while(ans*2 <= n){
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import re


def main():
    s = input().replace("?", ".")
    t = input()
    ls = len(s)
    lt = len(t)
    for i in range(ls - lt, -1, -1):
        f = re.match(s[i: i + lt], t)
        if f != None:
            if i == ls - lt:
                x = s[:i]+t
            else:
                x = s[:i] + t + s[i + lt:]
            print(x.replace(".", "a"))
            return
    print("UNRESTORABLE")
    return


main()


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

int main(){
  int a[12]={0},v1,v2;
  char s;
  double l;
  while(cin >>a[1]>>s>>a[2]>>s>>a[3]>>s>>a[4]>>s>>a[5]>>s>>a[6]>>s>>a[7]>>s>>a[8]>>s>>a[9]>>s>>a[10]>>s>>v1>>s>>v2){
    for(int i=1;i<=10;i++)a[i]+=a[i-1];
    l=(double) a[10]*(double) v1/( (double) v1+(double) v2);
    for(int i=1;i<=10;i++){
      if(a[i]>=l){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3000
#include<string>
#include<iostream>
using namespace std;
int main(){
string a,h="";
cin>>a;
h+=(char)(int)(a[0]+'A'-'a');
cin>>a;
h+=(char)(int)(a[0]+'A'-'a');
cin>>a;
h+=(char)(int)(a[0]+'A'-'a');
cout<<h<<endl;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
s,t=input().split()
#for i in range(n):
    
ans=t+s
print(ans)




Measured memory_bytes: 39404
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int n,m,p,i,x,sum,win;
  for(;scanf("%d%d%d",&n,&m,&p);)
    {
      if(n==0&&m==0&&p==0)
	exit(0);
      sum=0;
      win=0;
      for(i=1;i<=n;i++)
	{
	  scanf("%d",&x);
	  sum+=(x*100);
	  if(i==m)
	    win=x;
	}
      if(win==0)
	puts("0");
      else
	printf("%d\n",(int)(sum*((100-p)/100.0))/win);
    }
  exit(0);
}

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

int main(){
    int n;
    cin >> n;
    int ans=0;
    if(n >= 105){
        ans ++;
    }
    
    if(n >= 135){
        ans ++;
    }
    if(n>=165){
        ans ++;
    }
    
    if(n >= 189){
        ans ++;
    }

    if(n>=195){
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

if sum(A) < sum(B) :
  print(-1) 
else :
  l = []
  ret = 0
  rest = 0
  for a, b in zip(A, B) :
    if a <= b :
      if a != b :
        ret += 1
      rest += b - a
    else :
      l.append(a - b)

  l.sort()
  while rest > 0 :
    ret += 1
    rest -= l.pop()

  print(ret)

Measured memory_bytes: 81840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll t[n+1];
	pii a[n+1];For(i,1,n+1) cin>>t[i]>>a[i].fi>>a[i].se;
	a[0] = {0,0};
	t[0] = 0;

	For(i,1,n+1){
		ll c = abs(a[i].fi-a[i-1].fi)+abs(a[i].se-a[i-1].se);
		ll T = t[i]-t[i-1];
		if(c>T || (T-c)%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;










	
}

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

const int MX = 6500, N = 82;
bitset<2*MX> pos[N][N];
int a[N][N], b[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>a[i][j];


    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>b[i][j];


    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            int d = abs(a[i][j] - b[i][j]);
            if (i == 1 && j == 1)   pos[i][j][MX+d] = 1;
            if (i > 1)  pos[i][j] |= (pos[i-1][j] << d) | (pos[i-1][j] >> d);
            if (j > 1)  pos[i][j] |= (pos[i][j-1] << d) | (pos[i][j-1] >> d);

//            cout<<i<<" "<<j<<" "<<d<<" ---> ";
//            for (int x=0; x<2*MX; x++)
//                if (pos[i][j][x])   cout<<x-MX<<" "; cout<<endl;
        }
    }

    for (int i=0; i<MX; i++) {
        if (pos[n][m][MX + i] || pos[n][m][MX - i]) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 10752
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47420
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := 1
	for ans*2 <= n {
		ans *= 2
	}
	fmt.Println(ans)
}


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

#define ll long long
#define lp(i,n) for(int i=0; i<n; i++)
#define pb push_back
const long double pi=3.141592654;
#define OSOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;



set<ll>st;
ll arr[1000001] ={},mod = 1e9+7;

ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % mod;
	if (exp % 2 != 0)
		ans = (ans * (base% mod)) % mod;
	return ans;
}



void primeFact(int n)
{
	for(int i=2;i*i<=n;i++) // i*i<=n equals i<=sqrt(n)
	{
		int cnt = 0;
		while(n%i==0)
		{
			st.insert(i);
			cnt++;;
			n/=i;
		}
		if(cnt > arr[i])
			arr[i] = cnt;
	}
	if(n>1)
	{
		st.insert(n);
		if(1 > arr[n])
			arr[n]++;
	}
}

int main()
{
	OSOS
	ll n,lcm = 1;
	cin>>n;

	ll nums[n];
	memset(arr,0,sizeof(arr));
	lp(i,n)
	{
		cin>>nums[i];
		primeFact(nums[i]);
	}
	for(auto it : st)
	{
		lcm = (lcm % mod * ( fp( it , arr[it] ) % mod) ) % mod;
	}
	ll ans = 0;
	//cout<<lcm<<"\n";
	for(int i=0; i<n; i++)
	{
		//cout<<fp(nums[i] , mod-2)<<" ";
		ans = (ans % mod + (lcm * fp(nums[i] , mod-2)) % mod) % mod;
	}
	cout<<ans;
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		String strInput1 = scanner.nextLine();
		String strInput2 = scanner.nextLine();

		String strLoop = strInput1 + strInput1;

		if (strLoop.contains(strInput2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    string S;
    string weather[3] = { "Sunny", "Cloudy", "Rainy" };
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if(S == weather[i]) {
            if(i == 2) {
                cout << weather[0] << endl;
            }else {
                cout << weather[i+1] << endl;
            }
        }
    }
        return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int,input().split())
price_li = [-int(i) for i in input().split()]
heapq.heapify(price_li)
for _ in range(m):
    j = -heapq.heappop(price_li)
    j //= 2
    heapq.heappush(price_li,-j)
print(-sum(price_li))

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  int64_t a = k;
  for (int i = 1; i < n; i++) {
    a *= k - 1;
  }
  std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    ans += min(K - x[i],x[i]) * 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
s=input()
A,B =map(int,input().split())
t = 0
k=0
L=len(s)
table=[[] for i in range(2)]
for i in range(len(s)):
    if s[i]=='F':
        k+=1
    else:
        table[t].append(k)
        t=(t+1)%2
        k=0
table[t].append(k)
Lx=set()
Lx.add(table[0][0])
for i in range(1,len(table[0])):
    x=table[0][i]
    T=set()
    for a in Lx:
        if -L<=a+x<=L:
            T.add(a+x)
        if -L<=a-x<=L:
            T.add(a-x) 
    Lx=T
flag=True
for a in Lx:
    if a==A:
        flag =False
if flag:
    print('No')
    sys.exit()

Lx=set()
Lx.add(0)
for i in range(len(table[1])):
    x=table[1][i]
    T=set()
    for a in Lx:
        if -L<=a+x<=L:
            T.add(a+x)
        if -L<=a-x<=L:
            T.add(a-x) 
    Lx=T
flag=True
for a in Lx:
    if a==B:
        flag =False
if flag:
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 48732
# -*- coding: utf-8 -*-
n = int(input())
dic = {}

for i in range(n):
    shop, ten = input().split()
    ten = int(ten)
    if shop in dic:
        dic[shop].append({i+1:ten})
    else:
        dic.update({shop: [{i+1:ten}]})


for k, v in sorted(dic.items()):
    d = {}
    for a in v:
        d.update(a)

    for a, b in sorted(d.items(), key=lambda x: -x[1]):
        print(a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int in;
    cin >> in;
    cout << in * in * in << endl;
    return 0;
}


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

int main(){
  int a,b,c,s=0;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=a;i<b+1;i++){
    if(i%c==0){
      s++;
    }
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 3680
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans;
    cin >> n;
    vector<int> d(n);
    rep(i, n) {
      cin >> d[i];
    }
    sort(d.begin(), d.end());
    ans = d[n / 2] - d[n / 2 - 1];

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
N,K = map(int,input().split())
S = input()
row = []
count = 1
flag = S[0]
for i in range(1,N):
    if S[i] != flag:
        row.append([count,flag])
        count = 1
        flag = S[i]
    else:
        count += 1
row.append([count,flag])
inst = 0
ans,temp = 0,0
left,right = 0,0
for i in range(len(row)):
    if row[i][1] == "1":
        temp += row[i][0]
    else:
        inst += 1
        if inst <= K:
            temp += row[i][0]
        else:
            temp -= row[left][0]
            if row[left][1] == "1":
                temp -=row[left+1][0]
                left += 1
            temp += row[i][0]
            left += 1
    ans = max(ans,temp)
print(ans)

Measured memory_bytes: 13300
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;


int main() {
	int a, b, h; cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}


Measured memory_bytes: 256
s = input()
# 最後まで見れるかどうかを判定する必要がある
ok = 1
idx = 0
le = len(s)
while idx < le:
    #print(idx)
    if s[idx] == "e":
        if le >= idx+5 and s[idx:idx+5] == "erase":
            if le >= idx+6 and s[idx+5] == "r":
                #eraser 確定
                idx = idx+6
            else: 
                idx = idx+5
        else:
            ok = 0
            break
    elif s[idx] == "d":
        if le >= idx+5 and s[idx:idx+5] == "dream":
            if le >= idx+7 and s[idx:idx+7] == "dreamer":
                if le >= idx + 8 and s[idx+7] == "a":
                    idx = idx + 5
                else:
                    idx = idx + 7
            else: 
                idx = idx + 5
        else: 
            ok = 0
            break
    else: 
        ok = 0
        break
if ok == 0:
    print("NO")
else: 
    print("YES")

Measured memory_bytes: 40176
N = int(input())
ans = []
if N < 105:
    print(0)
    exit()
cnt = 0
for i in range(2, N+1):
    ans = []
    for j in range(1, i+1):
        if i % j == 0:
            ans.append(i)
        if len(ans) == 8 and i % 2 != 0:
            cnt += 1
            break
print(cnt)

Measured memory_bytes: 39408
#include <stdio.h>
#define N 10000

int linearSearch(int x);

int s[N], t[N], n, q;

int main()
{
  int c=0, i, j;

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++)
    scanf("%d", &t[i]);

  
  for(i=0; i<q; i++){
    c += linearSearch(i);
  }
  printf("%d\n",c);

  return 0;
}

int linearSearch(int x)
{
  int i = 0;
  s[n] = t[x];
  while(s[i]!=t[x]){
    i++;
    if(i==n) return 0;
  }
  return 1;
}

Measured memory_bytes: 644
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn remain(x: u64, y: u64) -> u64 {
    x - (x / y)
}

fn solve(a: u64, b: u64, c: u64, d: u64) -> u64 {
    remain(b, c) + remain(b, d)
        - remain(b, lcm(c, d))
        - (remain(a - 1, c) + remain(a - 1, d) - remain(a - 1, lcm(c, d)))
}

fn main() {
    let (a, b, c, d) = parse_line!(u64, u64, u64, u64);
    println!("{}", solve(a, b, c, d));
}

#[test]
fn remain_test() {
    assert_eq!(remain(10, 5), 8);
    assert_eq!(remain(11, 5), 9);
    assert_eq!(remain(10, 2), 5);
}

#[test]
fn solve_test() {
    assert_eq!(solve(4, 9, 2, 3), 2);
    assert_eq!(solve(1, 10, 2, 3), 3);
    assert_eq!(solve(10, 40, 6, 8), 23);
    assert_eq!(
        solve(314159265358979323, 846264338327950288, 419716939, 937510582),
        532105071133627368
    );
}


Measured memory_bytes: 4352
import java.util.Scanner;

class UnionFindTree {
	int[] par;
	int[] rank;
	int[] peers; //仲間の数

	public UnionFindTree(int n){
		par = new int[n];
		rank = new int[n];
		peers = new int[n];
		for(int i=0;i<n;i++){
			par[i] = i;
			peers[i] = 1;
		}
	}

	//木の根を求める
	int find(int x){
		if(par[x] == x){
			return x;
		}
		else{
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y){
		int px = find(x);
		int py = find(y);

		if(px == py){
			return;
		}
		else if(rank[px] < rank[py]){
			peers[py] += peers[px];
			par[px] = py;

		}
		else{
			peers[px] += peers[py];
			par[py] = px;
			if(rank[px]==rank[py]){
				rank[px]++;
			}
		}

	}


	//xとyが同じ集合に属するか
	boolean isEquivalent(int x, int y){
		return find(x) == find(y);
	}

	//xの仲間の数を求める
	int peersnum(int x){
		return peers[find(x)];
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		UnionFindTree uf = new UnionFindTree(N);
		int[][] S = new int[M][2];
		for(int i = 0 ; i < M ; i++){
			S[i][0] = sc.nextInt()-1;
			S[i][1] = sc.nextInt() -1;
		}
		sc.close();

		long[] ans = new long[M];
		ans[M-1] = (long)N*(N-1)/2;

		for(int i = M-2 ; i >=0  ; i--){
			if(!uf.isEquivalent(S[i+1][0], S[i+1][1])){
				ans[i] = Math.max(ans[i+1] - (uf.peersnum(S[i+1][0]) * uf.peersnum(S[i+1][1])),0);
				uf.unite(S[i+1][0],S[i+1][1]);
			}
			else{
				ans[i] = ans[i+1];
			}
		}

		for(int i = 0 ; i < M ; i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 100892
#include <iostream>

using namespace std;
const double perTwoRootThree = 0.28867513459481287;

struct pos {
    double x;
    double y;

    void print() {
        printf("%f %f\n", x, y);
    }
};

pos getS(pos &p1, pos &p2) {
    return pos{(p1.x * 2 + p2.x) / 3, (p1.y * 2 + p2.y) / 3};
}

pos getU(pos &p1, pos &p2) {
    return pos{(p1.x + p2.x) / 2 + (p1.y - p2.y) * perTwoRootThree,
               (p1.y + p2.y) / 2 - (p1.x - p2.x) * perTwoRootThree};
}

pos getT(pos &p1, pos &p2) {
    return getS(p2, p1);
}

void kock(pos p1, pos p2, int depth) {
    if (depth-- == 0) p2.print();
    else {
        pos
                s = pos{(p1.x * 2 + p2.x) / 3, (p1.y * 2 + p2.y) / 3},
                u = pos{(p1.x + p2.x) / 2 + (p1.y - p2.y) * perTwoRootThree,
                        (p1.y + p2.y) / 2 - (p1.x - p2.x) * perTwoRootThree},
                t = pos{(p1.x + p2.x * 2) / 3, (p1.y + p2.y * 2) / 3};
        kock(p1, s, depth);
        kock(s, u, depth);
        kock(u, t, depth);
        kock(t, p2, depth);
    }
}

int main() {
    int n;
    pos p1 = pos{0, 0}, p2 = pos{100, 0};
    cin >> n;
    p1.print();
    kock(p1, p2, n);
    return 0;
}



Measured memory_bytes: 3208
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int x[110];

int main() {
	int n;
	while(cin>>n){
		int i;
		for(i=0;i<n;i++){
			cin>>x[i];
		}
		sort(x,x+n);
		int res=0;
		for(i=0;i<n;i++){
			res+=x[i]*(n-i);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0