akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
	static FastScanner stdIn=new FastScanner();
	public static void main(String[] args) {
		String S=stdIn.next();
		int N=S.length(),K=0;
		long ans=0;
		for(int i=0;i<Math.pow(2,N-1);i++){
			K=i;
			String a=S.substring(0,0+1);
			for(int j=1;j<N;j++){
				if(K%2==1){
					ans+=Long.valueOf(a);
					a="";
				}
				if(K!=0)
					K/=2;
				a+=S.substring(j,j+1);
			}
			ans+=Long.valueOf(a);a="";
		}
		System.out.println(ans);
	}
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
string s;
char d[111111];
char cs[]={'S','W'};

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	cin>>s;
	rep(hoge,4){
		d[0]=cs[hoge/2];
		d[1]=cs[hoge%2];
		repl(i,1,n-1){
			if(d[i]=='S'&&s[i]=='o'){
				d[i+1]=d[i-1];
			}else if(d[i]=='S'&&s[i]=='x'){
				d[i+1]=d[i-1]=='S'?'W':'S';
			}else if(d[i]=='W'&&s[i]=='o'){
				d[i+1]=d[i-1]=='S'?'W':'S';
			}else if(d[i]=='W'&&s[i]=='x'){
				d[i+1]=d[i-1];
			}
		}
		bool ok=true;
		if(s[0]=='o'){
			if((d[0]=='S'&&d[n-1]!=d[1])||(d[0]=='W'&&d[n-1]==d[1])){
				ok=false;
			}
		}
		if(s[0]=='x'){
			if((d[0]=='W'&&d[n-1]!=d[1])||(d[0]=='S'&&d[n-1]==d[1])){
				ok=false;
			}
		}
		if(s[n-1]=='o'){
			if((d[n-1]=='S'&&d[n-2]!=d[0])||(d[n-1]=='W'&&d[n-2]==d[0])){
				ok=false;
			}
		}
		if(s[n-1]=='x'){
			if((d[n-1]=='W'&&d[n-2]!=d[0])||(d[n-1]=='S'&&d[n-2]==d[0])){
				ok=false;
			}
		}
		if(ok){
			d[n]=0;
			printf("%s\n", d);
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	ll x;
	cin >> x;

	ll sum = 0;
	for(ll i = 1;;i++){
		sum += i;
		if(sum >= x){
			cout << i << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2E4+5;
int n,m,a[105][105],b[105][105],c[105][105];
namespace flow
{
	int size,head[maxn];
	int S,T,dfn[maxn];
	struct edge
	{
		int to,next,w,id;
	}E[maxn*2];
	inline void addE(int u,int v,int w,int id)
	{
		E[++size].to=v;
		E[size].next=head[u];
		E[size].w=w;
		E[size].id=id;
		head[u]=size;
	}
	inline void add(int u,int v,int w,int id)
	{
		addE(u,v,w,id);
		addE(v,u,0,id);
	}
	inline void clear()
	{
		memset(head,0,sizeof(head));
		memset(E,0,sizeof(E));
		size=1;
	}
	inline bool bfs()
	{
		for(int i=0;i<=T;++i)
			dfn[i]=-1;
		queue<int>Q;
		Q.push(S);
		dfn[S]=0;
		while(!Q.empty())
		{
			int u=Q.front();
			Q.pop();
			for(int i=head[u];i;i=E[i].next)
			{
				int v=E[i].to;
				if(E[i].w==0||dfn[v]!=-1)
					continue;
				dfn[v]=dfn[u]+1;
				Q.push(v);
			}
		}
		return dfn[T]!=-1;
	}
	int dfs(int u,int up)
	{
		if(u==T)
			return up;
		int s=0;
		for(int i=head[u];i;i=E[i].next)
		{
			int v=E[i].to;
			if(dfn[v]!=dfn[u]+1||E[i].w==0)
				continue;
			int g=dfs(v,min(E[i].w,up-s));
			E[i].w-=g;
			E[i^1].w+=g;
			s+=g;
			if(g==0)
				dfn[v]=-1;
			if(s==up)
				break;
		}
		return s;
	}
	inline void solve()
	{
		int s=0;
		while(bfs())
			s+=dfs(S,123456);
		assert(s==n);
	}
}
inline int get(int x)
{
	return (x-1)/m+1;
}
bool used[105*105];
inline void solve()
{
	for(int e=1;e<=m;++e)
	{
		flow::clear();
		flow::S=0;
		flow::T=2*n+1;
		for(int i=1;i<=n;++i)
			for(int j=1;j<=m;++j)
				if(!used[a[i][j]])
					flow::add(i,n+get(a[i][j]),1,a[i][j]);
		for(int i=1;i<=n;++i)
			flow::add(0,i,1,0),flow::add(i+n,2*n+1,1,0);
		flow::solve();
		using namespace flow;
		for(int u=1;u<=n;++u)
			for(int i=head[u];i;i=E[i].next)
				if(E[i].w==0)
				{
					used[E[i].id]=1;
					b[u][e]=E[i].id;
					c[get(E[i].id)][e]=E[i].id;
				}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	solve();
	for(int i=1;i<=n;++i,cout<<endl)
		for(int j=1;j<=m;++j)
			cout<<b[i][j]<<" ";
	for(int i=1;i<=n;++i,cout<<endl)
		for(int j=1;j<=m;++j)
			cout<<c[i][j]<<" ";
	return 0;
}


Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <cassert>

static const int MOD = 998244353;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <ll M = MOD> struct modint {
    ll val;
    modint(const ll x = 0) : val(x) {
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
    }

    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint operator/(const modint a) const { return modint(*this) /= a; }
    modint operator-() const { return modint(M-val); }
    modint inv() const {
        ll u = 1, v = 0, s = 0, t = 1, m = M, x = val;
        while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
        if(s < 0) s += M;
        return modint(s);
    }
    modint pow(ll n) const {
        ll u = 1, xx = val;
        while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; }
        return modint(u);
    }
    modint& operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; }
    modint& operator-=(const modint a){ val -= a.val; if(val < 0) val += M; return *this; }
    modint& operator*=(const modint a){ val = val * a.val % M; return *this; }
    modint& operator/=(const modint a){ val = val * a.inv().val % M; return *this;}

    modint& operator=(const int& x){
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
        return *this;
    }
};

using mint = modint<MOD>;

template<class T>
vector<T> divisor(T n){
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main() {
    ll n; string s;
    cin >> n >> s;
    mint ans = 0, k = 1;
    auto d = divisor(n);
    map<int, mint> m;
    reverse(d.begin(),d.end());
    for (auto &&x : d) {
        if(!(x & 1)) continue;
        int y = n/x;
        string A = s.substr(0, y);
        string B = A;
        for (auto &&j : B) {
            j = (j == '1' ? '0' : '1');
        }
        mint p = 1; k = 1;
        for (ll i = y-1; i >= 0; --i) {
            if(s[i] == '1') p += k;
            k *= mint(2);
        }
        int ok = 1;
        for (ll i = 1; i < x; ++i) {
            auto X = s.substr(i*y, y);
            if(i & 1) {
                if(B > X) ok = 0;
                if(B < X) break;
            }else {
                if(A > X) ok = 0;
                if(A < X) break;
            }
        }
        if(!ok) p -= 1;
        for (auto &&l : m) {
            if((l.first) % x == 0) p -= l.second;
        }
        m[x] = p;
    }
    for (auto &&l : m) {
        ans += l.second*mint(2*(n/l.first));
    }
    cout << ans.val << "\n";
    return 0;
}

Measured memory_bytes: 956
N = int(input())
A = [0 for i in range(N)]
a = 1
X = 0
while 1:
  X += (a + a - 1)
  if X > N:
    break
  Y = X
  b = 1
  while 1:
    Y += (a + b + b - 1)
    if Y > N:
      break
    Z = Y
    c = 1
    while 1:
      Z += (a + b + c + c - 1)
      if Z <= N:
        A[Z-1] += 1
      else:
        break
      c += 1
    b += 1
  a += 1
for a in A:
  print(a)

Measured memory_bytes: 68700
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {

	string a, b;
	cin >> a >> b;

	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())

    Q = []
    for _ in range(N):
        a, b = map(int, input().split())
        Q.append([b, a])
    heapq.heapify(Q)

    t = 0
    while len(Q)!=0:
        b, a = heapq.heappop(Q)
        t += a
        if t>b:
            print('No')
            return
    print('Yes')

 
if __name__ == '__main__':
    main()


Measured memory_bytes: 34868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	vector<int> deg(n);
	iota(all(deg), 0);
	double res = 0.0;
	do {
		double tmp = 0.0;
		rep(i, n - 1) {
			tmp += sqrt((x[deg[i]] - x[deg[i + 1]]) * (x[deg[i]] - x[deg[i + 1]]) + (y[deg[i]] - y[deg[i + 1]]) * (y[deg[i]] - y[deg[i + 1]]));
		}
		res += tmp;
	} while (next_permutation(all(deg)));
	double fact = 1;
	rep(i, n) fact *= (i + 1);
	printf("%.10f", res / (double)fact);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int i = Integer.parseInt(sa[0]);
		int o = Integer.parseInt(sa[1]);
		int j = Integer.parseInt(sa[3]);
		int l = Integer.parseInt(sa[4]);
		br.close();

		long ans = o;
		if ((j % 2 == 1 && l % 2 == 1 && i > 0)
				|| ((j % 2 == 1 || l % 2 == 1) && j > 0 && l > 0 && i % 2 == 1)) {
			ans += 3;
			i--;
			j--;
			l--;
		}
		ans += i / 2 * 2;
		ans += j / 2 * 2;
		ans += l / 2 * 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
import std.stdio; // ??\????????????????????????
import std.string; // chomp????????????????????????(?????????????????????)
import std.conv; // to????????????????????????
import std.array; // split?????????????????????
import std.algorithm; // map?????????????????????

void main() {
    auto input = readln.split.map!(to!int);
    int a = input[0];
    int b = input[1];
    int c = input[2];

    int cnt = 0;

    foreach (i; a .. (b + 1)) {
        if (c % i == 0) {
            cnt++;
        }
    }

    writeln(cnt);
}

Measured memory_bytes: 2412
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 500010
using namespace std;
typedef long long ll;
ll l,r,ans;
int i,j,k;
int main(){
//	l=rand()%57+1,r=rand()%57+1;
//	while(l>=r-1)l=rand()%57+1,r=rand()%57+1;
	cin>>l>>r;
//	cout<<l<<" "<<r<<" ";
	if(r-l<=0)return cout<<r-l+1,0;
/*	for(i=l;i<=r;i++)f[i]=1;
	for(i=0;i<=(r<<1);i++)if(f[i])for(j=l;j<=r;j++)f[i|j]=1;
	for(i=0;i<=1000000;i++)if(f[i])cnt++,cout<<i<<" ";puts("");
	cout<<cnt<<" ";*/
//	ans=r-l+1;
	for(i=61;~i;i--)if(((r>>i)&1)^((l>>i)&1))break;else l&=~(1ll<<i),r&=~(1ll<<i);
	ans+=(1ll<<i)-l;
	// l~2^i 
	for(j=i-1;~j;j--)if(r&(1ll<<j))break;
//	cout<<"   "<<i<<" "<<j<<"    ";
//	ans+=(1<<j+1)+(1<<j+1)*((1<<i-j-1)-l-1)+
	// 2^i~r : 100000000~100011111
	// l~r :   110101010~111111111
	ans+=1ll<<i;
	ans-=max(0ll,(1ll<<i)+l-((1ll<<i)+(1ll<<j+1)-1)-1);
	cout<<ans;
/*	if(cnt^ans){
		cout<<cnt<<" "<<ans<<endl;
		for(int i=200000000;i;i--);
	}
	else puts("");*/
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N, K, C;
int scheduling(string X, vector<ll>& vec){
    int last = -1000;
    int idx = 0;
    REP(i,N){
        if(idx == K) break;
        char c = X[i];
        if(c == 'o' && i - last > C){
            vec[i] = idx++;
            last = i;
        }
        else
            vec[i] = -1;
    }

    return idx;
}

int main(){
    cin >> N >> K >> C;
    string S;
    cin >> S;

    //vector<ll> asap(N, 1e8);
    //vector<ll> alap(N, 1e10);
    vector<ll> asap(N, -1);
    vector<ll> alap(N, -1);

    int total;
    total = scheduling(S, asap);
    reverse(S.begin(), S.end());
    scheduling(S, alap);
    reverse(alap.begin(), alap.end());

    for(auto&& x : alap){
        if(x == -1) continue;
        x = total - x - 1;
    }


    //REP(i,N)
    //    printf("%+lld, ", asap[i]);
    //printf("\n");

    //REP(i,N)
    //    printf("%+lld, ", alap[i]);
    //printf("\n");

    REP(i,N){
        if(asap[i] == -1) continue;
        if(alap[i] == -1) continue;
        if(asap[i] == alap[i])
            cout << i+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5056
#include <iostream>

using namespace std;

int main()
{
    string word;
    cin>> word;
    for(int i = 0 ; i < 5 ; i++)
    {
        cout<<word[i];
    }
        cout<<" ";
    for(int i = 6 ; i < 13; i ++)
    {
        cout<<word[i];
    }
        cout<<" ";
    for(int i = 14 ; i < 19 ; i ++)
    {
        cout<<word[i];
    }

    return 0;
}


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

using namespace std;
const int N = 2e3 + 10;
const int MOD = 1e9 + 7;

int n, m, d[N], s[N], t[N];
void make_sum (int&, int);

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < m; i++)
		cin >> t[i];

	int ans = 1;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			int backup = d[j];
			if (s[i] == t[j]) {
				make_sum (d[j], sum + 1);
				make_sum (ans, sum + 1);
			}
			make_sum (sum, backup);
		}
	}
	cout << ans << endl;
}

void make_sum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//自作関数 a^n mod MODを求める
int m_pow(int a, int n){
  if(n == 0) return 1;
  if(n % 2 == 0){
    int t = m_pow(a, n / 2);
    return t * t % MOD;
  }
  return a * m_pow(a, n - 1) % MOD;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

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

  vec s(m),c(m);

  REP(i,m) {
    cin >> s[i] >> c[i];
    s[i]--;
  }

  vec memo(n,-1);

  REP(i,m){
    if((memo[s[i]] != -1 && memo[s[i]] != c[i]) || (n != 1 && s[i] == 0 && c[i] == 0)) {
      cout << -1 << endl;
      return 0;
    }
    else{
      memo[s[i]] = c[i];
    }
  }

  if(memo[0] == -1) {
    memo[0] = 1;
    if(n == 1) memo[0] = 0;
  }

  int ret = 0;
  RREP(i,n){
    if(memo[i] != -1) ret += memo[i] * pow(10, (n - i));
  }

  cout << ret / 10 << endl;

  return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) {
    val scan = new java.util.Scanner(System.in)
    val n  = scan.next.toInt
    val ts = (1 to n).toList.map(_ => BigInt(scan.next))
    println(ts.reduceLeft((a,b) => lcm(a,b)))
  }

  def gcd(a: BigInt, b: BigInt): BigInt = if (b == 0) a else gcd(b, a % b)
  def lcm(a: BigInt, b: BigInt): BigInt = a * b / gcd(a, b)
}

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

int main() {
  double left,right;
  int L[4]={},R[4]={};
  while(cin >> left >> right) {
    if(left >= 1.1) L[0]++;
    else if(left >=0.6) L[1]++;
    else if(left >= 0.2) L[2]++;
    else L[3]++;
    if(right >= 1.1) R[0]++;
    else if(right >= 0.6) R[1]++;
    else if(right >= 0.2) R[2]++;
    else R[3]++;
  }
  for(int i=0;i<4;i++) {
    cout << L[i] << " " << R[i] << endl;
  }
}

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

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

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

    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            for(int k = j + 1; k < n; k++){
                if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int d,g;
int p[12],c[12];

int main(){
	cin>>d>>g;
	REP(i,d)
		cin>>p[i]>>c[i];
	int ans=INF;
	for(int i=0;i<(1<<d);i++){
		int t=0;
		int s=100;
		int tans=0;
		for(int j=0;j<d;j++){
			if(i>>j&1){
				t+=(j+1)*100*p[j];
				t+=c[j];
				tans+=p[j];
			}else{
				s=j;
			}
		}
		if(t>=g){
			ans=min(ans,tans);
			continue;
		}else if(s==100){
			continue;
		}else{
			int ut=((g-t)+((s+1)*100)-1)/((s+1)*100);
			if(ut>=p[s])continue;
			tans+=ut;
		}
		ans=min(ans,tans);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

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

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n, k; cin >> n >> k;
    vll l(k), r(k);
    rep(i, k){
        cin >> l[i] >> r[i];
    }

    ll mod = 998244353;
    vll dp(n+1), sum(n+1);
    dp[1] = 1;
    sum[1] = 1;
    rep2(i, 2, n+1){
        rep(j, k){
            ll li = i-r[j];
            ll ri = i-l[j];
            if(ri<0) continue;
            li = max(li, 1LL);
            dp[i] += sum[ri]-sum[li-1];
            dp[i] %= mod;
        }
        sum[i] = sum[i-1] + dp[i];
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 6412
a=[int(i) for i in input().split()]
k=a[2]
if(a[0]<=k):
    k-=a[0]
    a[0]=0
else:
    a[0]-=k
    k=0
if(k>0):
    if(a[1]>k):
        a[1]-=k
    else:
        a[1]=0
print(a[0],a[1])


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d4x[4] = {0,1,0,-1};
int d4y[4] = {1,0,-1,0};

int main(){
	while(true){
		int maze[70][70] = {0};
		int ans[70][70] = {0};
		int H,W;
		cin>>W>>H;
		if(H==0 && W==0)break;
		REP(i,2*H-1){
			REP(j,2*W-1){
				ans[i][j] = inf;
			}
		}
		REP(i,2*H-1){
			if(i%2==1){
				REP(j,W-1){
					int in;
					cin>>in;
					if(in == 1){
						maze[i][j*2] = 1;
						maze[i+1][j*2] = 1;
						maze[i-1][j*2] = 1;
					}
				}
			}else{
				REP(j,W){
					int in;
					cin>>in;
					if(in==1){
						maze[i][2*j-1] = 1;
						maze[i][2*j] = 1;
						maze[i][2*(j-1)] = 1;
					}
				}
			}
		}
		queue<ip> Q;
		Q.push(make_pair(1, 1));
		ans[1][1] = 1;
		while(!Q.empty()){
			int y = Q.front().first, x = Q.front().second;
			Q.pop();
			rep(i,4){
				int dy = y + d4y[i], dx = x + d4x[i];
				if(1<=dy && dy<=2*H-1 && 1<=dx && dx<=2*W-1 && ans[dy][dx] == inf && maze[dy][dx] == 0){
					if(dy*dx%2 == 0){
						ans[dy][dx] = ans[y][x];
					}else{
						ans[dy][dx] = ans[y][x] + 1;
					}
					Q.push(make_pair(dy, dx));
				}
			}
		}

		int res = ans[2*H-1][2*W-1];
		if(res==inf)cout<<0<<endl;
		else cout<<res<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3040
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int MAX_N = 36; // ?????????????????°????????§???

int N;              // ?????????????????°
char card[2];       // ??????????????\????????????????????????????????????1?????????????????????2??????????????°???
char suits[MAX_N];  // ????????????????????????????????????????????????
int numbers[MAX_N]; // ??????????????°?????????????????????????????????

bool isStable(int N,int in_n[],int out_n[],char in_c[],char out_c[]){
	int i,j,a,b;
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			for(a=0;a<N;a++){
				for(b=a+1;b<N;b++){
					if(in_n[i] == in_n[j] && in_n[i] == out_n[b] && in_n[j] == out_n[a] && in_c[i] == out_c[b] && in_c[j] == out_c[a]) return false;
				}
			}
		}
	}
	return true;
}

void output(int N, char suits[], int numbers[]){
	int i;
	for(i=0;i<N;i++){
		printf("%c%d",suits[i],numbers[i]);
		if(i!=N-1) printf(" ");
		else if(i==N-1) printf("\n");
	}
}

void BubbleSort(int N, char suits_bubble[],int numbers_bubble[]){
	int i,j;
	for(i=0;i<N;i++){
		for(j=N-1;j>i;j--){
			if(numbers_bubble[j] < numbers_bubble[j-1]){
				swap(numbers_bubble[j],numbers_bubble[j-1]);
				swap(suits_bubble[j],suits_bubble[j-1]);
			}
		}
	}
	output(N,suits_bubble,numbers_bubble);
	if(isStable(N,numbers,numbers_bubble,suits,suits_bubble)) printf("Stable\n");
	else printf("Not stable\n");
}

void SelectionSort(int N, char suits_selection[], int numbers_selection[]){
	int i,j;
	int minj;
	for(i=0;i<N;i++){
		minj = i;
		for(j=i;j<=N-1;j++){
			if(numbers_selection[j] < numbers_selection[minj])
				minj = j;
		}
		swap(numbers_selection[i],numbers_selection[minj]);
		swap(suits_selection[i],suits_selection[minj]);
	}
	output(N,suits_selection,numbers_selection);
	if(isStable(N,numbers,numbers_selection,suits,suits_selection)) printf("Stable\n");
	else printf("Not stable\n");
}

int main(){
	int i,j;
	char suits_bubble[MAX_N],suits_selection[MAX_N];
	int numbers_bubble[MAX_N],numbers_selection[MAX_N];

	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%s",card);
		suits[i] = card[0];
		suits_bubble[i] = card[0];
       		suits_selection[i] = card[0];	// ??\??????1??????????????\????????????
		numbers[i] = card[1]-'0';
		numbers_bubble[i] = card[1]-'0';
	        numbers_selection[i] = card[1]-'0';	// ??\??????2??????????????£??\?????????
	}

	BubbleSort(N,suits_bubble,numbers_bubble);
	SelectionSort(N,suits_selection,numbers_selection);

	return 0;
}

Measured memory_bytes: 2672
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
  int N,X,Y,i,j,r;
  cin >> N >> X >> Y;
  
  int count[N];
  for( i=0 ; i<N ; i++ )count[i] = 0;
  for( i=1 ; i<N ; i++ ){
    for( j=i+1 ; j<(N+1) ; j++ ){
      r = j-i;
      if( r > (abs(i-X)+abs(j-Y)+1))r = (abs(i-X)+abs(j-Y)+1);
      count[r]++;
    }
  }
  
  for( i=1 ; i<N ; i++ )cout << count[i] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n,x;
  cin  >> n >> x;
  vi m(n);
  int total=0;
  REP(i,n) {
    cin >> m[i];
    total+=m[i];
  }
  int ans=n;
  x-=total;
  sort(ALL(m));
  ans+=x/m[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N];
int main()
{
    scanf("%s",s+1);
    bool flag=true;
    for(int i=1;s[i];i++)
        if(i&1)
    {
        if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') flag=false;
    }
    else
    {
        if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') flag=false;
    }
    printf(flag?"Yes":"No");
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = 0
for i in range(n - 1):
    res += B[i]
    if A[i] + 1 == A[i + 1]:
        res += C[A[i] - 1]
print(res + B[-1])


Measured memory_bytes: 9108
#!/usr/bin/env python3
# coding: utf-8
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    K, A, B = map(int, open(0).read().split())
    a = 'NG'
    for i in range(A, B + 1):
        if i % K == 0:
            a = 'OK'
    print(a)
if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <iostream>
#include <vector>

int main(){
    std::vector<std::string> players(3);
    for(int i = 0; i < 3; ++i){
        std::cin >> players.at(i);
    }

    int i = 0;
    int j;
    while(!players.at(i).empty()){
        j = (int)players.at(i).at(0) - 97;
        players.at(i).erase(players.at(i).begin());
        i = j;
    }

    std::cout << (char)(i + 65) << std::endl;
}


Measured memory_bytes: 888
N, M = list(map(int, input().split()))

C = [[0]*3 for i in range(N)]
for i in range(N):
    x, y, z = list(map(int, input().split()))
    C[i][0] = x
    C[i][1] = y
    C[i][2] = z

#0なら負、1なら正
def calc(pn_x,pn_y,pn_z):
    L = [0]*N
    for i in range(N):
        x= C[i][0] if pn_x else (-1)*C[i][0]
        y= C[i][1] if pn_y else (-1)*C[i][1]
        z= C[i][2] if pn_z else (-1)*C[i][2]
        L[i] = x + y + z

    L = sorted(L, reverse=True)
    return sum(L[:M])


ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = max(ans,calc(i,j,k))

print(ans)

            

Measured memory_bytes: 3316
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		int T = sc.nextInt();
		
		int[] t = new int[T+1];
		for(int i=0; i<N; i++) {
			t[sc.nextInt()]++;
			t[sc.nextInt()]--;
		}
		
		int max = t[0];
		for(int i=1; i<=T; i++) {
			t[i] = t[i] + t[i-1];
			if(t[i] > max) {
				max = t[i];
			}
		}
		
		System.out.println(max);
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 53332
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))
    for i in range(n):
        al[i] -= 1
    bl = list(map(int, input().split()))
    cl = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        ans += bl[al[i]]
        if i > 0:
            if al[i-1] + 1 == al[i]:
                ans += cl[al[i-1]]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38472
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int n, k; readf("%d %d\n", &n,&k);
    int[] h = new int[n];
    foreach (ref hi ; h)
        hi = read();
    h.sort();

    int minh = 1145141919;
    foreach (i; 0 .. n - k + 1)
        minh = min(minh, h[i + k - 1] - h[i]);
    writeln(minh);
}


Measured memory_bytes: 1660
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
       
       int tree[200001];
        void update(int node, int start, int end, int idx, int val)
{
    if(start == end)
    {
        // Leaf node
        
        tree[node] += val;
    }
    else
    {
        int mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            
            update(2*node, start, mid, idx, val);
        }
        else
        {
             update(2*node+1, mid+1, end, idx, val);
        }
        
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
int query(int node, int start, int end, int l, int r)
{
    if(r < start or end < l)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if(l <= start and end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int p1 = query(2*node, start, mid, l, r);
    int p2 = query(2*node+1, mid+1, end, l, r);
    return (p1 + p2);
}
        
        int32_t main()
        {
            IOS
           
          
        
        int n;
        cin>>n;
        int a[n];
        memset(tree,0,sizeof(tree));
        for(int i=0;i<n;++i)
            cin>>a[i],update(1,1,2000,a[i],1);
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<n;++i)
        {
            update(1,1,2000,a[i],-1);
            for(int j=i+1;j<n;++j)
            {
                
                update(1,1,2000,a[j],-1);
                ans+=query(1,1,2000,max(a[j]-a[i]+1,(ll)0),a[i]+a[j]-1);
                
                update(1,1,2000,a[j],+1);
            }
            update(1,1,2000,a[i],+1);
        }

        cout<<ans/3<<endl;


        }


Measured memory_bytes: 1920
#include <iostream>
#include <string>
using namespace std;
typedef signed long long ll;
char grid[100][100];
bool goodr[107], goodc[107];
int main() {
	int r, c; cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> grid[i][j];
		}
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (grid[i][j] == '#') {
				goodr[i] = true;
				goodc[j] = true;
			}
		}
	}
	for (int i = 0; i < r; i++) {
		if (goodr[i]) {
			for (int j = 0; j < c; j++) {
				if (goodc[j]) {
					cout << grid[i][j];
				}
			}
			cout << endl;
		}
	}
	
	 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s; int c[26];
int main() {
	cin >> s;
	for(int i = 0; i < s.size(); i++) c[s[i] - 97]++;
	bool f = true;
	for(int i = 0; i < 26; i++) if(c[i] % 2 == 1) f = false;
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX 1000

int main(){
    int n;
    int i, j=0, sum;
    int score[MAX];
    double ave, tmp;
    double dev[MAX];

    while(1){
        scanf("%d", &n);
        if(n==0)break;
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d", &score[i]);
            sum+=score[i];
        }
        ave=(double)sum/(double)n;
        tmp=0.0;
        for(i=0;i<n;i++){
            tmp+=pow(score[i]-ave, 2);
        }
        dev[j++]=sqrt(tmp/(double)n);
    }
    for(i=0;i<j;i++){
        printf("%f\n", dev[i]);
    }
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && c!=a)cout<<"Yes";
  else if(a==c && b!=a)cout<<"Yes";
  else if(b==c && a!=b)cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 1; i < (n); ++i )
typedef std::pair<int,int> pint;

using namespace std;
typedef long long ll;

int main(){
    int N; cin >> N;
    string str; cin >> str;
    string ans;
    char tmp;
    tmp = str[0];
    ans[0] = tmp;
    //cout << ans[0] << endl;
    rep (i,str.length()){
        if (str[i] == tmp){
            continue;
        }
        else{
            tmp = str[i];
            ans += tmp;
        }
    }
    //cout << ans << endl;
    cout << ans.length() + 1 << endl; 
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>

using namespace std;
void printArray(int* A, int n)
{
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
int main()
{
    
    int n;
    cin >> n;
    int* A = new int[n];
    for(int i = n-1; i >= 0; i--){
        cin >> A[i];
    }
    printArray(A, n);
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,i,j,z;
  cin>>h>>w>>n;
  vector<int> c;
  for(i=1;i<=n;i++){
    cin>>z;
    for(j=0;j<z;j++) c.push_back(i);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(j>0) cout<<' ';
      if(i%2==0) cout<<c.at(w*i+j);
      else if(i%2==1) cout<<c.at(w*i+w-1-j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3608
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);

$x = $m = 0;
$a = ['I'=>1, 'D'=>-1];
for ($i = 0; $i < $n; $i++) {
	$x += $a[$s[$i]];
	if ($m < $x) $m = $x;
}
echo $m;

Measured memory_bytes: 3576
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        long ans = 0;
        Arrays.sort(A);
        if (N % 2 == 0) {
            for (int i = N / 2; i < N; i++) {
                ans += 2 * A[i];
            }
            for (int i = 0; i < (N / 2); i++) {
                ans -= 2 * A[i];
            }
            ans -= A[N / 2];
            ans += A[N / 2 - 1];
        } else {
            for (int i = N / 2; i < N; i++) {
                ans += 2 * A[i];
            }
            for (int i = 0; i < N / 2; i++) {
                ans -= 2 * A[i];
            }
            ans -= A[N / 2];
            ans -= A[N / 2 + 1];
            long ans2 = 0;
            for (int i = N / 2 + 1; i < N; i++) {
                ans2 += 2 * A[i];
            }
            for (int i = 0; i < (N / 2) + 1; i++) {
                ans2 -= 2 * A[i];
            }
            ans2 += A[N / 2];
            ans2 += A[N / 2 - 1];
            ans = Math.max(ans, ans2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 61252
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W;
  cin >> H >> W;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<bool>> open(H, vector<bool>(W, true));
  int64_t count_black = 0;
  for (int64_t i = 0; i < H; ++i) {
    string s;
    cin >> s;
    for (int64_t j = 0; j < W; ++j) {
      const char ch = s.c_str()[j];
      if (ch == '#') {
        open[i][j] = false;
        ++count_black;
      }
    }
  }
  vector<vector<int64_t>> distance(H, vector<int64_t>(W, kInf));
  distance[0][0] = 0;
  queue<Pair> q;
  q.emplace(0, 0);
  const int64_t d_nexts[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
  while (!q.empty()) {
    const Pair target = q.front();
    q.pop();
    for (const auto &d : d_nexts) {
      const Pair next(target.first + d[0], target.second + d[1]);
      if (next.first >= 0 && next.first < H && next.second >= 0 && next.second < W && open[next.first][next.second]) {
        if (distance[target.first][target.second] + 1 < distance[next.first][next.second]) {
          distance[next.first][next.second] = distance[target.first][target.second] + 1;
          q.emplace(next);
        }
      }
    }
  }
  int64_t result = 0;
  if (distance[H - 1][W - 1] == kInf) {
    result = -1;
  } else {
    result = H * W - count_black - (distance[H - 1][W - 1] + 1);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3644
S=int(input())
flag = True
n = 2
List=[S]
res = 0
while flag:
  if S % 2 == 0:
    S = S // 2
  else:
    S = 3* S +1
  if List.count(S) ==0:
    List.append(S)
  else:
    res = n
    flag = False
  n += 1
print(res)

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);

		long p = 1;
		for (int i = 0; i < n; ++i) {
			if (a[i] == 0) {
				System.out.println(0);
				return;
			}

			if (1000000000000000000L / p >= a[i]) {
				p *= a[i];
			} else {
				System.out.println(-1);
				return;
			}
		}

		System.out.println(p);

	}

}


Measured memory_bytes: 61444