akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int mod = 1e9 + 7;
const int MX = 210000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll C(ll n, ll k){
	return f[n] * invf[k] % mod * invf[n - k] % mod;
}
bool visit(const vector<vi> &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  for(int e : g[v]) {
    if (color[e] == 2) continue;
    if (color[e] == 1) return false;
    if (!visit(g, e, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
bool topologicalSort(const vector<vi> &g, vector<int> &order) {
  int n = g.size();
  vector<int> color(n);
  rep(u, n) if (!color[u] && !visit(g, u, order, color))
    return false;
  reverse(all(order));
  return true;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	calc();
	int h, w, n; cin >> h >> w >> n;
	vector<pi> in;
	
	in.emplace_back(1, 1);
	rep(i, n){
		int y, x; cin >> y >> x;
		in.emplace_back(y, x);
	}
	in.emplace_back(h, w);
	n += 2;
	
	vector<vi> g(n);
	rep(i, n) rep(j, n) if(i != j){
		if(in[i].first <= in[j].first && in[i].second <= in[j].second) g[i].pb(j);
	}
	vi ord;
	topologicalSort(g, ord);
	//dbg(in); dbg(ord);
	
	vector<vi> dp(n, vi(2));
	dp[0][0] = 1;
	for(int i : ord){
		for(int j : ord){
			if(i == j) break;
			int y = in[i].first - in[j].first;
			int x = in[i].second - in[j].second;
			if(y < 0 || x < 0) continue;
			
			rep(k, 2) (dp[i][k ^ 1] += dp[j][k] * C(x + y, x) % mod) %= mod;
		}
	}
	ll ans = (dp[n - 1][1] + mod - dp[n - 1][0]) % mod;
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int n,b,f,r,v,floor[4][3][10] = {};
	
	cin >> n;
	
	for(int i=0;i<n;++i){
		cin >> b >> f >> r >> v;
		floor[b-1][f-1][r-1] += v;
	}

	for(int i=0;i<4;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<10;++k){
				cout << ' ' << floor[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)
			cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

ll a[300000 + 1];

int main(){
	int N;

	cin >> N;
	for (int i = 0; i<3 * N; i++){
		cin >> a[i];
	}
	sort(a, a + 3 * N, greater<ll>());

	ll sum = 0;
	int j = 0;

	for (int i = 1; j<N; i+=2, j++)sum += a[i];

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char C;
    char alp[30]="abcdefghijklmnopqrstuvwxyz";
    cin >> C;
    
    for(int i=0;i<26;i++){
        if(alp[i]==C){
        cout << alp[i+1] << endl;
        return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
 
int main(){
    int A, B;
    cin >>  A >> B;

    rep(i, 1300){
        int syohi_8 = i*0.08;
        int syohi_10 = i*0.1;
        if(syohi_8==A && syohi_10==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}

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

using namespace std;

#define ll long long

int main(){
    int N;
    string S;
    map<string, int> mp;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S;
        mp.insert(make_pair(S, i));
    }
    cout << mp.size() << endl;
    return 0;
}


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

#define fi first
#define se second

const int N = 110;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

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

        int n;
        cin >> n;
        vector < int > a(n);
        long long inf = 1e18;
        vector < long long > d(n + 1, - inf);
        vector < long long > f(n + 1, - inf);
        
        d[0] = 0;
        
        for(int i = 0; i < n; i++){
                cin >> a[i];

                d[i + 1] = max(d[i + 1], d[i] + a[i] / 2);
                d[i + 1] = max(d[i + 1], f[i] + a[i] / 2);
                if(a[i] > 0)f[i + 1] = max(f[i + 1], d[i] + (a[i] - 1) / 2);
                if(a[i] > 0)d[i + 1] = max(d[i + 1], f[i] + (a[i] - 1) / 2 + 1);
                if(a[i] > 0)f[i + 1] = max(f[i + 1], f[i] + (a[i] - 1) / 2);
                if(a[i] > 1)f[i + 1] = max(f[i + 1], f[i] + (a[i] - 2) / 2 + 1);
                d[i] = max(d[i], f[i]);
        }

        cout << max(f.back(), d.back()) << "\n";
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{  
     string s;
    cin >> s;
    
    int flag = 1;
    
    if(s[2] != s[3]) flag=  0;
    if(s[4] != s[5]) flag = 0;
    
    if(flag) cout <<"Yes";
    else cout <<"No";
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	if(N%2==0){
		cout<<0.5<<endl;
	}else{
        double M=(double)N;
		cout<<(M+1)/(2*M)<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int A = one.get(0);
		int B = one.get(1);
		int C = one.get(2);
		myout(Math.min(A + B, Math.min(A + C, B + C)));
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 25332
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
     int b = a/3600;
     int c = a%3600;
     int d = c/60;
     int e = c%60;
     System.out.println(b+":"+d+":"+e);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String line = br.readLine();
    }
}



Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<=n;j++){
      if(s[j]!='A'&&s[j]!='T'&&s[j]!='C'&&s[j]!='G'){
        ans=max(ans,j-i);
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    if(N / 100 == 7)
        cout << "Yes" << endl;
    else if (N % 100 / 10 == 7)
        cout << "Yes" << endl;
    else if (N % 100 % 10 / 1 == 7)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

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

    int temp = n % 10;

    if (temp == 2 || temp == 4 || temp == 5 || temp == 7 || temp == 9)
    {
        cout << "hon" << "\n";
    }
    else if (temp == 3)
    {
        cout << "bon" << "\n";
    }
    else
    {
        cout << "pon" << "\n";
    }
}

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

Measured memory_bytes: 3620
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())

    vec = list(range(1, 10))
    for i in range(K):
        tail = vec[i] % 10
        n10 = vec[i] * 10
        if tail == 0:
            vec.append(n10 + tail)
            vec.append(n10 + tail + 1)
        elif tail == 9:
            vec.append(n10 + tail - 1)
            vec.append(n10 + tail)
        else:
            vec.append(n10 + tail - 1)
            vec.append(n10 + tail)
            vec.append(n10 + tail + 1)
            
        if len(vec) == K:
            break

    print(vec[K - 1])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 86380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
      int a = sc.nextInt();
		
        int b = sc.nextInt();
		String s = "NG";
      
        for(int i=a;i<=b;i++){if(i%k==0){s="OK";break;
                                                 }
                            }
        
		System.out.println(s);
	}
}


Measured memory_bytes: 35728
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    insert(node(x));
  }
  return 0;
}


Measured memory_bytes: 26576
#include <stdio.h>
#include <string.h>
#include <math.h>
#define PI 3.141592653589793
#define EPS 0.000001

double arctan(double x,double y){
	if (fabs(x) < EPS) return PI / 2;
	if (x > 0){
		if (y > 0){
			return atan(y / x);
		}
		else{
			y *= -1;
			return -atan(y / x) + 2*PI;
		}
	}
	else{
		x *= -1;
		if (y > 0){
			return -atan(y / x) + PI;
		}
		else{
			y *= -1;
			return atan(y / x) + PI;
		}
	}
}
int main(void){
	double x, y;
	double arg;
	int n;
	scanf("%d", &n);
	while (n != -1){
		n--;
		x = 1;
		y = 0;
		while (n--){
			arg = arctan(x, y);
			arg += PI / 2;
			x += 1 * cos(arg);
			y += 1 * sin(arg);
		}
		printf("%lf\n%lf\n", x, y);
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 712
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)


// 素数と個数を求める
vector<pair<ll,ll>> factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2L; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1L);
  return res;
}

//約数列挙
vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1; i*i<=n; ++i){
		if(n%i != 0) continue;
		res.push_back(i);
		if(i*i != n) res.push_back(n/i);
	}
	return res;
}

int main(){
	int N; cin>>N;
	vi A(N);
	int max_a = 0;
	rp(i,0,N){
		cin>>A[i];
		max_a = max(max_a, A[i]);
	}

	vi E(max_a + 1, 0);
	for(auto a:A){
		E[a]++;
	}

	int ans = 0;

	rp(i,0,N){
		vector<ll> d = divisors((ll)A[i]);
		// cout<<setw(2)<<A[i]<<" [";
		// for(auto x:d){cout<<x<<" ";}
		// puts("]");

		bool ok = true;
		for(auto x:d){
			if(A[i] != x && E[x] == 1){
				ok = false;
				break;
			}
			else if(E[x] > 1){
				ok = false;
				break;
			}

		}

		if(ok){
			ans++;
		}

	}

	cout<< ans <<endl;
}


Measured memory_bytes: 7952
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = -1;
  REP(i2,n-1){
    string S = s.substr(i2,s.size()-i2);
    int A[200000];
    int i = 1, j = 0;
    while (i < S.size()) {
      while (i+j < S.size() && S[j] == S[i+j]) ++j;
      A[i] = j;
      if (j == 0) { ++i; continue;}
      //cout << i << " "<< j << endl;
      int k = 1;
      while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
      i += k; j -= k;
    }
    REP(i3,S.size()){
      if(i3==0) continue;
      int tt = min(i3,A[i3]);
      ans = max(ans,tt);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#define llint long long

using namespace std;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

llint n;
llint a[100005];
llint s[100005];
map<llint, llint> mp;
BIT bit(100005);

bool check(llint x)
{
	s[0] = 0;
	for(int i = 1; i <= n; i++){
		s[i] = s[i-1];
		if(a[i] <= x) s[i]++;
		else s[i]--;
	}
	
	mp.clear();
	for(int i = 0; i <= n; i++) mp[s[i]];
	llint id = 1;
	for(auto it = mp.begin(); it != mp.end(); it++) it->second = id++;
	for(int i = 0; i <= n; i++) s[i] = mp[s[i]];
	
	llint cnt = 0;
	bit.init();
	for(int i = 0; i <= n; i++){
		cnt += bit.query(s[i]-1);
		bit.add(s[i], 1);
	}
	return cnt >= n*(n+1)/2/2+1;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ub = 1e9+7, lb = 0, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	return 0;
}

Measured memory_bytes: 8832
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] c = sc.next().toCharArray();
 
   String ans = "Yes";
   if(c[0] == c[1] && c[1] == c[2]) ans = "No";
   System.out.print(ans);
 }
}

Measured memory_bytes: 21716
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
count = 0

for i in range(q):
    for j in range(n):
        if T[i] == S[j]:
            count += 1
            break

print(count)



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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

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


    cout << S.substr(0, 3) << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,ll> mp;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll tmp=max(a,max(b,c));
    if(tmp==a){
        cout<<b*c*(a-tmp/2)-b*c*(tmp/2)<<endl;
    }
    else if(tmp==b){
        cout<<a*c*(b-tmp/2)-a*c*(tmp/2)<<endl;
    }
    else cout<<b*a*(c-tmp/2)-b*a*(tmp/2)<<endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  int su = 0;
  REP(i, SZ(s)) {
    su += s[i] - '0';
    su %= 9;
  }
  cout << (su == 0 ? "Yes" : "No") << endl;

}








Measured memory_bytes: 3780
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999
int main() {
	int h = 0, w = 0;
	char can[50][50] = {};
	bool flug = true;//true yes false no
	std::cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			std::cin >> can[i][j];
		}
	}
	if (can[0][0] == '#' && can[0][1] == '.' && can[1][0] == '.') {
		flug = false;
	}
	if (can[0][w-1] == '#' && can[0][w-2] == '.' && can[1][w-1] == '.') {
		flug = false;
	}
	if (can[h-1][0] == '#' && can[h-1][1] == '.' && can[h-2][0] == '.') {
		flug = false;
	}
	if (can[h-1][w-1] == '#' && can[h-1][w-2] == '.' && can[h-2][w-1] == '.') {
		flug = false;
	}
	for (int i = 1; i < w; i++) {
		if (can[0][i] == '#' && can[0][i + 1] == '.' && can[0][i - 1] == '.' && can[1][i] == '.') {
			flug = false;
		}
	}
	for (int i = 1; i < w; i++) {
		if (can[h-1][i] == '#' && can[h-1][i + 1] == '.' && can[h-1][i - 1] == '.'&&can[h-2][i]=='.') {
			flug = false;
		}
	}
	for (int i = 1; i < h; i++) {
		if (can[i][0] == '#' && can[i-1][0] == '.' && can[i+1][0] == '.'&&can[i][1] == '.') {
			flug = false;
		}
	}
	for (int i = 1; i < h; i++) {
		if (can[i][w-1] == '#' && can[i - 1][w-1] == '.' && can[i + 1][w-1] == '.'&&can[i][w-2] == '.') {
			flug = false;
		}
	}
	for (int i = 1; i < h-1; i++) {
		for (int j = 1; j < w-1; j++) {
			if (can[i][j] == '#' && can[i - 1][j] == '.' && can[i + 1][j] == '.' && can[i][j + 1] == '.' && can[i][j - 1] == '.') {
				flug = false;
			}
		}
	}
	if (flug == true) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  val linse = (0 until n).map(_ => StdIn.readLine())
  
  val d = Array.fill[Long](5)(0)
  
  linse.foreach{ l =>
    val idx = l.charAt(0) match {
      case 'M' => 0
      case 'A' => 1
      case 'R' => 2
      case 'C' => 3
      case 'H' => 4
      case _ => -1
    }
    if(0 <= idx) d(idx) += 1
  }
  val co = List(0, 1, 2, 3, 4).combinations(3)
  //println(co.mkString(" "))
  var r = 0L
  co.foreach{ p =>
    r += d(p(0))*d(p(1))*d(p(2))
  }
  println(r)
  
}

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

using namespace std;

void dfs(vector<vector<pair<int, int> > >& ver, int par, int v, int dist, vector<int>& res) {
	for(auto vx : ver[v]) {
		if(vx.first != par) {
			res[vx.first] = (dist + vx.second)% 2;
			dfs(ver, v, vx.first, res[vx.first], res);
		}
	}
}

int main() {
	int n, u, v, w;
	cin >> n;
	vector<int> res(n + 1);
	vector<vector<pair<int, int>>> ver(n +  1);
	for(int i = 0; i < n - 1; i++) {
		cin >> u >> v >> w;
		ver[u].push_back(make_pair(v, w));
		ver[v].push_back(make_pair(u, w));
	}
	res[1] = 0;
	dfs(ver, -1, 1, 0, res);
	for(int i = 1; i <= n; i++) 
		cout << res[i] << endl;
	return 0;
}

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

long long N, W, w, v;
long long dp[100004];

int main() {
	cin>>N>>W;
	memset(dp,0,sizeof(dp));
	for(int i = 0;i<N;i++){
		cin>>w>>v;
		for(int j = W-w;j>=0;j--){
			dp[j+w] = max(dp[j+w],dp[j]+v);
		}
		
	}
	cout<<*max_element(dp,dp+W+1);
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
X = [ [] for j in range(N+1) ]
for i in range(M):
    a, b = map(int, input().split())
    X[a].append(b)
    X[b].append(a)

result = [0] * (N+1)
c = []
flag = [0]*N
for x in X[1]:
    result[x] = 1
    c.append(x)
    flag[x-1]=True

c_new = []
while not all(flag):
    for x in c:
        for y in X[x]:
            if flag[y-1] == False:
                result[y] = x
                c_new.append(y)
                flag[y-1] = True
    c = c_new
    c_new = []

print('Yes')
for j in range(2, N+1):
    print(result[j])

Measured memory_bytes: 34576
using System;
using System.Collections.Generic;
using System.Linq;
using static Constans;

public static class Constans
{
    public const long Mod = (long)1e9 + 7;
}

public struct ModInt
{
    public long Num;

    public ModInt(long num)
    {
        Num = num;
    }

    // x^n
    public static long Power(long x, long n)
    {
        long pow = 1;
        while (n > 0)
        {
            if (n % 2 == 0)
            {
                x *= x;
                x %= Mod;
                n /= 2;
            }
            else
            {
                pow *= x;
                pow %= Mod;
                n--;
            }
        }

        return pow;
    }

    public static ModInt GetInv(long f)
    {
        // フェルマーの小定理 a^(-1) = a^(mod-2)
        return new ModInt(Power(f, Mod - 2));
    }

    public ModInt GetInv()
    {
        return GetInv(Num);
    }

    public override string ToString()
    {
        return Num.ToString();
    }

    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Num += r.Num;
        if (l.Num >= Mod)
        {
            l.Num -= Mod;
        }
        return l;
    }

    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Num -= r.Num;
        if (l.Num < 0)
        {
            l.Num += Mod;
        }
        return l;
    }

    public static ModInt operator *(ModInt l, ModInt r)
    {
        return new ModInt(l.Num * r.Num % Mod);
    }

    public static implicit operator ModInt(long n)
    {
        n %= Mod;
        if (n < 0)
        {
            n += Mod;
        }
        return new ModInt(n);
    }
}

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var sum = new ModInt(0);
        for (var bit = 1L; bit < (1L << 60); bit <<= 1)
        {
            var zeros = 0;
            var ones = 0;
            foreach (var a in A)
            {
                if ((a & bit) != 0)
                {
                    ones++;
                }
                else
                {
                    zeros++;
                }
            }
            sum += ((ModInt)zeros) * ((ModInt)ones) * ((ModInt)bit);
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 57036
#include <iostream>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include<string>
#include<stack>
#include<queue>
#include<stdio.h>
#include<set>
#include<vector>

#define _CRT_SECURE_NO_WARNINGS
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

using namespace std;




int main()
{
	//cin>>N;
	// for (int i = 0; i < N; ++i) cin >> A[i];
	//while(true){break; ++res;}
	//cout << res << endl;
	//sort(a, a+N, greater<int>()) 大きい順ソート sort(v.begin(), v.end()); // vector
	//set<int>values; values.insert() values.size()
	//map<string,int>salary; salary["John"] = 1400;
	// string num = to_string(counter);
	// swap(a,b);


	int a, b, d;
	int sum = 0;
	long long int count = 0;
	int check = 0;
	int time;
	int w, h;
	int x, y, r;
	long long int N=0;
	long long int R=0;

	int bcount = 0;
	int acount = 0;
	int wcount = 0;


	string s; // s.size() to_string char string %s


	int max = 0;
	int min = 0;

	int nextattack = 0;
	int leftmonster = 0;
	int l = 0;
	int i = 0;
	int j = 0;

	cin >> N ;
;
	vector<long long int> A(N);
	vector<long long int> B(N);

	while (cin >> l) {
		A[i] = l;
		i=i+1;
		if (i >= N) {
			break;
		}
	}

	while (true) {
		cout<<A[i-1];
		i = i -1;
		if (i > 0)
		{
			cout << " ";
		}
		else if (i <= 0) {
			cout << "" << endl;
			break;
		}
	}


	


}



Measured memory_bytes: 3108
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 1000000
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >v,vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>adj[MAX+10];
bool visited[MAX+10];
ll dep[MAX+10];
ll arr[MAX+10];
void reset()
{
   FOR(i,MAX)
   {
       visited[i]=0;
       dep[i]=0;
       adj[i].clear();
   }
   mp.clear();
   mp1.clear();
}
void solve()
{
    memset(arr,0,sizeof arr);
    FOR1(i,1000000LL)
    {
        if(i%3==0 or i%5==0)
        {
            continue;
        }
        else arr[i]=i;
    }
    FOR1(i,1000000LL) arr[i]+=arr[i-1];
}
int main()
{
    fast;
    ///cin>>ta;
    //FOR(test,ta)
    //{
    solve();
       cin>>n;
       cout<<arr[n]<<endl;
    return 0;
}


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

int w, a, b;

int main(){
	cin >> w >> a >> b;
	if (max(a, b) - (min(a, b) + w) <= 0) {
		cout << '0' << endl;
		return 0;
	}
	else {
		cout << max(a, b) - (min(a, b) + w) << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(10%p==0){
    	ll ans=0;
    	for(int i=0;i<n;i++)if((s[i]-'0')%p==0)ans += i+1;
    	cout << ans << endl;
    	return 0;
    }
    ll a[n+1],b=0,c=1;
    for(int i=n-1;i>=0;i--){
        (b+=c*(s[i]-'0'))%=p;
        a[i]=b;
        (c*=10)%=p;
    }
    ll num[p];
    a[n]=0;
    memset(num,0,sizeof(num));
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=num[a[i]];
        num[a[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2196
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        int n=ni();
        long mod=1000000007;
        long total=0;
        long[]A=new long[n];
        for (int i=0;i<n;i++) {
            A[i]=ni();
            total+=A[i];
        }
        
        long ans=0;
        for (int i=0;i<n;i++) {
            total-=A[i];
            ans=(ans+A[i]*(total%mod))%mod;
        }
        
        out.println(ans);
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 56380
/*
 * main.c
 *
 *  Created on: 2019/05/11
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int N = 0, K = 0;
    scanf("%d %d", &N, &K);
    printf("%d\n",N - (K - 1));
    return 0;
}


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

int a = 0;
int g = 1;
int c = 2;
int t = 3;

long long we_like_agc(int n){
  long long mod = 1000000007;
  long long ans[100][4][4][4][4] = {{{{{0}}}}};

  if(n == 3)
    return 61;
  for(int j=0;j<4;j++) {
    for(int k=0;k<4;k++) {
      for(int l=0;l<4;l++) {
	for(int m=0;m<4;m++) {
	  ans[3][j][k][l][m] = 0;
	  if((j == a && k == g && l == c) || 
	     (j == g && k == a && l == c) || 
	     (j == a && k == c && l == g) || 
	     (j == a && k == g &&           m == c) || 
	     (          k == a && l == g && m == c) ||
	     (j == a           && l == g && m == c) || 
	     (          k == g && l == a && m == c) ||
	     (          k == a && l == c && m == g)){
	    continue;
	  }
	  ans[3][j][k][l][m] = 1;
	}
      }
    }
  }

  for(int i=4;i<n;i++) {
    for(int j=0;j<4;j++) {
      for(int k=0;k<4;k++) {
	for(int l=0;l<4;l++) {
	  for(int m=0;m<4;m++) {
	    ans[i][j][k][l][m] = 0;
	  if((j == a && k == g && l == c) || 
	     (j == g && k == a && l == c) || 
	     (j == a && k == c && l == g) || 
	     (j == a && k == g &&           m == c) || 
	     (          k == a && l == g && m == c) ||
	     (j == a           && l == g && m == c) || 
	     (          k == g && l == a && m == c) ||
	     (          k == a && l == c && m == g)){
	    continue;
	  }
	  for(int o = 0;o<4;o++) {
	    ans[i][j][k][l][m] += ans[i-1][o][j][k][l];
	    ans[i][j][k][l][m] = ans[i][j][k][l][m] % mod;
	  }
	  }
	}
      }
    }
  }

  long long rtn = 0;
  for(int i=0;i<4;i++) {
    for(int j=0;j<4;j++) {
      for(int k=0;k<4;k++) {
	for(int l=0;l<4;l++) {
	  rtn += ans[n-1][i][j][k][l];
	  rtn = rtn % mod;
	}
      }
    }
  }

  return rtn;
}
int main() {
  int n;
  cin >> n;
  cout << we_like_agc(n);
}

Measured memory_bytes: 384
#include <iostream>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p)  
{  
    long long int res = 1;      
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
  
          
        y = y>>1;  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
        long long int sum;
        cin>>sum;
        long long int p=1e9+7;
        
        long long int arr[2005]={0};
        for(int i=3;i<=sum;i++)
        {
            arr[i]=1;
        }
        
        for(int i=4;i<=sum;i++)
        {
            for(int j=3;j<=i;j++)
            {
                arr[i]+=arr[i-j]%p;
                arr[i]%=p;
            }
        }
            
            cout<<arr[sum]<<endl;
	   
	}
	   
	   
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}


int main(){
    fast_io

    string s,ans="CODEFESTIVAL2016";
    cin>>s;
    int cnt=0;
    rep(i,16){
        if(s[i]==ans[i]){}
        else cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = do
    t <- getInt
    unless (t==0) $ do
        n <- getInt
        (t-) . sum . map (apply2 subtract) <$> replicateM n getInts >>= putStrLn . (cond "OK" <$> show <*> (<=0)) >> main


Measured memory_bytes: 4084
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int n,k,x,i,sum=0;
	cin>>n>>k;
	priority_queue<int> pq;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		pq.push(x);
	}
	for(i=1;i<=k;i++)
	{
		sum+=pq.top();
		pq.pop();
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
# Date [ 2020-09-13 23:02:13 ]
# Problem [ e.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    xy = [tuple(read_ints()) for _ in range(n)]
    diff = [x - y for x, y in xy]
    sum_ = [x + y for x, y in xy]
    print(max(max(sum_) - min(sum_), max(diff) - min(diff)))

if __name__ == '__main__':
    Main()

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

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < 3; i++)if (s.at(i) == 'o')ans += 100;
	cout << 700 + ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin>>N;
    vector<int> v(3,0);
    for(int i=0;i<N;i++){
        int n; cin >> n;
        if(n%4==0) v[2]++;
        else if(n%2==0) v[1]++;
        else v[0]++;
    }
    if(v[1]==0){
        if(v[2]>=v[0]-1) cout << "Yes"<< endl;
        else cout << "No" << endl;
    }else{
        if(v[2]>=v[0]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 256
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = gets.split.map(&:to_i)
ans = 'No'
[a, b, c].each do |s|
  if s.include?(x) && s.include?(y)
    ans = 'Yes'
    break
  end
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

/*
連続部分列が問題
*/



int main(void){
    int i,N;
    scanf("%d",&N);
    long long counter = 0;
    int a[N],num[100001];
    for(i=0;i<100001;i++){
        num[i] = 0;
    }
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        if(a[i]<=100000){
            num[a[i]]++;
        }else{
            counter++;
        }
    }
    for(i=0;i<100001;i++){
        if(num[i]<i){
            counter+=num[i];
        }else{
            counter += num[i]-i;
        }
    }
    printf("%lld\n",counter);
    return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      // int[] seqA = new int[nHalf];
      // int[] seqB = new int[nHalf];
      // int[][] seq = {seqA, seqB};

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      List<Map<Integer,Integer>> aMap = new ArrayList<>();
      aMap.add(mapA);
      aMap.add(mapB);
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        // seq[(i&1)][i>>1] = num;
        aMap.get(i&1).merge(num, 1, Integer::sum);
      }

      int[] vm1 = {0,0};
      int[] vm2 = {0,0};
      int[] x   = {0,0};

      for (int i=0; i<aMap.size(); i++) {
        for (Map.Entry<Integer,Integer> m : aMap.get(i).entrySet()) {
          int val = m.getValue();
          if(vm1[i] <val) {
            vm2[i] = vm1[i];
            vm1[i] = val;
            x[i]  = m.getKey();
          } else if(vm2[i] < val) {
            vm2[i] = val;
          }
        }
      }

      int ans = 0;
      int cca1 = nHalf - vm1[0];
      int ccb1 = nHalf - vm1[1];
      int cca2 = nHalf - vm2[0];
      int ccb2 = nHalf - vm2[1];

      if(x[0] == x[1])
        ans = cca2 > ccb2 ? cca1 + ccb2 : cca2 + ccb1;
      else
        ans = cca1 + ccb1;

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main()
{
    long long k,a,b,c=0;
    cin>>k>>a>>b;
    if(a>=k)
    {
        cout<<1<<endl;
        return 0;
    }
    else if(b>=a)
    {
        cout<<-1<<endl;
        return 0;
    }
    else if((k-a)%(a-b)>=1)
    {
        c=1;
    }
    cout<<((k-a)/(a-b)+c)*2+1<<endl;
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,c,ans=1000000000000000000;

main() {
    cin >> a >> b >> c;
    ans = min(ans,(a+1)/2*b*c-a/2*b*c);swap(a,b);ans = min(ans,(a+1)/2*b*c-a/2*b*c);swap(a,c);ans = min(ans,(a+1)/2*b*c-a/2*b*c);
    ct(ans)
}


Measured memory_bytes: 256