akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

#define at(i, j) ((i) * W + (j))
int main() {
  for(int W, H; cin >> W >> H, (W | H) != 0; ) {
    vector<vector<pii>> adj(W * H * W * H);

    rep(i, 2 * H - 1) {
      if (!(i & 1)) {
        rep(j, W - 1) {
          int e; cin >> e;
          if (e) continue;
          adj[at(i / 2, j)].emplace_back(j + 1, i / 2);
          adj[at(i / 2, j + 1)].emplace_back(j, i / 2);
        }
      }
      else {
        rep(j, W) {
          int e; cin >> e;
          if (e) continue;
          adj[at(i / 2, j)].emplace_back(j, i / 2 + 1);
          adj[at(i / 2 + 1, j)].emplace_back(j, i / 2);
        }
      }
    }

    queue<pii> que;
    que.emplace(0, 0);
    int dist[30][30] = {};
    dist[0][0] = 1;
    while(!que.empty()) {
      int x, y;
      tie(x, y) = que.front();
      que.pop();

      for(auto p : adj[at(y, x)]) {
        int tx, ty;
        tie(tx, ty) = p;
        assert(abs(x - tx) + abs(y - ty) <= 1);
        if(dist[ty][tx]) continue;
        dist[ty][tx] = dist[y][x] + 1;
        que.emplace(tx, ty);
      }
    }

    cout << dist[H - 1][W - 1] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 32604
n = gets.chomp.to_i
d = gets.chomp.split(' ').map{|i| i.to_i }

sum = 0
n.times{|i|
  (n - i - 1).times{|jj|
    j = jj + i + 1
    sum += d[i] * d[j]
  }
}

puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int h, w; cin >> h >> w;
    vector<vector<string>> vvs(h, vector<string>(w));
    rep(i, 0, h) rep(j, 0, w) cin >> vvs[i][j];
    int ii, jj;
    rep(i, 0, h) rep(j, 0, w) {
        if(vvs[i][j] == "snuke") ii = i, jj = j;
    }
    ii++;
    vector<char> a(25);
    rep(i, 0, 25) a[i] = 'A' + i;
    cout << a[jj] << ii << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	ArrayList<LinkedList<P>> data;
	
	class P implements Comparable<P>{
		int time,lap, lest, nowlane;
		public P(int time, int lap) {
			this.time = time;
			this.lap = lap * 2;
			this.lest = time;
			this.nowlane = 0;
		}
		@Override
		public String toString() {
			return "P [time=" + time + ", lap=" + lap + ", lest=" + lest
					+ ", nowlane=" + nowlane + "]";
		}
		@Override
		public int compareTo(P o) {
			return this.time - o.time;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			data = new ArrayList<LinkedList<P>>();
			for(int i = 0; i < 2; i++){
				data.add(new LinkedList<P>());
				if(i == 0){
					for(int j = 0; j < n; j++){
						int t = sc.nextInt(), l = sc.nextInt();
						data.get(i).add(new P(t, l));
					}
				}
				Collections.sort(data.get(i));
			}
			
			int nowtime = 1;
			int count = 0;
			for(nowtime = 1;; nowtime++){
				
				ArrayList<ArrayList<P>> temp = new ArrayList<ArrayList<P>>();
				for(int i = 0; i < 2; i++){
					temp.add(new ArrayList<Main.P>());
				}
				
				for(int i = 0; i < 2; i++){
					for(int j =0;j <  data.get(i).size(); j++){
						data.get(i).get(j).lest--;
						if(data.get(i).get(j).lest <= 0 && j == 0){
							data.get(i).get(0).lap--;
							data.get(i).get(0).nowlane ^= 1;
							data.get(i).get(0).lest = data.get(i).get(0).time;
							P now = data.get(i).remove(0);
							j--;
							if(now.lap == 0){
								count++;
							}
							else{
								temp.get(i ^ 1).add(now);
							}
						}
					}
				}
				
				for(ArrayList<P> a: temp){
					Collections.sort(a);
				}
				for(int i = 0; i < 2; i++){
					for(int j = 0; j < temp.get(i).size(); j++){
						data.get(i).add(temp.get(i).get(j));
					}
				}
				
				//debug
//				System.out.println("time = " + nowtime + " count = " + count);
//				for(int i = 0; i < 2; i++){
//					System.out.println("i = " + i);
//					System.out.println(data.get(i));
//				}
				
				//end cond
				if(count >= n){
					break;
				}
			}
			System.out.println(nowtime);
		}
	}

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

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

using namespace std;


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

    vector<int> height;
    int n;
    cin >> n;

    for(int i = 0 ; i < n; ++i)
    {
        int h;
        cin >> h;
        height.push_back(h);
    }
    int count = 1;
    int min_height = height[0];
    for(int i = 0 ; i < height.size(); ++i)
    {
        int j = i+1;

        if(height[j] >= height[i] && height[j] >= min_height)
        {
            count++;
        }
        min_height = max(min_height, height[j]);
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int s = 0;
	int k = n;
	for(;;){
		s += k % 10;
		if(k < 10) break;
		k /= 10;
	}
	if(n % s == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
"use strict"

function main(input) {
  input = input.split(/\n/).map(v => v.split(" ").map(v => ~~v))
  const N = input[0][0]
  const groups = input.slice(1, input.length)
  let ans = 0
  for (let i = 0; i < N; i++) {
    ans += groups[i][1] - groups[i][0] + 1
  }
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7868
nn, kk = list(map(int,input().split()))
pp = list(map(int,input().split()))

expectation = [0]*(nn-kk+1)
expectation[0] = sum(pp[0:kk])

for i in range(1,nn-kk+1):
    expectation[i] = expectation[i-1] - pp[i-1] + pp[i+kk-1]

print((max(expectation)+kk)/2)


Measured memory_bytes: 99212
#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;

int main()
{
    string w, t;
    int count = 0;

    cin >> w;
    transform(w.begin(), w.end(), w.begin(), ::tolower);

    while (cin >> t) {
        transform(t.begin(), t.end(), t.begin(), ::tolower);

        if (t.compare(w) == 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
string N;
long long l;
int main()
{
    cin>>N;
	l=N.size();
	for(int i=0;i<l;i++)
	{
		if(N[i]=='9')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}cout<<"No"<<endl;
	
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (X, Y, Z) = readLine()!!.split(" ").map(String::toInt)

    var count = 1
    while (true) {
        val sum = ((Y * (count + 1)) + (Z * (count + 2)))
        if (X - sum >= 0) {
            count++
        } else {
            break
        }
    }
    println(count)
}



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

bool eval(int prev_b, int prev_s, int next_b, int next_s) {
    if (prev_b == next_b) return prev_s == next_s;
    else return prev_s != next_s;
}

char int2char(int num) {
    if (num < 10) return num + '0';
    return num - 10 + 'A';
}

void solve(int n, int m, int q) {
    vector<string> S(q), B(q);
    for (int i = 0; i < q; ++i) {
        cin >> S[i] >> B[i];
    }
    vector<vector<int> > corr(m);
    for (int i = 0; i < m; ++i) {
        // i番目の電球を切り替えられるスイッチを見つける
        for (int j = 0; j < n; ++j) {
            bool is_ok = true;
            int prev_bulb = 0;
            int prev_switch = 0;
            for (int k = 0; k < q; ++k) {
                int next_bulb = B[k][i] - '0';
                int next_switch = prev_switch ^ (S[k][j] - '0');
                if (!eval(prev_bulb, prev_switch, next_bulb, next_switch)) {
                    is_ok = false;
                    break;
                }
                prev_bulb = next_bulb;
                prev_switch = next_switch;
            }
            if (is_ok) corr[i].push_back(j);
        }
    }
    for (int i = 0; i < m; ++i) {
        if (corr[i].size() == 1) {
            cout << int2char(corr[i][0]);
        }
        else cout << '?';
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, Q;
    while (true) {
        cin >> N >> M >> Q;
        if (N == 0 && M == 0 && Q == 0) break;
        solve(N, M, Q);
    }
    return 0;
}


Measured memory_bytes: 4396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = 0,x,y;
	x = b - b / c - b / d + b / lcm(c,d);
	y = (a-1) - (a-1) / c - (a-1) / d + (a-1) / lcm(c,d);
	cout << x - y;
	return 0; 
}









Measured memory_bytes: 256
n,Ma,Mb=map(int,input().split())
inf=float("inf")
dp=[[[inf]*401 for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0

l=[tuple(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
    for j in range(401):
        for k in range(401):
            a,b,c=l[i-1]
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])
            if j-a>=0 and k-b>=0:
                dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a][k-b]+c)

ans=inf
for i in range(1,1+min(400//Ma,400//Mb)):
    ans=min(ans,dp[n][Ma*i][Mb*i])

print(ans if ans!=inf else -1)

Measured memory_bytes: 133596
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
typedef pair<LL, int> P;

inline LL eval(P p, const vector<LL>& sum, LL C) {
    return p.first + sum[p.second] - C;
}
inline int lower_bound(LL l, const deque<P>& s, const vector<LL>& sum, LL C) {
    int lb = -1, ub = s.size();
    while(ub - lb > 1) {
        int k = (lb + ub) / 2;
        if(eval(s[k], sum, C) >= l) {
            ub = k;
        } else {
            lb = k;
        }
    }
    return ub;
}

int main(){
    int Q;
    LL L;
    while(cin >> Q >> L && Q > 0) {
        LL C = 0;
        vector<LL> sum(Q);
        deque<P> s;
        for(int i = 0; i < Q; i++) {
            int type;
            scanf("%d", &type);

            if(type == 0) {
                s.push_back(P(L, i));
            } else if(type == 1) {
                LL D;
                scanf("%lld", &D);
                C += D;
                int ans = 0;
                while(s.size()) {
                    P p = s.front();
                    if(eval(p, sum, C) <= 0) {
                        ans++;
                        s.pop_front();
                    } else {
                        break;
                    }
                }
                if(ans > 0) {
                    cout << "damage ";
                    cout << ans << endl;
                }
            } else if(type == 2) {
                int k;
                scanf("%d", &k);
                if(s.size() >= k) {
                    k--;
                    s.erase(s.begin() + k);
                    cout << "hit" << endl;
                } else {
                    cout << "miss" << endl;
                }
            } else if(type == 3) {
                LL x, r;
                scanf("%lld %lld", &x, &r);
                LL a = x - r, b = x + r; // [a, b]
                //cout << "[" << a << ", " << b << "]" << endl;
                int begin = lower_bound(a, s, sum, C);
                auto it = s.begin() + begin;
                int ans = 0;
                while(it != s.end()) {
                    auto dist = eval(*it, sum, C);
                    if(dist > b) break;
                    ans++;
                    assert(dist >= a);
                    it = s.erase(it);
                }
                cout << "bomb " << ans << endl;
            } else if(type == 4) {
                int k;
                scanf("%d", &k);
                if(s.size() >= k) {
                    k--;
                    cout << "distance ";
                    cout << eval(s[k], sum, C) << endl;
                } else {
                    cout << "distance -1" << endl;
                }
            }

            sum[i] = C;
        }
        cout << "end" << endl;
    }
    return 0;
}

Measured memory_bytes: 2844
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define EPS (1e-12)
inline double sq(double a) { return a*a; }

int n, a[10], b[10];

double at(int i, double y) {
    const int j = (i+1)%n;
    const double dx = a[j]-a[i], dy = b[j]-b[i];
    return a[i] + dx/dy*(y-b[i]);
}

double cut(double y) {
    vector<double> xs;
    rep(i, n) {
        const int j = (i+1)%n;
        if(b[i]==b[j]) continue;
        if(y <= min(b[i], b[j])) continue;
        if(y >= max(b[i], b[j])) continue;
        xs.push_back(at(i, y));
    }
    sort(xs.begin(), xs.end());
    if(xs.size()==4) return xs[3]-xs[2]+xs[1]-xs[0];
    else return xs.size()<2 ? 0 : xs.back()-xs.front();
}

int main() {
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        rep(i, n) scanf("%d%d", a+i, b+i);
        vector<double> ws;
        rep(i, n) ws.push_back(b[i]-EPS), ws.push_back(b[i]+EPS);
        sort(ws.begin(), ws.end());
        double ans = 0;
        rep(i, n) {
            const int j = (i+1)%n;
            if(b[i]==b[j]) {
                ans += (cut(b[i]-EPS) + cut(b[i]+EPS)) * abs(a[j]-a[i]);
            }
            else {
                const int u = min(b[i], b[j]), v = max(b[i], b[j]);
                rep(k, ws.size()-1) {
                    const double l = ws[k], r = ws[k+1];
                    if(r<u || l>v) continue;
                    const double d = sqrt(sq(r-l) + sq(at(i, r)-at(i, l)));
                    ans += (cut(l) + cut(r)) * d;
                }
            }
        }
        printf("%.12f\n", ans);
    }
}

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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 ///   freopen("testcase.txt","r",stdin);

 string s;
 cin>>s;

 int c=0;
 for(int i=0;i<=s.length();i++)
 {
     if(i%2==0)
     {
         if(s[i]=='R' || s[i]=='U' || s[i]=='D')
         {
             c++;
         }
     }
     else
     {
        if(s[i]=='L' || s[i]=='U' || s[i]=='D')
         {
             c++;
         }
     }
 }
 if(c==s.length())
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n,x[100005],a=0;
	long long s[2];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x[i];
	}
	sort(x,x+n);
	for(int i=n-1;i>0;i--){
		if(x[i]==x[i-1]){
			s[a++]=x[i];
			i--;
			if(a==2){
				cout << s[0]*s[1] << endl;
				return 0;
			}
		}
	}
	cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
#define per(i,a,n) for (i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE 1000001
#define ONLINE_JUDGE
#define rd
#define PI acos(-1)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
auto clk=clock(); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

int main(){
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(20);
	#ifndef rd
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif	

	

	// Write after this

	int r;
	cin>>r;
	cout<<2*PI*r;

	// End code here


	#ifndef ONLINE_JUDGE
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<sstream>
#include<complex>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cctype>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS) 

using namespace std;

int n,d;

int main()
{
  while(cin >> n >> d,n|d)
    {
      deque<int> deq[n];
      int sum[n];
      rep(i,n)sum[i] = 0;
      int total = 0;
      rep(i,n)
	{
	  int k,c;
	  cin >> k;
	  total += k;
	  rep(j,k)
	    {
	      cin >> c;
	      sum[i] += c;
	      deq[i].push_back(c);
	    }
	  reverse(deq[i].begin(),deq[i].end());
	}

      bool ok = true;

      rep(i,total)
	{
	  rep(j,n)
	    {
	      if(deq[j].empty())continue;
	      int mex,men;
	      mex = -inf;
	      men = inf;
	      rep(k,n)
		{
		  int cost = sum[k] - (k==j?deq[j].front():0);
		  mex = max(mex,cost);
		  men = min(men,cost);
		}

	      if(mex-men <= d)
		{
		  sum[j] -= deq[j].front();
		  deq[j].pop_front();
		  break;
		}
	      if(j == n-1)ok = false;
	    }
	  if(!ok)break;
	}
    

      cout << (ok?"Yes":"No") << endl;

    }
  return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
//
// Created by karayuu on 2018-12-31.
//

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    if (0 <= a + w - b && a + w - b <= 2 * w) {
        printf("%d\n", 0);
    } else {
        printf("%d\n", min(abs(b + w - a), abs(a + w - b)));
    }
}

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

int main(){
    int S;
    int s;
    int m;
    int h;
    cin >> S; 
    
    cout << (h=S/3600) << ":" << (m=(S % 3600)/60) << ":" << (s=(S % 3600)%60) << endl;
    
    return 0;
}


Measured memory_bytes: 3068
// Zende bad Shoma nasime faghat !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = (1 << 19) + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}
ll bin_pow(ll b, ll p){
	ll res = 1;
	for(ll j = 1, pw = b; j <= p; j <<= 1, pw = mul(pw, pw))
		if(p & j)
			res = mul(res, pw);
	return res;
}
ll inv(ll x){
	return bin_pow(x, Mod - 2);
}

int n, m, m2;
int p[N];
int mk[N];
ll Sm[N];

vector< pair<int, ll> > V;
ll dp[N], iv[N];
ll Ans;

void DFS(int u){
	if(!mk[u]) return;
	if(u > m) return;
	DFS(u << 1);
	DFS(u << 1 | 1);
	Ans += mul(u, mul(Sm[u << 1], Sm[u << 1 | 1]));
	Sm[u] = mul(u, (Sm[u << 1] + Sm[u << 1 | 1]));
}

ll ans[N];

void Solve(int u){
	int L = u;
	while(L <= m) L <<= 1;
	int R = u;
	while(R <= m) R = R << 1 | 1;
	//cerr << "! " << L << ' ' << R << '\n';
	int mt;
	for(int v = L; v <= R; v++){
		mt = m + p[v];
		//if(u == 1) cerr << v << ' ' << mt << '\n';

		Sm[mt] = mul(mt, mul(dp[v], iv[u]));
		mk[mt] = 1;
		while(mt >>= 1) mk[mt] = 1;
		//cerr << "MTF\n";
	}
	//debug("P!");
	Ans = 0;
	DFS(1);
	Ans %= Mod;
	ans[u] = mul(Ans, u);
	//debug("P#");
	for(int v = L; v <= R; v++){
		mt = m + p[v];
		Sm[mt] = 0;
		mk[mt] = 0;
		while(mt >>= 1) Sm[mt] = 0, mk[mt] = 0;
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[1] = 1;
	for(int i = 2; i < N; i++) dp[i] = mul(dp[i / 2], i);
	for(int i = 1; i < N; i++) iv[i] = inv(dp[i]);

	cin >> n;
	m = (1 << (n - 1)) - 1;
	m2 = (1 << n) - 1;
	for(int i = m + 1; i <= m2; i++) cin >> p[i];

	for(int i = m; i > 0; i--){
		//cerr << i << '\n';
		Solve(i);
	}
	ll fin = 0;
	for(int i = 1; i <= m; i++){
		ans[i] -= mul(ans[i << 1], mul(i, i << 1));
		ans[i] -= mul(ans[i << 1 | 1], mul(i, i << 1 | 1));
		ans[i] %= Mod;
		fin += ans[i];
	}
	fin %= Mod;
	fin += Mod;
	cout << fin % Mod << '\n';

	return 0;
}


Measured memory_bytes: 16444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],b[N],T,p[N],ans;
ll s[N],dp[33];
int main(){
	//freopen("07-a01_almost_a0-00","r",stdin);
	n=read(),T=read();
	for(int i=1;i<=n;++i){
		a[i]=read(),b[i]=read()+a[i],p[i]=i;
	}
	sort(p+1,p+n+1,[&](int i,int j){return a[i]>a[j];});
	int m=n;
	while(m&&!a[p[m]])--m;
	sort(p+1,p+m+1,[&](int i,int j){return 1LL*(b[i]+1)*a[j]<1LL*(b[j]+1)*a[i];});
	sort(p+m+1,p+n+1,[&](int i,int j){return b[i]<b[j];});
	for(int i=1;i<=n-m;++i){
		s[i]=s[i-1]+b[p[i+m]]+1;
	}
	for(int i=1;i<=30;++i){
		dp[i]=0x3f3f3f3f;
	}
	dp[0]=0;
	for(int i=1;i<=m;++i){
		for(int j=30;j>=1;--j){
			dp[j]=min(dp[j],dp[j-1]+1LL*dp[j-1]*a[p[i]]+b[p[i]]+1);
		}
	}
	int now=0;
	for(int i=30;i>=0;--i){
		if(dp[i]>T)continue;
		while(now<n-m&&s[now+1]<=T-dp[i]){
			++now;
		}
		ans=max(ans,now+i);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 7608
#include<iostream>
using namespace std;
int main()
{
	int n,tag,minv,i,j;
	int *p;
	cin>>n;
	p = new int [n];
	for(i=0;i<n;i++)
		cin>>p[i];
	tag = p[1] - p[0];
	minv = p[0];
	for(i=1;i<n;i++)
	{
		if(p[i] - minv>tag)
		tag = p[i]-minv;
		if(minv>p[i])
		minv = p[i];
	}	
	cout<<tag<<endl;
	delete [] p;
	return 0;
 } 


Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

int main(){
    string S;
    cin >> S;
    if(count(S.begin(), S.end(), 'a') == 1 && count(S.begin(), S.end(), 'b') == 1 && count(S.begin(), S.end(), 'c') == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  const ll INF=1000000000;
  ll n;
  while(1){
    cin >> n;
    if(n==0){
      return 0;
    }
    double dp[110][110];
    ll i,j,k,b[110],x[110],y[110];
    for(i=0;i<n;i++){
      cin >> b[i] >> x[i] >> y[i];
      b[i]--;
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        dp[i][j]=INF;
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<=50){
          dp[b[i]][b[j]]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
      }
    }
    ll z[110][110];
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        z[i][j]=j;
      }
    }
    for(k=0;k<n;k++){
      for(i=0;i<n;i++){
        for(j=0;j<n;j++){
          if(dp[i][j]>dp[i][k]+dp[k][j]){
            dp[i][j]=dp[i][k]+dp[k][j];
            z[i][j]=z[i][k];
          }
        }
      }
    }
    ll m,s,g;
    cin >> m;
    for(i=0;i<m;i++){
      cin >> s >> g;
      s--,g--;
      if(dp[s][g]==INF){
        cout << "NA" << endl;
        continue;
      }
      cout << s+1;
      for(j=s;j!=g;j=z[j][g]){
        cout << ' ' << z[j][g]+1;
      }
      cout << endl;
    }
  }
  return 0;
}


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


const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

int C[N];

signed main(){
    int n;
    cin >> n;
    int mx = 0;
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d",&x);
        mx = max(mx,++C[x]);
        if(x) mx = max(mx,++C[x-1]);
        mx = max(mx,++C[x+1]);
    }
    
    cout << mx;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int a, b, c, d;
    cin>>a>>b>>c>>d;

    cout<<max(min(b, d) - max(a, c), 0)<<endl;
}

Measured memory_bytes: 256
k = int(input())
a = [7 % k]
if 7 % k == 0:
    print(1)
    exit()
for i in range(1,k):
    tmp = (a[-1] * 10 +7) % k
    if tmp == 0:
        print(i+1)
        exit()
    else:
        a.append(tmp)
print('-1')

Measured memory_bytes: 48560
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
ll k;
ll a[205][205][205];
void solve(ll k)
{
   for(int i=1;i<=k;i++)
   {
       for(int j=1;j<=k;j++)
       {
           for(int s=1;s<=k;s++)
           {
               ll u=__gcd(i,__gcd(j,s));
               a[i][j][s]=u;
           }
       }
   } 
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll ans=0;
      cin>>k;
      solve(k);
      for(int i=1;i<=k;i++)
    {
       for(int j=1;j<=k;j++)
       {
           for(int s=1;s<=k;s++)
           {
               ans+=a[i][j][s];
           }
       }
   }
   cout<<ans; 
  }
  return 0;
}

Measured memory_bytes: 68436
($N,$D)=glob<>;
@X=<>;
for$i(0..$N-1){for$j($i+1..$N-1){
	@a=glob$X[$i];
	@b=glob$X[$j];
	$t=0;
	$t+=($a[$_]-$b[$_])**2 for 0..$D-1;
	$c+=($%=$t**.5)**2==$t;
}}
print$c

Measured memory_bytes: 768
/* krk */

/* Internet-->"http://arcoder.jp/contests/arc103/tests/arc103_a" */
/* (arc)103C */
/* C-/\/\/\/ */
#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> ii;

const int Maxm = 100005;

int n;
int a[Maxm];
int freq[Maxm];
ii best[2][2];

void Get(int from)
{
    fill(freq, freq + Maxm, 0);
    for (int i = from; i < n; i += 2)
        freq[a[i]]++;
    for (int i = 1; i < Maxm; i++)
        if (ii(freq[i], i) > best[from][0])
            best[from][1] = best[from][0], best[from][0] = ii(freq[i], i);
        else if (ii(freq[i], i) > best[from][1])
            best[from][1] = ii(freq[i], i);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    Get(0); Get(1);
    int res = 0;
    if (best[0][0].second == best[1][0].second)
        res = max(best[0][0].first + best[1][1].first,
                  best[0][1].first + best[1][0].first);
    else res = best[0][0].first + best[1][0].first;
    printf("%d\n", n - res);
    return 0;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> l(n);
	for(int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	
	sort(l.begin(), l.end(), [](const int& a, const int& b) {return a > b;});
	
	int ans = 0;
	
	for(int i = 0; i < k; i++)
	{
		ans += l[i];
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(void){
	char s[10];

	scanf("%s",s);

	if(strcmp(s,"Sunny") == 0){
		printf("Cloudy\n");
	}else if(strcmp(s,"Cloudy") == 0){
		printf("Rainy\n");
	}else{
		printf("Sunny\n");
	}


	return 0;
}




Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


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

	string s;
	ll n;
	cin >> n >> s;
	static ll w[400000];//←にいるWの数を求める
	static ll e[400000];//→にいるEの数を求める
	w[0] = 0;
	for (int i = 1; i < n;i++) {
		if (s[i - 1] == 'W') w[i] = w[i - 1] + 1; else w[i] = w[i - 1];
	}

	e[n - 1] = 0;

	for (int i = n - 2; i >= 0; i--) {
		if (s[i + 1] == 'E') e[i] = e[i+1] + 1; else e[i] = e[i+1];
	}

	ll num = 500000;
	REP(i, n) {
		num= min(num, e[i] + w[i]);
	}
	
	cout << num << endl;

	return 0;

}

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

void fnInput(int &a_riElementCnt, vector<int> &a_rviElement, 
             int &a_riTargetCnt , vector<int> &a_rviTarget )
{
  cin >> a_riElementCnt;

  a_rviElement.resize(a_riElementCnt);
  for (int i = 0; i < a_riElementCnt; i++)
    cin >> a_rviElement[i];

  cin >> a_riTargetCnt;

  a_rviTarget.resize(a_riTargetCnt);
  for (int i = 0; i < a_riTargetCnt; i++)
    cin >> a_rviTarget[i];
}

int fnRcsSearch(int a_iPos, const vector<int> &a_cnrviElement, int a_iTarget,
                vector<vector<int>> &a_rvviOK)
{
  if (a_iPos == a_cnrviElement.size())  return 0;
  if (!a_iTarget)    return 1;
  if (a_iTarget < 0) return 0;
  if (a_rvviOK[a_iPos][a_iTarget] != -1)
    return a_rvviOK[a_iPos][a_iTarget];

  a_iPos++; 
  int iRtn0 = fnRcsSearch(a_iPos, a_cnrviElement, a_iTarget, a_rvviOK);
  a_rvviOK[a_iPos][a_iTarget] = iRtn0;
  if (iRtn0)  return iRtn0;

  int iSmallTarget = a_iTarget - a_cnrviElement[a_iPos];
  int iRtn1 = fnRcsSearch(a_iPos, a_cnrviElement, iSmallTarget, a_rvviOK);
  if (iSmallTarget >= 0)
  {
    a_rvviOK[a_iPos][iSmallTarget] = iRtn1;
    return iRtn1;
  }
}

void fnExhSearch(const vector<int> &a_cnrviElement, const vector<int> &a_cnrviTarget)
{
  vector<vector<int>> vviOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < a_cnrviTarget.size(); i++)
  {
    int iTarget = a_cnrviTarget[i];
    int iRtn0, iRtn1;

    if (fnRcsSearch(0, a_cnrviElement, iTarget, vviOK))
    {
      cout << "yes" << endl;
      vviOK[0][iTarget] = fnRcsSearch(0, a_cnrviElement, iTarget, vviOK);
      continue;
    }

    int iSmallTarget = iTarget - a_cnrviElement[0];
    if (fnRcsSearch(0, a_cnrviElement, iSmallTarget, vviOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    if (iSmallTarget >= 0)
    {
      vviOK[0][iSmallTarget] = fnRcsSearch(0, a_cnrviElement, iSmallTarget, vviOK);
    }
  }
}

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

  int iElementCnt, iTargetCnt;
  vector<int> viElement, viTarget;

  fnInput(iElementCnt, viElement, iTargetCnt, viTarget);
  fnExhSearch(viElement, viTarget);

  return 0;
}

Measured memory_bytes: 1340
import java.util.Scanner;

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

        if(Integer.toString(n).contains("7")) {
            System.out.print("Yes");
            return;
        }
        System.out.print("No");
    }
}


Measured memory_bytes: 27080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        if(sc.nextInt()+sc.nextInt()+sc.nextInt()>=22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b ;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( b % a == 0 ){
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    //*/
    
    //cout << a / b << endl;

    return 0; 
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	//c_p_c();
	string s;
	cin >> s;
	int m = 0;
	for(int i=0;i<3;){
		if(s[i] == 'R'){
			int ans = 0;
			while(s[i] == 'R'){
				ans++;
				i++;
			}
			i--;
			m = max(ans, m);
		}
		i++;
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 3624
import numpy as np

N = int(raw_input())

A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

A = sorted(A)
B = sorted(B)
C = sorted(C)

ans = 0
x = 0
z = 0

for y in B:
    while x < N and A[x] < y:
        x = x + 1
    while z < N and C[z] <= y:
        z = z + 1
    ans = ans + x*(N-z)
print ans


Measured memory_bytes: 34204
#include <stdio.h>

#define N 100000

int main()
{
  int n,q,i,j,k,S[N],T[N],m,right,left;

  scanf("%d",&n);

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

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

  for(j=0;j<q;j++){
    left = 0;
      right = n;
      m = n/2;
    while(left<right){
      m = (left+right)/2;
      if(T[j] < S[m])
	right = m;
      else if(T[j] > S[m])
	left = m+1;
      else {
	k++;
	break;
      }
    }
  }

  printf("%d\n",k);

  return 0;
}
  

      



Measured memory_bytes: 2356
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

string s;

bool isKaibun(ll l, ll r){
	ll n = r - l;
	rep(i, n + 1) if(s[l + i] != s[r - i]) return false;
	return true;
}

int main(void){
	cin >> s;

	ll n = s.size();
	if(isKaibun(0, n - 1) && isKaibun(0, (n - 1) / 2 - 1) && isKaibun((n + 3) / 2 - 1, n - 1)) co("Yes");
	else co("No");

	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = input()
    li = list(map(int, input().split(' ')))
    ans = float('inf')

    while li != []:
        li_value = li.pop()
        cnt = 0
        while li_value % 2 != 1:
            cnt += 1
            li_value /= 2
        ans = min(ans, cnt)
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

#define MAX_N 10000

using namespace std;

int prime[MAX_N];
bool is_prime[MAX_N + 1];
bool is_p[MAX_N + 1];
vector<int> prime2;
int data[MAX_N];
set<int> used;

int sieve(int n){
  int p = 0;
  for(int i=0;i<=n;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++] = i;
      for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
    }
  }
  return p;
}

void solve(int n){
  int size = (n-1)/2;
  if(is_p[n]){
    for(int i=0;i<size;i++){
      cout << size-1 << endl;
    }
    return;
  }
  fill(data, data+size, 0);
  used.clear();
  for(int i=1;i<=size;i++){
    int tmp = (i*i)%n;
    used.insert(tmp);
  }
  set<int>::iterator ite = used.begin();
  for(;ite!=used.end();ite++){
    for(set<int>::iterator ite2 = used.begin();ite2!=used.end();ite2++){
      if(ite == ite2) continue;
      int a = *ite;
      int b = *ite2;
      int c = a-b;
      if(c < 0) c += n;
      if(c > size) c = n - c;
      ++data[c-1];
    }
    }
  for(int i=0;i<size;i++){
    cout << data[i] << endl;
  }
}

main(){
  int size = sieve(MAX_N);
  for(int i=0;i<size;i++){
    if(prime[i] % 4 == 3){
      prime2.push_back(prime[i]);
      is_p[prime[i]] = true;
    }
  }
  int n;
  while(cin >> n && n){
    /*if(n == 1){
      cout << 0 << endl;
      continue;
      }*/
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 0
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
ll a[N],b[N];
signed main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n,m,k;cin>>n>>m>>k;
    _for(i,0,n){
        int x;cin>>x;
        a[i+1]=a[i]+x;
    }
    _for(i,0,m){
        int x;cin>>x;
        b[i+1]=b[i]+x;
    }
    int ans = 0;
    ll res;
    _for(i,1,n+1){
        res = k-a[i];
        if(res<0){
            if(i==1){
                int y = lower_bound(b,b+m+1,k)-b;
                if(y==m+1)y=m;
                else if(b[y]>k)--y;
                ans = max(ans,y);
                break;
            }
            else break;
        }else if(res==0)ans = max(i,ans);
        else{
            int y = lower_bound(b,b+m+1,res)-b;
            if(y==m+1)y=m;
            else if(b[y]>res)--y;
            ans = max(ans,y+i);
        }
    }
    _for(i,1,m+1){
        res = k-b[i];
        if(res<0){
            if(i==1){
                int y = lower_bound(a,a+n+1,k)-a;
                if(y==n+1)y=n;
                else if(a[y]>k)--y;
                ans = max(ans,y);
                break;
            }
            else break;
        }else if(res==0)ans = max(i,ans);
        else{
            int y = lower_bound(a,a+n+1,res)-a;
            if(y==n+1)y=n;
            else if(a[y]>res)--y;
            ans = max(ans,y+i);
        }
    }
    cout<<ans;
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

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

typedef long long ll;
using namespace std;

void solve(){
    int n;
    bool zero = false;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];

        if (a[i] == 0)
            zero = true;
    }

    if (zero)
        cout << 0;
    else {
        long long prod = 1;
        for (int i = 0; i < n; ++i)
            if (a[i] <= 1000000000000000000/prod)
                prod *= a[i];
            else {
                cout << -1;
                return;
            }
        cout << prod;
    }
}

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

    solve();

    return 0;
}


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

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  int k; // to input 
  int a; // to input 
  int b; // to input 

  scan = scanf("%d", &k);
  scan = scanf("%d", &a);
  scan = scanf("%d", &b);

  for (int i = 0; i <= b - a; i++) {
    if ((a + i) % k == 0) {
      printf("OK");
      return (0);
    }
  }
  
  printf("NG");
  return (0);
}


Measured memory_bytes: 1736