akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int[] b, x, y;
	int m;
	int[] s, g;
	HashMap<Integer, Integer> map;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			b=new int[n];
			x=new int[n];
			y=new int[n];
			for(int i=0; i<n; i++){
				b[i]=sc.nextInt();
				x[i]=sc.nextInt();
				y[i]=sc.nextInt();
			}
			m=sc.nextInt();
			s=new int[m];
			g=new int[m];
			for(int i=0; i<m; i++){
				s[i]=sc.nextInt();
				g[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		map=new HashMap<Integer, Integer>();
		for(int i=0; i<n; i++){
			map.put(b[i], i);
		}

		@SuppressWarnings("unchecked")
		LinkedList<E>[] es=new LinkedList[n];
		for(int j=0; j<n; j++){
			es[j]=new LinkedList<E>();
			for(int i=0; i<n; i++){
				if(i==j){
					continue;
				}
				double cost=Math.hypot(x[i]-x[j], y[i]-y[j]);
				if(cost<50+EPS){
					es[j].add(new E(i, cost));
				}
			}
		}
		for(int i=0; i<m; i++){
			LinkedList<Integer> path=dijkstra(es, map.get(s[i]), map.get(g[i]));
			if(path==null){
				println("NA");
			}else{
				for(int k=0; k<path.size(); k++){
					print(b[path.get(k)]+(k==path.size()-1?"\n":" "));
				}
			}
		}
	}

	LinkedList<Integer> dijkstra(LinkedList<E>[] es, int s, int g){
		int n=es.length;
		double[] d=new double[n];
		int[] pre=new int[n];
		PriorityQueue<P> que=new PriorityQueue<P>();

		Arrays.fill(d, INF);
		Arrays.fill(pre, -1);
		d[s]=0;
		pre[s]=s;
		que.offer(new P(s, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			if(d[p.v]<p.d)
				continue;
			for(E e : es[p.v]){
				if(d[e.to]>d[p.v]+e.cost){
					pre[e.to]=p.v;
					d[e.to]=d[p.v]+e.cost;
					que.offer(new P(e.to, d[e.to]));
				}
			}
		}
		LinkedList<Integer> path=new LinkedList<Integer>();
		for(int i=g;; i=pre[i]){
			path.addFirst(i);
			if(i==-1){
				return null;
			}
			if(i==s){
				return path;
			}
		}
	}

	class E{
		int to;
		double cost;

		E(int to, double cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v;
		double d;

		P(int v, double d){
			this.v=v;
			this.d=d;
		}

		@Override
		public int compareTo(P p){
			if(d+EPS<p.d){
				return -1;
			}else if(d>p.d+EPS){
				return 1;
			}else{
				return 0;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int getID(vector<int>& v,int idx){
  if(v[idx]==idx)return idx;
  v[idx]=getID(v,v[idx]);
  return v[idx];
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> d(N,0);
  vector<int> v(N,-1);
  for(int i=0;i<M;i++){
    int s[2];
    cin>>s[0]>>s[1];
    s[0]--;
    s[1]--;
    
    if(v[s[0]]==-1 && v[s[1]]==-1){
      v[s[0]]=s[0];
      v[s[1]]=s[0];
      d[s[0]]=2;
    }
    else if(v[s[0]]==-1 || v[s[1]]==-1){
      for(int j=0;j<2;j++){
        if(v[s[j]]==-1){
          int id=getID(v,s[(j+1)%2]);
          v[s[j]]=id;
          d[id]++;
        }
      }
    }
    else{
      int r1=getID(v,s[0]);
      int r2=getID(v,s[1]);
      if(r1==r2)continue;
      v[r1]=r2;
      d[r2]+=d[r1];
      d[r1]=0;
    }
    
  }
  int ans=1;
  for(int i=0;i<N;i++){
    ans=max(ans,d[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4696
def E_dijkstra(V,AL,S):
    from heapq import heappush,heappop
    INF=float('inf')
    ans=[INF]*V
    ans[S]=0
    used=[0]*V # 0:未確定
    used[S]=1
    que=[]
    for i in range(V):
        heappush(que,(ans[i],i))
    while que:
        x,u=heappop(que)
        used[u]=1
        for v,w in AL[u]:
            if not used[v] and ans[v]>x+w:
                ans[v]=x+w
                heappush(que,(ans[v],v))
    return ans

# verified: https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_A
# import sys
# input = sys.stdin.readline
# V,E,R=map(int,input().split())
# AL=[[] for i in range(V)]
# for _ in range(E):
#     S,T,D=map(int,input().split())
#     AL[S].append((T,D))
# for ans in E_dijkstra(V,AL,R):
#     print('INF' if ans==float('inf') else ans)

import sys
input = sys.stdin.readline

N=int(input())
AL=[[] for _ in range(N)]
for _ in range(N):
    for i,x in enumerate(input().split()):
        x=int(x)
        if i==0:
            j=x
        elif i==1:
            pass
        else:
            if i%2==0:
                tmp=[x]
            else:
                tmp.append(x)
                AL[j].append(tmp)
for ans in enumerate(E_dijkstra(N,AL,0)):
    print(*ans)


Measured memory_bytes: 88412
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>

using namespace std;

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

	int n;
	cin >> n;

	vector<int> seq;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		seq.push_back(x);
	}

	vector<int> ans;

	ans.push_back(0);
	for (int i = 0; i < n; i++)
	{
		auto it = ans.begin();
		if (seq[i] > ans.size())
		{
			cout << -1 << "\n";
			return 0;
		}
		ans.insert(it + seq[i], seq[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		cout << ans[i] << "\n";
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n;
	std::map<std::string,bool> mp;
	cin >> n;
	fori(n){
		string hoge;
		cin>>hoge;
		mp[hoge]=true;
	}
	cout<<mp.size();
	return 0;
}

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


#define ll long long
#define MOD 1000000007



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

    vector<pair<ll,ll>> sch(n);

    ll x,l;
    for(int i=0;i<n;i++){
        cin>>x>>l;
        sch.at(i).second=x-l;
        sch.at(i).first=x+l;
    }

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


    ll cd=sch.at(0).first,co=1;
    for(int i=0;i<n;i++){
        if(sch.at(i).second<cd)continue;
        cd = sch.at(i).first;
        co++;
    }

    cout<<co<<endl;


}

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

struct dsu {
  int cc;
  vector<int> p, sz;
  dsu(int n = 0) : cc(n), p(n, -1), sz(n, 1) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto&& e : s) {
    cin >> e;
  }
  dsu d(h * w);
  auto $ = [&](int i, int j) {
    return i * w + j;
  };
  vector<string> t{"6314", "2.2.", "1364", "5.5."};
  auto chk = [&](int i, int j) {
    return s[i][j] == t[i % 4][j % 4];
  };
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i + 1 < h and chk(i, j) and chk(i + 1, j)) {
        d.unite($(i, j), $(i + 1, j));
      }
      if (j + 1 < w and chk(i, j) and chk(i, j + 1)) {
        d.unite($(i, j), $(i, j + 1));
      }
    }
  }
  if (d.same($(0, 0), $(h - 1, w - 1))) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll N;
    cin >> N;
    vll a(N);
    rep(i, N){
        cin >> a[i];
    }
    vll x(N);
    ll sx = 0;
    rep(i, N){
        sx += a[i];
    }
    ll st = 0;
    for(ll i=0; i<N-1; i+=2){
        st += a[i];
    }
    x[N-1] = sx - st*2;
    irep(i, N-1){
        x[i] = 2*a[i] - x[i+1];
    }
    rep(i, N-1){
        cout << x[i] << " ";
    }
    cout << x[N-1] << endl;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int dp[3001][3001] = {};

int main() {
  string s, t; cin >> s >> t;
  int Ls = s.size(), Lt = t.size();
  for (int i = 1; i <= Ls; ++i) {
    for (int j = 1; j <= Lt; ++j) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  int i = Ls, j = Lt;
  string ans;
  while (dp[i][j] > 0) {
    if (s[i-1] == t[j-1]) {
      ans = s[i-1] + ans;
      --i, --j;
    } else if (dp[i-1][j] > dp[i][j-1]) {
      --i;
    } else {
      --j;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e6+5;
typedef pair<int, bool> pib;

int main() {
    int a,b; cin >> a >> b;
    int c,v,e; c = a-b; v = a + b; e = a*b;
    cout << max(c, max(v,e));
}



Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def main():
    n, l = getList()
    lis = []
    for i in range(n):
        lis.append(getS())

    lis.sort()
    print("".join(lis))

if __name__ == "__main__":
    main()
   

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

int main(){
	double P,N,K;
	cin >> N >> K;
	double score = 0;
	double c = 0;
	for(int i=1;i<N+1;i++){
		score = i;
		double d = 1;
		while(score<K){
			score *= 2;
			c++;
			d*=2;
		}
		P += (1.0/(N*d));
		c = 0;
	}
	cout << setprecision(60) << P;
	cin >> N;
}

Measured memory_bytes: 256
a,b,m = list(map(int,input().split()))
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

minnum = min(a_list) + min(b_list)

for i in range(m):
    x,y,c = list(map(int,input().split()))
    if minnum > a_list[x-1] + b_list[y-1] - c:
        minnum = a_list[x-1] + b_list[y-1] - c

print(minnum)

Measured memory_bytes: 18736
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=1000000;
bool prime[N];
void sieve()
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x*x;
    }
    return res;
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int findTileCount(int x, int y, int l, int r)
{
    int lcm = (x * y) / __gcd(x, y);
    int countl = (l - 1) / lcm;
    int countr = r / lcm;
    return countr - countl;
}
int32_t main()
{
    base
    int n=nxt(),k=nxt();
    vector<string>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(all(v));
    for(int i=0;i<n;i++)cout<<v[i];
    exit
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	int disAC,disAB,disBC;

	if(abs(a-c)<=d){
		printf("Yes\n");
		return 0;
	}
	if(abs(a-b)<=d && abs(b-c)<=d){
		printf("Yes\n");
		return 0;
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int left = -1;
  int right = 0;
  int ans = 0;
  while(left!=S.length()){
    if(S[right]=='A' || S[right]=='C' || S[right]=='G' || S[right]=='T'){
    }else {
      left = right;
    }
    ans = max(ans,right-left);
    right++;
  }
  cout << ans;
}


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

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    int l1 = s1.length(), l2 = s2.length();
    int j, ans = l2, cnt = 0;
    for(int i=0; i<l1-l2+1; i++)
    {
        j = 0;
        cnt = 0;
        while(j < l2)
        {
            if(s1[i+j] != s2[j]){
                cnt++;
            }
            
            j++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}

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

using namespace std;

int main(void){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B == C + D){
    puts("Balanced");
  }else if(A + B > C + D){
    puts("Left");
  }else{
    puts("Right");
  }
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
n = int(input())
s = list(str(input()))

def remove_adjacent(nums):
  i = 1
  while i < len(nums):    
    if nums[i] == nums[i-1]:
      nums.pop(i)
      i -= 1  
    i += 1
  return nums

remove_adjacent(s)
print(len(s))


Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define N 1000005
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;
set< string > s;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    while(n--){
        string a; cin>>a;
        s.insert(a);
    }
    int o = s.size();
    cout<<o;
    
    return 0;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}
template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

int main() {
    PRE_COMMAND
    int n, m, x;
    cin >> n >> m >> x;
    vi a(m);
    cin >> a;
    int c1 = 0, c2 = 0;
    for (int i = 0; i < m; i++) {
        if (a[i] < x) c1++;
        if (a[i] > x) c2++;
    }
    cout << min(c1, c2) << endl;
}

Measured memory_bytes: 3568
/*
 * Rock, Paper, Scissors
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			if (line.equals("0")) {
				break;
			}

			int[] p = new int[5];
			int rock, scissors, paper;
			rock = scissors = paper = 0;

			p[0] = Integer.parseInt(line);
			for (int i = 1; i < 5; i++) {
				p[i] = Integer.parseInt(br.readLine());
			}
			//
			for (int i = 0; i < 5; i++) {
				switch (p[i]) {
				case 1:
					rock++;
					break;
				case 2:
					scissors++;
					break;
				case 3:
					paper++;
					break;
				}
			}
			//
			if ((rock * paper * scissors) > 0) {
				p = new int[] { 3, 3, 3, 3, 3 };
			} else if (rock == 5 || paper == 5 || scissors == 5) {
				p = new int[] { 3, 3, 3, 3, 3 };
			} else {
				if (rock == 0) {
					for (int i = 0; i < 5; i++) {
						if (p[i] == 2) {
							p[i] = 1;
						} else {
							p[i] = 2;
						}
					}
				} else if (scissors == 0) {
					for (int i = 0; i < 5; i++) {
						if (p[i] == 3) {
							p[i] = 1;
						} else {
							p[i] = 2;
						}
					}
				} else if (paper == 0) {
					for (int i = 0; i < 5; i++) {
						if (p[i] == 1) {
							p[i] = 1;
						} else {
							p[i] = 2;
						}
					}
				}
			}
			//
			for (int i = 0; i < 5; i++) {
				System.out.println(p[i]);
			}
		}
	}
}

Measured memory_bytes: 16976
import itertools
n, m = map(int,input().split())
D = {tuple(sorted(map(int,input().split()))) for i in range(m)}
#print(D)
cnt = 0
for i in itertools.permutations(range(2,n+1),n-1):
  li = [1] + list(i)
  #print(li)
  cnt += sum(1 for j in zip(li,li[1:]) if tuple(sorted(j)) in D) == n-1
print(cnt)


Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    Integer[] array = new Integer[n];

    for(int i=0; i<n; i++){
      array[i] = sc.nextInt();
    }
    Arrays.sort(array,Collections.reverseOrder());

    //for(int a:array){System.out.println(a);}
    int max = -1;
    int min = -1;
    int sub_min = Integer.MAX_VALUE;

    for(int i=0; i<n-k+1;i++){
      max = array[i];
      min = array[i+k-1];
      if(sub_min>max-min){
        sub_min = max - min;
      }
    }

    System.out.println(sub_min);

  }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  printf("%d", n*n);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3848
using System;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	string[] s = Console.ReadLine().Split();
    int a = int.Parse(s[0]);
    int b = int.Parse(s[1]);
    int c = int.Parse(s[2]);
    if(a>c & c>b){
      Console.WriteLine("Yes");
      return;
    }else if(b>c & c>a){
      Console.WriteLine("Yes");
      return;
    }
    Console.WriteLine("No");
  }
}

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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
string s1,t1;
ll lcs(ll i,ll j,vector<vector<ll>> &dp)
{
    if(i<0 || j<0)
        return 0;
    if(dp[i+1][j+1]!=-1)
        return dp[i+1][j+1];
    if(s1[i]==t1[j])
        return dp[i+1][j+1] = 1 + lcs(i-1,j-1,dp);
    else
        return dp[i+1][j+1] = max(lcs(i,j-1,dp),lcs(i-1,j,dp));
}

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> s1 >> t1;
        vector<vector<ll>> dp(s1.size()+1,vector<ll>(t1.size()+1,-1));
        ll len = lcs(s1.size()-1,t1.size()-1,dp);

        n = t1.size();
        m = s1.size();
        string ans;
        while(n>0 && m>0)
        {
            if (s1[m-1] == t1[n-1])
        	{
        		ans = s1[m-1] + ans;
        		m--; n--;
        	}

        	else if (dp[m-1][n] > dp[m][n-1])
        		m--;
        	else
        		n--;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    cout << ( B < A ? A - 1 : A ) << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  bool b = true;
  int T = 0;
  int X = 0;
  int Y = 0;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int delx = max(X-x,x-X);
    int dely = max(Y-y,y-Y);
    int delt = t-T;
    if (delx + dely > delt || (delt - delx - dely) % 2 != 0) {
      b = false;
      break;
    }
    T = t; X = x; Y = y;
  }
  
  if (b) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

ans = 0
L.sort()
for i in range(N-2):
    for j in range(i+1, N-1):
        k = bisect_left(L, L[i]+L[j])
        ans += k - j - 1
print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k, a, b, cnt = 0, ans;
  cin >> n >> k;
  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

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

  for (auto x : p) {
    cnt += x.second;
    if (cnt >= k) {
      ans = x.first;
      break;
    }
  }
  cout << ans << endl;

  // priority_queue<int, vector<int>, greater<int>> pq;

  // for (int i = 0; i < n; ++i) {
  //   cin >> a >> b;
  //   for (int j = 0; j < b; ++j) {
  //     pq.push(a);
  //   }
  // }

  // for (int i = 0; i < k - 1; ++i) pq.pop();

  // cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<ll, int>;
const int MX = 100005;
int n, m, u, v, dep[MX] = {1};
ll l = 1, r = 1e9, s, a[MX];
vector<P> G[MX];
queue<int> qu;
int main(){
	scanf("%d%d", &n, &m);
	rep(i,m){
		scanf("%d%d%lld", &u, &v, &s);
		u--; v--;
		G[u].push_back(P(s,v));
		G[v].push_back(P(s,u));
	}
	qu.push(0);
	while(!qu.empty()){
		v = qu.front(); qu.pop();
		for(P nx: G[v]){
			tie(s,u) = nx;
			if(dep[u]){
				if(dep[u] == dep[v]){
					ll k = s - (a[u] + a[v]);
					if(k % 2) return 0*puts("0");
					k = dep[u] % 2 ? k/2 : -k/2;
					l = max(l,k);
					r = min(r,k);
				}else if(a[u] + a[v] != s) return 0*puts("0");
			}else{
				qu.push(u);
				dep[u] = dep[v] + 1;
				a[u] = s - a[v];
				if(dep[u] % 2) l = max(l,1-a[u]);
				else r = min(r,a[u]-1);
			}
		}
	}
	printf("%lld\n", max(0LL,r-l+1));
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < N; i++){
        int cnt = 0;
        if(a[i] % 2 == 0) {
            ll target = a[i];
            while(target % 2 == 0) {
                target /= 2;
                cnt+=1;
            }
        }
        ans += cnt;
    }
    
    cout << ans << endl;
}


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

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

  vector<int> s(N + 1, 0);
  for (int i = 0; i < N; i++)
    cin >> s.at(i);
  sort(s.begin(), s.end(), greater<int>());

  int sum = 0;
  for (int i = 0; i < N; i += 2)
    sum += s.at(i) - s.at(i + 1);

  cout << sum << endl;
}


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

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

    const int N = 1e5+5;
    vector<int> adj[N];
    
    int n,m;
    cin >> n >> m;
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        a --; b --;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    queue<int> q;
    vector<int> visited(n,false);
    visited[0] = true;
    vector<int> parent(n, -1);

    q.push(0);

    while(!q.empty()){
        auto x = q.front(); q.pop();
        for(auto y : adj[x] ){
            if( visited[y] == false ){
                visited[y] = true;
                parent[y] = x;
                q.push(y);
            }
        }
    }
    for(int i=0; i<n; ++i){
        if( visited[i] == false ){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(int i=1; i<n; ++i){
        cout << parent[i] + 1 << '\n';
    }


    return 0;
}

Measured memory_bytes: 10708
s = list(input())[::-1]

mod = 10**9 + 7

rest = []
for i in range(6):
    res = []
    for j in range(10):
        res.append(((10**i)*j) % 13)
    rest.append(res)

nowtable = [0] * 13
nowtable[0] = 1

for i in range(len(s)):
    degree = i % 6
    nextable = [0] * 13
    if s[i] == '?':
        for j in range(10):
            for k in range(13):
                index = (k + rest[degree][j]) % 13
                nextable[index] = (nextable[index] + nowtable[k]) % mod
    else:
        num = int(s[i])
        for k in range(13):
            index = (k + rest[degree][num]) % 13
            nextable[index] = (nextable[index] + nowtable[k]) % mod
    nowtable = nextable

print(nowtable[5])


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

#define int long long

using namespace std;

int dp[1005][1005];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    const int mod = 1e9+7;

    int h, w;
    cin >> h >> w;
    dp[1][1] = 1;
    char c[h+3][w+3];

    for(int i = 0; i < h+3; i++)
        for(int j = 0; j < w+3; j++)
            c[i][j] = '#';
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            cin >> c[i][j];

    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++) {
            if(i > 1 || j > 1) {
                if(c[i][j-1] == '.')
                    dp[i][j] += dp[i][j-1];
                if(c[i-1][j] == '.')
                    dp[i][j] += dp[i-1][j];
                dp[i][j] %= mod;
            }
        }

    cout << dp[h][w];

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define COUNTOF1(array) (sizeof(array) / sizeof(array[0]))
#define COUNTOF2(array) (sizeof(array[0]) / sizeof(array[0][0]))

int main(){

  int H,W;
  cin >> H >> W;
  char a[H][W];
  // initialize
  vector<bool> h(H, false);
  vector<bool> w(W, false);

  rep(i,H){
    rep(j,W){
      cin >> a[i][j];
      if(a[i][j]=='#') {
        h[i]=true;
        w[j]=true;
      }
    }
  }

  rep(i,H){
    if(h[i]==true){
       rep(j,W){
         if(w[j]==true) cout << a[i][j];
       }
    cout << '\n';
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 998244353LL;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
template <class T>
struct Matrix {
    vector<vector<T>> a;
    Matrix() {}
    Matrix(int n, int m) : a(n, vector<T>(m)) {}
    inline const vector<T> &operator[](int k) const {
        return a.at(k);
    }
    inline vector<T> &operator[](int k) {
        return a.at(k);
    }
    Matrix I(int n) {
        Matrix mat(n);
        for (int i = 0; i < n; i++) {
            mat[i][i] = 1;
        }
        return mat;
    }
    Matrix &operator+=(const Matrix &rhs) {
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < a[i].size(); j++) {
                (*this)[i][j] += rhs[i][j];
            }
        }
        return (*this);
    }
    Matrix &operator-=(const Matrix &rhs) {
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < a[i].size(); j++) {
                (*this)[i][j] -= rhs[i][j];
            }
        }
        return (*this);
    }
    Matrix &operator*=(const Matrix &rhs) {
        int n = a.size(), m = a[0].size(), p = rhs[0].size();
        assert(m == rhs.a.size());
        vector<vector<T>> b(n, vector<T>(p));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < p; j++) {
                for (int k = 0; k < m; k++) {
                    b[i][j] += (*this)[i][k] * rhs[k][j];
                }
            }
        }
        swap(a, b);
        return (*this);
    }
    Matrix &operator^=(const long long &rhs) const {
        ll n = rhs;
        Matrix res = I(a.size());
        while (n > 0) {
            if (n & 1) {
                res *= (*this);
            }
            (*this) *= (*this);
            n >>= 1;
        }
        swap(a, res.a);
        return (*this);
    }
    Matrix operator+(const Matrix &rhs) const {
        return Matrix(*this) += rhs;
    }
    Matrix operator-(const Matrix &rhs) const {
        return Matrix(*this) -= rhs;
    }
    Matrix operator*(const Matrix &rhs) const {
        return Matrix(*this) *= rhs;
    }
    Matrix operator^(const long long &rhs) const {
        return Matrix(*this) ^= rhs;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    Matrix<ll> a(n, m), b(m, 1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i][0];
    }
    Matrix<ll> c = a * b;
    for (int i = 0; i < n; i++) {
        cout << c[i][0] << '\n';
    }
}


Measured memory_bytes: 3288
n = int(input())
A = [int(x) for x in input().split()]

p = 10**9 + 7

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

from itertools import chain, accumulate
memo_fact = list(chain([1], accumulate(range(1, 10**5 + 2), lambda a, x: a * x % p)))

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return memo_fact[n] * gfp_inv(memo_fact[n - m], p) * gfp_inv(memo_fact[m], p) % p

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)

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

int main(){
    int n;
    cin >> n;
    int a[200000], b[200000];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int j = n - 1;
    int c;
    if(n%2 == 0)
        c = n/2;
    else
        c = n/2 + 1;
    for(int i=0;i<c;i++){
        b[i] = a[j];
        j--;
        if(j>=0){
            b[n - 1 - i] = a[j];
            j--;
        }
    }
    for(int i=0;i<n;i++)
        cout << b[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
import java.util.Map.Entry;
import java.lang.reflect.Method;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayList;

//import org.w3c.dom.css.Counter;

public class Main {
    // public class App {

    public static void main(final String[] args)throws Exception{
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final Scanner s = new Scanner(System.in);
        int D = Integer.parseInt(s.next());
        int T = Integer.parseInt(s.next());
        int S = Integer.parseInt(s.next());
        if(D > T*S){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
    }
}

Measured memory_bytes: 35624
#include <stdio.h>
int heap[5000000];
int n;
 
void getmax(int);
void build(void);

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&heap[i]);
  build();
  for(i=1;i<=n;i++) printf(" %d",heap[i]);
  printf("\n");
  return 0;
 }

void getmax(int i){
  int l=2*i,r=2*i+1,a,p;
  if(l<=n && heap[i]< heap[l]) a=l;
    else a=i;
    if(heap[r] > heap[a] && r<=n) a=r;
    if(a!=i){
      p=heap[i];
      heap[i]=heap[a];
      heap[a]=p;
      getmax(a);
    }
}

void build(void){
  int i;
  for(i=(n/2);i>=1;i--) getmax(i);
}

Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
 
int main() {
    IN(int, n);
    int a = (n+999)/1000;
    COUT(a*1000-n);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)
int main() {
	int n,a;
	string ans ="APPROVED";

	cin >>n;

	rep(i,n){
		cin >> a;
		if (a%2)continue;
		if (a%3&&a%5){
			ans="DENIED";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
t=0
for i in range(k):
    if t==0:
        if a%2==0:
            b+=a//2
            a=a//2
        else:
            b+=(a-1)//2
            a=(a-1)//2
        t=1
    else:
        if b%2==0:
            a+=b//2
            b=b//2
        else:
            a+=(b-1)//2
            b=(b-1)//2
        t=0
print(a,end=" ")
print(b)

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int a[2][110];

int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,2){
        rep(j,n) cin>>a[i][j];
    }
    rep(i,n){
        int cnt=0;
        int k=0;
        rep(j,n){
            cnt+=a[k][j];
            if(j==i){
                k++;
                cnt+=a[k][j];
            }
        }
        if(cnt>ans) ans=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

INF = -1
H, W = map(int,input().split())
stpt = [1,1]
stpt[0]-=1
stpt[1]-=1
glpt = [H,W]
glpt[0]-=1
glpt[1]-=1
Gmap = [list(input()) for _ in range(H)]
Dist = [[INF]*W for _ in range(H)]
direc = [[1,0], [-1,0], [0,1], [0,-1]]

def dfs(start):
    Dist[start[0]][start[1]] = 1
    q = deque([])
    q.append(start)
    r = 0
    while len(q)!=0:
        #スタック取り出し(先頭)幅優先
        h,w = q.popleft()
        for d in direc:
            hs, ws = h + d[0], w + d[1]
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF:
                q.append([hs,ws])
                Dist[hs][ws] = Dist[h][w] + 1

def main():
    dfs(stpt)
    white = Dist[glpt[0]][glpt[1]]
    if white == INF:
        print(-1)
    else:
        black = sum([Gmap[h].count('#') for h in range(H)])
        print(H*W-white-black)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll s; cin >> s;
	ll x,y;
	ll v = 1000000000;
	x = (v-s%v)%v;
	y = (s+x)/v;
	cout << "0 0 1000000000 1 " << x << ' ' << y << endl;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    ANS(N,(N+1)/2);
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

LL mod_pow(LL a, LL n) {
    LL res = 1;
    while( n > 0 ) {
        if ( n & 1 ) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }

    return res;
}

void solve(long long N, std::vector<long long> C){
    sort(ALL(C), greater<LL>());
    LL tmp = mod_pow(2, N - 1);
    LL ans = 0;

    REP(i, N) {
        ans += ((((tmp + i * (N == 1 ? 0 : mod_pow(2, N-2))) % MOD) * C[i]) % MOD);
        ans %= MOD;
    }
    cout << ((ans * mod_pow(2, N)) % MOD) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(C));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int main(void) {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  S[K-1] = S[K-1] - 'A' + 'a';
  cout << S << endl;
}


Measured memory_bytes: 256
using System;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if ((a < b) & (a < c) & (b < c))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8816
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

ll func(ll b,ll n){
	if(n<b)
		return n;
	else
		return (func(b,n/b)+(n%b));
}

int main(){
	ll n,s;
	cin>>n>>s;
	if(s==n){
		cout<<n+1<<endl;
		return 0;
	}
	for(int i=2;i<sqrt(1.*n)+1;i++){
		//printf("%d %d\n",i,func(i,n));
		if(func(i,n)==s){
			cout<<i<<endl;
			return 0;
		}
	}
	for(int i=sqrt(1.*n)+1;i>=1;i--){
		ll b=(n-s)/i+1;
		//printf("%d %d\n",i,func(b,n));
		if(b>=2 && func(b,n)==s){
			cout<<b<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;
	return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i, a, b) for (int i=a; i<(b); i++)

int n;
map<pair<ll,ll>,pii> mp;
ll ans=1;

ll p0w(ll base,int p) {
	ll res=1;
	while (p) {
		if (p&1) res=res*base%mod;
		base=base*base%mod;
		p>>=1;
	}
	return res;
}

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    int cnt=0;
    rep(i,0,n) {
    	ll a,b;
    	cin>>a>>b;
    	if (a==0&&b==0) cnt++;
    	else if (a==0) mp[MP(0,0)].fi++;
    	else if (b==0) mp[MP(0,0)].se++;
    	else {
	    	ll c=__gcd(abs(a),abs(b));
	    	a/=c,b/=c;
	    	bool ok=false;
	    	if (a<0&&b<0) a=-a,b=-b;
	    	else if (a<0) a=-a,swap(a,b),ok=true;
	    	else if (b<0) b=-b,swap(a,b),ok=true;
	    	if (ok) mp[MP(a,b)].fi++;
	    	else mp[MP(a,b)].se++;
	    }
	}
	for (map<pair<ll,ll>,pii>::iterator it=mp.begin();it!=mp.end();it++) {
		ans*=((p0w(2,(it->se).fi)+p0w(2,(it->se).se))%mod-1+mod)%mod;
		ans%=mod;
	}
	ans=(ans-1+mod)%mod;
	(ans+=cnt)%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16044
from collections import Counter
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
counter_a = Counter(a_li)
most_a = counter_a.most_common()
dum = len(most_a)
if dum <= k:
    print(0)
else:
    ans = 0
    for i in range(dum-1,k-1,-1):
        ans += most_a[i][1]
    print(ans)


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define MAX_V        20004

const ll inf = 1e15;
const ll mod = 1e9+7;

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

struct edge {
    ll to, cap, rev;
    edge(ll t, ll c, ll r): to(t), cap(c), rev(r){}
};

vector<edge> G[20004];
bool used[20004];

void add_edge(ll from, ll to, ll cap) {
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size() - 1));
}

ll dfs(ll v, ll t, ll f) {
    if (v == t) return f;
    used[v] = true;
    rep(i, G[v].size()) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            ll d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(ll s, ll t) {
    ll flow = 0;
    while (true) {
        memset(used, 0, sizeof(used));
        ll f =  dfs(s, t, inf);
        if (f == 0) return flow;
        flow += f;
    }
}

char field[101][101];
int main() {
    ll H, W; cin >> H >> W;
    rep(i, H) rep(j, W) {
        cin >> field[i][j];
        if (field[i][j] == 'X' && (i == 0 || i == H-1 || j == 0 || j == W-1)) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    ll S = 2 * H * W;
    ll T = 2 * H * W + 1;
    rep(i, H) rep(j, W) {
        if (field[i][j] == 'X') add_edge(S, i * W + j, inf);
        if (i == 0 || i == H-1 || j == 0 || j == W-1) add_edge(H * W + i * W + j, T, inf);
        
        add_edge(i * W + j, H * W + i * W + j, field[i][j] == 'X' ? inf : 1);
        rep(k, 4) {
            if (i+dy[k] < 0 || H-1 < i+dy[k] || j+dx[k] < 0 || W-1 < j+dx[k]) continue;
            add_edge(H * W + i * W + j, (i+dy[k]) * W + (j+dx[k]), inf);
        }
    }
    cout << max_flow(S, T) << endl;
    
    return 0;
}

Measured memory_bytes: 5120