akhauriyash/Code-Regression huggingface dataset:
N = int(input())
X = list(map(int, input().split()))

def num(P, X):
    number = 0
    for x in X:
        num = x-P
        #print(str(num))
        num2 = num**2
        number += num2
    return number

nList = []
for p in range(min(X), max(X) + 1):
    nList.append(num(p, X))

n = str(min(nList))
print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){

  string s,ans;
  cin>>s;

  char c='A';

  for(auto e:s){

    if(e!=c) continue;

    ans.push_back(c);

    if(c=='A') c='Z';
    else c='A';
  }

  if(ans.back()=='A') ans.erase(ans.size()-1,1);

  if(ans.empty()) cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 3224
#include <stdio.h>

int main () {
    char S[4];
    char T[4];
    scanf("%s", S);
    scanf("%s", T);
    int i = 0;
    int ans = 0;
    while(i < 3) {
        if (S[i] == T[i])
            ans++;
        i++;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
/**
 @Author -> saurabhP
**/

#include <iostream>
#include <vector>

#define print(arr, n) for(int i = 0; i < n; i++) std::cout << arr[i] << " ";
#define read(arr, n) for(int i = 0; i < n; i++) std::cin >> arr[i];

typedef long long int lld;

using namespace std;

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

int main(){
    // fast();
    string s, t;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if(u == s){
        cout << a - 1 << " " << b;
    }
    else if(u == t){
        cout << a << " " << b - 1;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
s = [None]*N
for i in range(N):
    s[i] = input()
M = int(input())
t = [None]*M
for j in range(M):
    t[j] = input()

sc = Counter(s)
tc = Counter(t)

ans = 0
for k in sc.keys():
    ans = max(ans, sc[k] - tc[k])
print(ans)


Measured memory_bytes: 3316
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
//#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 300005;
const ll mm = 1e+18;
void solve()
{
    int n,m,X;
    cin>>n>>m>>X;
    int mi=mm;
    vector<pair<int,vector<int>>>v;
    rep0(i,n){
        int x;
        cin>>x;
        vector<int>vv;
        rep0(i,m){
            int xx;
            cin>>xx;
            vv.pb(xx);
        }
        v.pb({x,vv});
    }
    rep0(i,(1<<n)){
        int a[m]={0};
        int z=0;
        rep0(j,n){
            if((i>>j)&1){
                z+=v[j].f;
                rep0(k,m) a[k]+=v[j].s[k];
            }
        }
        bool p=true;
        rep0(i,m){
            if(a[i]<X){
                p=false;
                break;
            }
        }
        if(p) mi=min(mi,z);
    }
    if(mi==mm) mi=-1;
    pr(mi);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // srand(time(0));
    //freopen("sp.txt","r",stdin);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

int main() {
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    a -= b;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    ll l=0, r=1e10;
    while (l+1<r) {
        ll c = (l+r) >> 1;
        ll t = 0;
        rep(i, n) {
            ll x = max(d[i]-c*b, 0LL);
            ll s = (x+a-1) / a;
            t += s;
        }
        if (t <= c) r=c; else l=c;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 768
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

ll mat[20][20];
ll cost[20];
ll n, m, x;

int main()
{
    ll i, j, k, l, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    while(cin >> n >> m >> x)
    {
		for(i = 0; i < n; i++)
		{
			slld(cost[i]);
			for(j = 0; j < m; j++) slld(mat[i][j]);
		}

		ans = mxlld;

		for(i = 0; i < (1 << n); i++)
		{
			ll arr[m+1];
			memset(arr,0,sizeof arr);
			ll cst = 0;

			for(j = 0; j < n; j++)
			{
				if(check(i,j))
				{
					cst += cost[j];

					for(k = 0; k < m; k++)
					{
						arr[k] += mat[j][k];
					}
				}
			}

			for(j = 0; j < m; j++)
			{
				if(arr[j] < x) break;
			}

			if(j == m) ans = min(ans,cst);
		}

		if(ans == mxlld) ans = -1;

		cout << ans << '\n';
    }


}





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

int main(){
  int week;
  int money = 100000;
  cin >> week;
  for(int i=0;i<week;i++){
    money*=1.05;
    if(money % 1000 != 0)
    money+=1000;
    money/=1000;
    money*=1000;
  }
  cout << money << endl;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;

int main() {
  string S, T;
  cin >> S >> T;
  vector<string> ans;
  int l = S.size()-T.size()+1;
  for (int i=0; i<max(0, l); i++) {
    string tmp = S;
    for (int j=0; j<T.size(); j++) {
      if (i+j>S.size()-1) break;
      if (tmp[i+j]=='?'||tmp[i+j]==T[j]) tmp[i+j] = T[j];
      else break;
      if (j==T.size()-1) {
        for (int k=0; k<tmp.size(); k++) {
          if (tmp[k]=='?') tmp[k] = 'a';
        }
        ans.push_back(tmp);
      }
    }
  }
  sort(ans.begin(), ans.end());
  cout << (ans.size()>0 ? ans[0]:"UNRESTORABLE") << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	for(auto i:s)cout<<"x";
	cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    map<ll,ll>m;
    rep(i,n){
        cin>>a[i];
        m[a[i]]++;
        }
    ll sum=0;
    for(auto v:m){
       sum+=v.se*(v.se-1)/2;
    }
    rep(i,n){
        ll k=m[a[i]];
        ll ans=sum;
        ans=sum-k*(k-1)/2+(k-1)*(k-2)/2;
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 11008
#include <stdlib.h>
#include <stdio.h>


int main(){
    int x,y,i;
    int turtle =4;
    int crane = 2;
    scanf("%d",&x);
    scanf("%d",&y);
    
    int a = x;

    for(i=0; i <=x;i++){
        if(i * 2 + a *4 == y){
            printf("Yes");
            return 0;
        }
        a--;
    }
    printf("No");
 

    return 0;
}


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

int main (){
    string n;
    cin >> n;
    if(n[0]==n[1] && n[1] == n[2]){
        cout << "Yes";
    }else if(n[1] == n[2] && n[2]==n[3]){
        cout << "Yes";
    }else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N= 3e5 + 5;
const ll mod=1e9 + 7;

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

    ll ans=0,n,m;
    cin>>n>>m;

    vector< vector<ll> > arr(m);
    vector<ll> p(m);
    for(ll i=0,k,s;i<m;i++){
        cin>>k;
        for(ll j=0;j<k;j++){
            cin>>s;
            arr[i].push_back(s-1);
        }
    }
    for(ll i=0;i<m;i++)cin>>p[i];

    for(ll k=0;k<(1ll<<n);k++){
        set<ll> on;
        ll num = k , pos=0;
        while(num){
            if(num&1)on.insert(pos);
            num>>=1;
            pos++;
        }
        bool flg=true;
        for(ll i=0;i<m;i++){
            ll cnt = 0;
            for(ll j=0;j<arr[i].size();j++)if(on.count(arr[i][j]))cnt++;
            if(cnt%2 != p[i]%2)flg=false;
        }
        if(flg)ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int x,y;
	
	while(1){
	    scanf("%d %d",&x,&y);
	    if(x==0 && y==0) break;
    	
        if(x<y){
        	printf("%d %d\n",x,y);
        } else {
            printf("%d %d\n",y,x);
        }
	}
    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, X;
    std::cin >> N >> X;

    int ans = 1;
    int sum = 0;
    REP(i, N) {
        int l;
        std::cin >> l;
        sum += l;
        if(sum <= X) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

public class Main {
    public static Node node[];
    public static String nodetype[];
 
    private static class Node{
        int id;
        int parent;
        int next_size;
        int next[];
        
        Node(int u, int k){
            this.id = u;
            this.parent = -1;
            this.next_size = k;
            this.next = new int[k];
        }
    }
    
    public static int depth(Node child){
        int cnt = 0;
        
        if (child.parent == -1)return cnt;
        
        cnt = depth(node[child.parent]) + 1;
        
        return cnt;
    }
    
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        node = new Node[n];
        nodetype = new String[n];
        
        for (int i = 0; i < n; i++){
            int u = in.nextInt();
            int k = in.nextInt();
            
            node[u] = new Node(u,k);
            
            for (int j = 0; j < k; j++){
                node[u].next[j] = in.nextInt();
            }
        }
        
        for(int i = 0; i < n; i++){
            Node head = node[i];
            for(int j = 0; j < head.next_size; j++){
                node[head.next[j]].parent = head.id;
            }
        }
        
        for(int i = 0; i < n; i++){
            Node head = node[i];
            if(node[head.id].parent == -1){
                nodetype[i] = "root";
            }else if(node[head.id].next_size > 0){
                nodetype[i] = "internal node";
            }else if(node[head.id].next_size == 0){
                nodetype[i] = "leaf";
            }
        }
        
        
        
        for(int i = 0; i < n; i++){
            Node head = node[i];
            if (nodetype[i] != "leaf"){
                System.out.print("node " + head.id + ": parent = " + head.parent + ", depth = " + depth(head) + ", "+ nodetype[i] + ", [");
                if (head.next_size == 0)System.out.println("]");
                for(int j = 0; j < head.next_size; j++){
                    if (j != head.next_size-1){
                        System.out.print(head.next[j] + ", ");
                    }else{
                        System.out.println(head.next[j] + "]");
                    }
                }
            }else if(nodetype[i] == "leaf"){
                System.out.println("node " + head.id + ": parent = " + head.parent + ", depth = " + depth(head)  + ", " + nodetype[i] + ", []");
            }

        }
      
    }  
}

Measured memory_bytes: 149536
import sys
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
cnt = 0
M = []
ans = 0
for i in range(N):
    if B[i] > A[i]:
        cnt += B[i] - A[i]
        ans += 1
    else:
        if B[i] < A[i]:
            M.append([A[i] - B[i], i])
M.sort(reverse=True)
if cnt == 0:
    print(ans)
    sys.exit(0)
for i in range(len(M)):
    cnt -= M[i][0]
    ans += 1
    if cnt <= 0:
        print(ans)
        break
else:
    print(-1)

Measured memory_bytes: 20084
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    string t;
    cin >> t;
    rep(i, t.size()) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int max_diff = 0;
    int ans = 0;
    int s = 0;
    rep(i, a.size()) {
        if (i == 0) {
            s = a[0];
            continue;
        }

        if (s >= a[i]) {
            s = a[i];
            continue;
        }

        int diff = a[i] - s;
        if (diff > max_diff) {
            max_diff = diff;
            ans = 1;
        } else if (diff == max_diff) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  int sum = 0;
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    int x = a / 400;
    if(x >= 8){
      sum++;
      continue;
    }
    mp[x]++;
  }
  //cout << mp.size() << endl;
  int m = mp.size();
  int ansmin = max(m, 1), ansmax = m + sum;
  cout << ansmin << " " << ansmax << endl;
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modoul 1000000007
#define ll long long
#define LOOP(i,a,b) for(ll i = (a); i < (b); ++i)
#define vi vector<ll>
#define whole(a) a.begin(), a.end()
int main()
{
	int n, m;cin >> n >> m;
	vi x(n), y(m);
	LOOP(i, 0, n)cin >> x[i];
	LOOP(i, 0, m)cin >> y[i];
	ll result = 0;
	sort(whole(x));sort(whole(y));
	ll first = 0, second = 0;
	for (int i = 0; i < n; ++i)	first -= x[i] * (n - 2 * i - 1);
	for (int i = 0; i < m; ++i)	second -= y[i] * (m- 2 * i - 1);
	first %= modoul;second %= modoul;
	result = first * second;
	cout << result%modoul;
	return 0;
}


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

class rest {
public:
		int point;
		char name[11];
		int num;
	};

int main() {
	int i;
	cin >> i;
	rest*ob = new rest[i];
	for (int n=0; n < i; n++) {
		ob[n].num = n + 1;
		cin >> ob[n].name >> ob[n].point;
	}

	int num=i;

	rest obtmp;

	for (int i = 1; i < num; i++) {
		for (int j = 1; j < num; j++) {
			if (strcmp(ob[j - 1].name, ob[j].name) > 0) {
				obtmp = ob[j - 1];
				ob[j - 1] = ob[j];
				ob[j] = obtmp;
			}
			else if(strcmp(ob[j - 1].name, ob[j].name) == 0) {
				if (ob[j - 1].point < ob[j].point) {
					obtmp = ob[j - 1];
					ob[j - 1] = ob[j];
					ob[j] = obtmp;
				}
			}
		}
	}
	for (int n = 0; n < i; n++) {
		cout << ob[n].num<<"\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

struct path {
    int from, to, coin;
};

signed main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<path> edge;
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        --A;
        --B;
        edge.push_back({A, B, C - P});
    }
    vector<bool> check(N, false);
    {
        vector<bool> checkS(N, false), checkE(N, false);
        checkS[0] = true;
        checkE[N - 1] = true;
        for (int i = 0; i < N; i++) {
            for (auto e : edge) {
                if (checkS[e.from]) checkS[e.to] = true;
                if (checkE[e.to]) checkE[e.from] = true;
            }
        }
        for (int i = 0; i < N; i++) check[i] = checkS[i] && checkE[i];
    }

    vector<int> ans(N, -INF);
    ans[0] = 0;
    for (int i = 0; i < N; i++) {
        for (auto e: edge) {
            if (ans[e.to] < ans[e.from] + e.coin) {
                ans[e.to] = ans[e.from] + e.coin;
                if (i == N - 1 && check[e.to] && check[e.from]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << max(0LL, ans[N - 1]) << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
set<int>ds[201010];
int main()
{
	int mx, my,num;
	scanf("%d%d%d", &mx, &my, &num);
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		ds[zb].insert(za);
	}
	for (int i = 0; i <= my; i++)ds[i].insert(mx);
	for (int i = 0; i <= mx; i++)ds[my].insert(i);
	int mini = 1000000000;
	int nx = 0;
	for (int ny = 0; ny < my; ny++)
	{
		nx++;
		int t = *(ds[ny].lower_bound(nx));
		mini = min(mini, t);
		if (t == nx)break;
		for (;;)
		{
			if (nx == mx)goto l01;
			if (ds[ny + 1].find(nx) == ds[ny + 1].end())break;
			else nx++;
		}
	}
l01:;
	printf("%d\n", mini);
}

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

 typedef long long int ll;
 typedef long long unsigned int ull;
 typedef long double ld;
 typedef vector<int> vr;
 typedef pair<int, int> pr;
 #define pb push_back
 #define ff first
 #define ss second
 #define INF 1999999999
 #define MODA 1000000007
 #define PI 3.1415926535897932384626433
 #define endl "\n"
 //cout << fixed << setprecision(2);


 int main()
 {
     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     string s;
     cin >> s;
     int len = s.size();
     string yy = "";
     yy = s[0];
     yy += s[1];
     string mm = "";
     mm = s[2];
     mm += s[3];


     int y = stoi(yy);
     int m = stoi(mm);

     if((y > 12 || y == 0) && (m >= 1 && m <= 12)){
        cout << "YYMM" << endl;
        //1905
     }
     else if((y >= 1 && y <= 12)&& (m > 12 || m == 0)){
        cout << "MMYY" << endl;
     }
     else if((y >= 1 && y <= 12)&& ( m >= 1 && m <= 12)){
        cout << "AMBIGUOUS" << endl;
        //0112
     }
     else if((y >= 1 || y <= 12) || (y >= 1 || y <= 12)){
        cout << "NA" << endl;
        //1700
     }
     return 0;
 }


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, K, a[100];
bool DP[100001];

int main() {
	cin >> N >> K;
	for (int i = 0; i != N; ++i)
		cin >> a[i];
	for (int i = K; i != -1; --i) {
		for (int j = 0; j != N&&i + a[j] <= K; ++j) {
			if (!DP[i + a[j]]) {
				DP[i] = true;
				break;
			}
		}
	}
	if (DP[0])
		cout << "First" << endl;
	else
		cout << "Second" << endl;
}

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

int main(){
    long long n, res = 0;
    cin >> n;
    long long a[n+1], b;
    for(int i=0; i<=n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b;
        if(a[i] < b){
            res += a[i];
            b -= a[i];
            if(a[i+1] < b){
                res += a[i+1];
                a[i+1] = 0;
            }else{
                res += b;
                a[i+1] -= b;
            }
        }else{
            res += b;
        }
    }
    cout << res;
    return 0;
}

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

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

    int n,k;
    cin>>n>>k;
    int mario[n];
    for(int i=0;i<n;i++){
        cin>>mario[i];
    }
    sort(mario,mario+n);
    int res=0;
    for(int j=0;j<k;j++){
        res+=mario[j];
    }
    cout<<res;

}


Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	char s[N];
	int nb[N];
	scanf("%s", s);
	int init = N;
	int count = 0;
	int num = N;
	int i = 0;
	while (s[i])
	{
		if (s[i] == 'I')
			count++;
		if (s[i] == 'D')
			count--;
		nb[i] = count;
		i++;
	}
	i = 0;
	int max = 0;
	while (i < N)
	{
		if (nb[i] > max)
			max = nb[i];
		i++;
	}
	printf("%d\n", max);
	return (0);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
#define MAX 1000000  
  bool sosu[MAX]={0};
  for(int i=4;i<MAX;i+=2)sosu[i]=true;
  for(int i=3;i<MAX;i+=2){
    if(sosu[i])continue;
    for(int j=3*i;j<MAX;j+=2*i)sosu[j]=true;
  }
  int n;
  while(cin>>n){
    int i;
    for(i=n-1;i>=2;i--)if(sosu[i]==0)break;
    cout<<i;
    for(i=n+1;i<MAX;i++)if(sosu[i]==0)break;
    cout<<" "<<i<<endl;
  }
}

Measured memory_bytes: 2144
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    vA = list(map(int, input().split()))
    MOD = 10**9 + 7
    BMAX = 61

    vC = [0,]*BMAX
    for a in vA:
        d = 0
        while a:
            vC[d] += a&1
            d += 1
            a >>= 1
    res = 0
    for i,c in enumerate(vC):
        x = pow(2,i) * c * (N-c) % MOD
        res = (res + x) % MOD
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 89712
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main() {
	
	int n;
	
	
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ARC" << endl;

	}
	return 0;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:16:30
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    if (s[0] == s[1] && s[1] == s[2] ||
        s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
 int n,m;
 cin >> n >> m;
 priority_queue<ll> pq;
 for(int i=0;i<n;i++) {
	 ll a;
	 cin >> a;
	 pq.push(a);
 }
 for(int i=0;i<m;i++) {
	 ll tmp = pq.top();
	 pq.pop();
	 pq.push(tmp/2);
 }
 ll ans=0;
 for(int i=0;i<n;i++) {
	 ans += pq.top();
	 pq.pop();
 }
 cout <<ans << endl;
}

Measured memory_bytes: 1400
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c float64
	fmt.Scan(&a, &b, &c)
	radc := c * math.Pi / 180
	h := b * math.Sin(radc)
	S := a * h / 2
	L := a + b + math.Sqrt(a*a+b*b-2*a*b*math.Cos(radc))
	fmt.Println(S)
	fmt.Println(L)
	fmt.Println(h)
}



Measured memory_bytes: 1148
#include<stdio.h>

int main()
{
   int A[100], N, i, j, minj, tmp, sw;

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

   sw = 0;

   for (i=0; i<N; i++){
      minj = i;
      for (j=i; j<N; j++){
         if (A[j]<A[minj])
            minj = j;
      }
      tmp = A[minj];
      A[minj] = A[i];
      A[i] = tmp;
      if (i!=minj)
         sw++;
   }

   for (i=0; i<N; i++){
      if (i>0)
         printf(" ");
      printf("%d", A[i]);
   }
   printf("\n");
   printf("%d\n", sw);

   return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1e9+7
#define mininf -922337203685477
#define pi acos(-1)
#define inf 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
typedef long long ll;
typedef unsigned long long ull;
int n, x;
bool vis[110];

int main(){
	fast
	cin >> x >> n;
	if(n==0){
		cout << x << '\n'; return 0;
	}
	while(n--){
		int a;
		cin >> a;
		vis[a]=1;
	}
	for(int i=0;i<=205;i++){
		if(!vis[x-i]){
			cout << x-i << '\n'; return 0;
		}
		if(!vis[x+i]){
			cout << x+i << '\n'; return 0;
		}
	}
}


Measured memory_bytes: 3616
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const N = 1001

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func lcs(x, y string) int {
	var c [N][N]int
	m := len(x)
	n := len(y)
	var maxl int

	x = " " + x
	y = " " + y

	for i := 1; i <= m; i++ {
		for j := 1; j <= n; j++ {
			if x[i] == y[j] {
				c[i][j] = c[i-1][j-1] + 1
			} else {
				c[i][j] = max(c[i-1][j], c[i][j-1])
			}
			maxl = max(maxl, c[i][j])
		}
	}
	return maxl
}

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())

	var out bytes.Buffer
	for i := 0; i < q; i++ {
		sc.Scan()
		s1 := sc.Text()
		sc.Scan()
		s2 := sc.Text()
		out.WriteString(fmt.Sprintf("%d\n", lcs(s1, s2)))
	}
	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 9132
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[20],W[100],s[10],X,Y;
   scanf("%d %d %d %d",&A,&B,&C,&D);
   if(A<B){
       printf("%d",A*C);
   }else{
    printf("%d",B*C+(A-B)*D);
   }
   return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
l=[]
for x in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l)
r=0
for x in l:
    r+=min(m,x[1])*x[0]
    m-=x[1]
    if m<=0:break
print(r)

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2000000000
#define PI 3.1415926535897932
using ll = long long;
using Graph = vector<vector<int>>;
//二項係数を求める。

int main(){
  int r; cin>>r;
  cout<<r*r<<endl;
  return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool is_prime(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
    ll X;
    cin >> X;
    FOR(i,X,1e7) {
        if (is_prime(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N;

int Main() {
    cin >> N;
    double ans = N* pi* 2;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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


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

a, b, c = (int(i) for i in input().split())  
#a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

if (a+b+c) > 21 :
    print("bust")
else:
    print("win")


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

int main(){
    int n,W;
    cin >> n >> W;
    vector<ll> w(n),v(n);
    for(int i=0;i<n;i++) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1,vector<ll>(1e5+1,1e12));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<1e5+1;j++){
            if(j-v[i]>=0){
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }else{
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }
        }
    }
    int ans=1e5;
    while(dp[n][ans]>W) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 83256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int inf = 1145141919;
struct seg
{
	vector<int> t;
	seg(int n) :t(n * 2 - 1, inf) {}
	bool add(int p, int n, int o, int l, int r)
	{
		if (l + 1 == r) {
			if (n >= t[o])
				return true;
			t[o] = n;
			return false;
		}
		int m = (l + r) / 2;
		if ((p < m ? add(p, n, o + 1, l, m) : add(p, n, o + (m - l) * 2, m, r)) || n >= t[o])
			return true;
		t[o] = n;
		return false;
	}
	int min(int a, int b, int o, int l, int r)
	{
		if (a >= b || a >= r || b <= l)
			return inf;
		if (a <= l && b >= r)
			return t[o];
		int m = (l + r) / 2;
		int p = min(a, b, o + 1, l, m);
		int q = min(a, b, o + (m - l) * 2, m, r);
		return p < q ? p : q;
	}
};

int main()
{
	int N, Q, b;
	cin >> N;
	vector<int> c(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> b;
		c[i + 1] = c[i] + b * 2 - 1;
	}
	cin >> Q;
	vector<pair<int, int>> s(Q);
	while (Q--)
		cin >> s[Q].first >> s[Q].second;
	sort(s.begin(), s.end());
	seg s0(N + 1), s1(N + 1);
	s0.add(0, (N + c[N]) / 2, 0, 0, N + 1);
	s1.add(0, (N - c[N]) / 2, 0, 0, N + 1);
	int r = 0;
	for (auto lr : s) {
		int m0 = s0.min(0, lr.first, 0, 0, N + 1) + c[lr.first - 1] - c[lr.second];
		r = lr.second;
		int m1 = s1.min(lr.first, r, 0, 0, N + 1) - c[r] + c[N];
		if (m0 > m1) m0 = m1;
		s0.add(r, m0, 0, 0, N + 1);
		s1.add(r, m0 + c[r] - c[N], 0, 0, N + 1);
	}
	cout << s0.t[0] << endl;
	return 0;
}


Measured memory_bytes: 7808
n = int(input())
l = list(map(int, input().split()))

l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != [i] and l[i] + l[j] > l[k]:
                ans += 1
print(ans)


Measured memory_bytes: 73720
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let n = scan "%d" id
let ax = scan_list ~sep:' ' int_of_string

let () =
  let cap = 1000000000000000000 in
  ax
  |> List.fold_left (fun a b ->
      if a= 0 || b = 0 then 0
      else if a = (-1) || b > cap/a then (-1)
      else a*b) 1
  |> Printf.printf "%d\n"


Measured memory_bytes: 17088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}
string s;
ll d;
ll memo[10'050][2][101];
ll md = 1000000000+7;

ll dp(ll at, ll same, ll sum) {
    if(at >= s.size()) {
        return sum == 0;
    }
    if(memo[at][same][sum] != -1) {
        return memo[at][same][sum];
    }
    ll cnt = 0;
    if(!same) {
        rep(i,0,10) {
            cnt += dp(at+1, same, (sum+i)%d);
            cnt %= md;
        }
    } else {
        rep(i,0,s[at]-'0'+1) {
            cnt += dp(at+1, i == s[at]-'0', (sum+i)%d);
            cnt %= md;
        }
    }
    return memo[at][same][sum] = cnt;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> s >> d;
    cout << (dp(0,1,0)-1+md)%md << endl;
    return 0;
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
int  N, K, A[200005], dp[200005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 0; i < K; i++)
	{
		cin >> A[i];
		dp[K - 1] += A[i];
	}
	for (int i = K; i < N; i++)
	{
		cin >> A[i];
		dp[i] = dp[i - 1] + A[i] - A[i - K];
	}
	printf("%.6lf\n", 1.0 * (*max_element(dp + K - 1, dp + N) + K) / 2);
	return 0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
hs = list(map(int, input().split()))

costs = [999999999999999999] * N
costs[0] = 0
for i in range(N-1):
    for j in range(i, min(N, i+K+1)):
        costs[j] = min(costs[j],
                       costs[i]+abs(hs[j]-hs[i]))
print(costs[-1])

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N, M;
  cin >> N;
  int X[N];
  for(int i = 0; i < N; i++){
    cin >> X[i];
  }
  cin >> M;
  int A[M];
  for(int i = 0; i < M; i++){
    cin >> A[i];
    A[i]--;
  }
  int m[2020] = {};
  for(int i = 0; i < N; i++){
    m[X[i]] = 1;
  }
  for(int i = 0; i < M; i++){
    if(X[A[i]] == 2019) continue;
    if(m[X[A[i]] + 1] == 0){
      m[X[A[i]] + 1] = 1;
      m[X[A[i]]] = 0;
      X[A[i]]++;
    }
  }
  for(int i = 1; i < 2020; i++){
    if(m[i] == 1){
      cout << i << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
ll d[1001001];
ll l[1001001];
int main(){
    int n; cin >> n;
    rep(i,n){
        cin >> l[i];
        rep(j,l[i]+1){
            d[j]++;
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int a = l[i]-l[j];
            int b = l[i]+l[j];
            if(a<0) a=-a;
            if(a<b){
                ans += d[max(a+1,0)];
                ans -= d[b];
                if(a<l[i]) ans--;
                if(a<l[j]) ans--;
            }
        }
    }
    cout << ans/3 << endl;
}


Measured memory_bytes: 2304
n=int(input())
a=[]
for i in range(n):
   a.append(input())
a.sort()
d={}
for i in range(n):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
all_values=d.values()
m=max(all_values)
l=[]
for i in d:
    if d[i]==m:
        l.append(i)
l.sort()
for i in l:
    print(i)

Measured memory_bytes: 35208
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int[] players = new int[n];
        Arrays.fill(players,k-q);
        //System.out.println(k-q);

        for(int i=0;i<q;i++){
            int temp = sc.nextInt();
            players[temp-1] = players[temp-1] + 1;
        }

        for(int i=0; i<n; i++){
            if(players[i] >0){

                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }



    }
}

Measured memory_bytes: 53916
s = list(input()) #sys.stdin.readlineは最後が改行
t = list(input()) #sys.stdin.readlineは最後が改行
ls=len(s)

from collections import defaultdict
d = defaultdict(list)

from bisect import bisect_right

for i in range(ls):
    d[s[i]].append(i+1)

ans = 0
prev =0
for i in range(len(t)):
    index = d[t[i]]
    if len(index)==0:
        print(-1)
        exit()
    elif len(index)==1:

        if index[0] <= prev:
            ans+=(ls-prev)+index[0]
        else:
            ans+=index[0]-prev
        prev = index[0]
    else:
        nex = bisect_right(index, prev)
        if nex == len(index):
            ans += (ls-prev)+index[0]
            prev = index[0]
        else:
            ans+= index[nex]-prev
            prev = index[nex]

print(ans)


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

using namespace std;

typedef long long ll;

const int MOD = int(1e9+7);

int main()
{
	int x;
	cin >> x;
	
	ll ans = x/500*1000;
	x= x % 500;
	ans+=x-x%5;
	cout << ans;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val ans = (N + 1) / 2
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


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

int main()
{
    string s,t;
    cin>>s>>t;
    int n,m;
    cin>>n>>m;
    string f;
    cin>>f;
    
    if(f==s){
        n--;
    }
    else m--;
    cout<<n<<" "<<m<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char **argv)
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int id[4] = {0};
		int time[4] = {25600, 25600, -1, -1};
		for (int i = 0; i < n; ++i)
		{
			int s;
			scanf("%d", &s);
			int t = 0;
			for (int j = 0; j < 4; ++j)
			{
				int min, sec;
				scanf("%d%d", &min, &sec);
				t += min * 60 + sec;
			}

			if (t < time[0])
			{
				time[1] = time[0];
				time[0] = t;
				id[1] = id[0];
				id[0] = s;
			}
			else if (t < time[1])
			{
				time[1] = t;
				id[1] = s;
			}

			if (t > time[3])
			{
				time[2] = time[3];
				time[3] = t;
				id[2] = id[3];
				id[3] = s;
			}
			else if (t > time[2])
			{
				time[2] = t;
				id[2] = s;
			}
		}

		printf("%d\n", id[0]);
		printf("%d\n", id[1]);
		printf("%d\n", id[2]);
	}

	return 0;
}


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

#define int long long

signed main(){
	int a[10][10];

	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			cin >> a[i][j];
		}
	}

	int n;
	cin >> n;

	for(int i = 0;i < n;i++){
		int b;
		cin >> b;
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 3;j++){
				if(a[i][j] == b){
					a[i][j] = 0;
				}
			}
		}
	}

	bool ans = false;
	for(int i = 0;i < 3;i++){
		ans = (ans || a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0);
	}

	for(int i = 0;i < 3;i++){
		ans = (ans || a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0);
	}

	ans = (ans || a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0);
	ans = (ans || a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0);

	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
s = input()
a = int(s[0:2])
b = int(s[2:4])

if a >= 1 and a <= 12:
    if b >= 1 and b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b == 0 or b > 12:
        print('NA')
    else:
        print('YYMM')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 250

int H[MAX+1];

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

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

  for(int i=1;i<=n;i++){
    cout<<"node "<<i<<": key = "<<H[i]<<", ";
    if(parent(i)!=0){
      printf("parent key = %d, ",H[parent(i)] );
    }
    if(left(i)<=n){
      printf("left key = %d, ",H[left(i)]);
    }
    if(right(i)<=n){
      printf("right key = %d, ",H[right(i)]);
    }
    cout<<endl;
  }
}


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

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

string s;
signed main()
{
    int cnt = 0;
    cin >> s;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i]=='?') s[i]='D';
    }
    cout << s;
    /*for(int i = 0; i < s.length(); i++)
    {
        if(i < s.length()-1 && s[i]=='P' && s[i+1]=='D') cnt++;
        if(s[i]=='D') cnt++;
    }
    cout << cnt;*/

}

Measured memory_bytes: 3696
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int A, B, C;  cin >> A >> B >> C;
  int ans = C - (A - B);
  ans = ans>0?ans : 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256