akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd_list(numbers):
    return reduce(gcd, numbers)


def main():
    n, x = map(int, input().split())
    xi = map(int, input().split())

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    print(gcd_list(diffs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n-1) {
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    rep(i,n) {
        cout << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
while True:
    
    H, W = map(int, raw_input().split())

    if H == 0 and W == 0:
        break


    for i in range(H):
	    if i%2 == 0:
	        print "#." * (W/2) + "#" * (W%2)
	    else:
	        print ".#" * (W/2) + "." * (W%2)
    print ""

Measured memory_bytes: 6440
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans=0,n;
	string s,t;
	cin>>s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		t+=t;
		for(int j=0;j<t.size()/2;j++)
		if(t.substr(j,s.size())==s){
			ans++;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define M 1000000007
#define vc vector
#define vci vector<ll>
#define si set<ll>
#define pb push_back
#define pop pop_back
#define fs first
#define sc second
#define endl "\n"
#define mii map<ll,ll>
#define pii pair<ll,ll>
#define msi map<string,ll>
#define PI 3.14159265
#define r0 return 0
using namespace std;

void ah_shit_here_we_go_again()
{
    ll n;
    cin>>n;
    ll h[n];
    rep(i,0,n)
    {
        cin>>h[i];
    }
    ll dp[n+1];
    rep(i,0,n+1)
    {
        dp[i]=0;
    }
    ll x,y;
    rep(i,2,n+1)
    {
        x=dp[i-1]+abs(h[i-2]-h[i-1]);
        y=1e18;
        if(i>2)
        {
            y=dp[i-2]+abs(h[i-3]-h[i-1]);
        }
        dp[i]+=min(x,y);
    }
    cout<<dp[n];
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    ll t;
    t=1;
    //cin>>t;
    rep(i1,0,t)
    {
        ah_shit_here_we_go_again();
    }
    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef struct in{
	ll x;
	ll y;
	ll h;
}a;
a input[105];
a result[2000010];
int cnt=0;
ll max(ll a,ll b){
	return a>b?a:b; 
}
int main(){
	int n;
	scanf("%d",&n);
	int flag1=0;
	for(int i=0;i<n;i++){
		scanf("%lld %lld %lld",&input[i].x,&input[i].y,&input[i].h);
		if(input[i].h>0){
			flag1=1;
		}
	}
	if(flag1==0){
		printf("0 0 0\n");
	}
	else{
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				for(int k=0;k<n;k++){
					if(input[k].h!=0){
						result[cnt].h=input[k].h+abs(i-input[k].x)+abs(j-input[k].y);
						result[cnt].x=i;
						result[cnt].y=j;
						cnt++;
					}
				}
			}
		}
	}
	ll ansx=0,ansy=0,ansh=0;
	for(int i=0;i<cnt;i++){
		int flag3=0;
		int ans=0;
		for(int j=0;j<n;j++){
			if(input[j].h==0){
				if(max(result[i].h-abs(result[i].x-input[j].x)-abs(result[i].y-input[j].y),0)!=0){
					flag3=1;
					break;
				}
			}
			else{
				if(input[j].h+abs(result[i].x-input[j].x)+abs(result[i].y-input[j].y)!=result[i].h){
					flag3=1;
					break;
				}
			}
		}
		if(flag3==0){
			ansx=result[i].x;
			ansy=result[i].y;
			ansh=result[i].h;
		}
	}
	printf("%lld %lld %lld\n",ansx,ansy,ansh);
} 

Measured memory_bytes: 24832
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)
	ans := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			v := s - x - y
			if 0 <= v && v <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    if(n%2!=0)
        cout << n/2 << endl;
    else
        cout << n/2-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m,c; cin >> n >> m >> c;
  vector<int> b(m);
  int ans=0;
  rep(i,m){cin>>b[i];}
  rep(j,n){ 
    int cur=0;
    rep(i,m){
      int k;  cin>>k;
      cur += k*b[i]; 
    }
    if(cur+c>0){ans++;}          
  }

  cout << ans << endl;    
  return 0;
}


Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
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;}
// head
const int SIZE = 1e6+10;
ll a[SIZE];
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll h,w,n;
	cin>>h>>w>>n;
	ll ans = max(h,w);
	cout<<n/ans+(n%ans==0?0:1);
  	return 0;
}


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

int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+b>c+d) puts("Left");
  else if(a+b==c+d) puts("Balanced");
  else puts("Right");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] a = new int[m][n];
		int[][] b = new int [l][m];
		long[][] c = new long [l][n];
		for(int i = 0;i < n;i++ ) {
			for(int j = 0;j < m;j++) {
				int d = sc.nextInt();
				a[j][i] = d;
			}
		}
		for(int i = 0;i < m;i++) {
			for(int j = 0;j < l;j++) {
				int d = sc.nextInt();
				b[j][i] = d;
			}
		}
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < l;j++) {
				for(int k = 0; k< m; k++) {
				c[j][i] = c[j][i] + (a[k][i] * b[j][k]);
				}
				System.out.print(c[j][i]);
				if(j < l -1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}





Measured memory_bytes: 55240
#include <cstdio>
#include <algorithm>
using namespace std;
const int md=1000000007,MX=100100;
int n,i,j,k,cc,d,r=1,cur,all[MX],fi[MX],la[MX],a[MX],b[MX],c[MX],cnt[MX],cyc[MX],comp[MX],v[MX],gv[MX];
long long f[MX],g[MX];
bool u[MX],w[MX],ic[MX],was;
int dfs(int i, int d) {
  b[d]=i;
  u[i]=true;
  w[i]=true;
  if (w[a[i]]) {
    c[i]=++cc;
    cyc[cc]=1;
    fi[cc]=cur;
    ic[a[i]]=true;
    all[cur++]=a[i];
    for (int j=d; b[j]!=a[i]; j--, cyc[cc]++) {
      ic[b[j]]=true;
      all[cur++]=b[j];
    }
    la[cc]=cur;
  } else if (u[a[i]]) c[i]=c[a[i]]; else c[i]=dfs(a[i],d+1);
  w[i]=false;
  comp[c[i]]++;
  return c[i];
}
int main() {
  scanf("%d",&n);
  for (f[0]=g[0]=i=1; i<=n; i++) {
    scanf("%d",&a[i]);
    v[a[i]]++;
    f[i]=(((i>1)?(i-1)*f[i-2]:0LL)+f[i-1]*2)%md;
    g[i]=(((i>1)?(i-1)*g[i-2]:0LL)+g[i-1])%md;
  }
  for (i=1; i<=n; i++) if (v[i]==0) dfs(i,1);
  for (i=1; i<=n; i++) if (u[i]) {
    if (v[i]>2) { puts("0"); return 0; }
    if (!ic[i]) {
      if (v[i]>1) { puts("0"); return 0; }
      gv[a[i]]=i;
    }
  }
  for (i=1; i<=cc; i++) {
    if (comp[i]>2*cyc[i]) { puts("0"); return 0; }
    was=false;
    for (cur=0, j=fi[i]; j<la[i]; j++, cur--) {
      k=all[j];
      int cz=0;
      for (int e=gv[k]; e!=0; e=gv[e]) cz++;
      if (cz>0) {
        if (was) {
          if (cur>0) { puts("0"); return 0; }
          if (cur<0) r=(r*2)%md;
        } else was=true;
        cur=cz;
      }
    }
    for (j=fi[i]; j<la[i]; j++, cur--) {
      k=all[j];
      int cz=0;
      for (int e=gv[k]; e!=0; e=gv[e]) cz++;
      if (cz>0) {
        if (cur>0) { puts("0"); return 0; }
        if (cur<0) r=(r*2)%md;
        cur=cz;
        break;
      }
    }
  }
  for (i=1; i<=n; i++) if (!u[i]) {
    for (j=i, k=0; !u[j]; j=a[j], k++) u[j]=true;
    cnt[k]++;
  }
  r=(r*g[cnt[1]])%md;
  for (j=2; j<=n; j+=2) {
    for (i=1; i<=cnt[j]; i++) g[i]=(((i>1)?((i-1)*g[i-2])%md*j:0LL)+g[i-1])%md;
  r=(r*g[cnt[j]])%md;
  }
  for (j=3; j<=n; j+=2) {
    for (i=1; i<=cnt[j]; i++) f[i]=(((i>1)?((i-1)*f[i-2])%md*j:0LL)+f[i-1]*2)%md;
  r=(r*f[cnt[j]])%md;
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 5760
MAX =10000
isPrime = Array.new(MAX+1,true)
isPrime[0,2]=false,false
(2..100).each{|i|
  if isPrime[i]
    (i*2).step(MAX,i){|j|
      isPrime[j]=false
    }
  end
}
prime=[]
isPrime.each_index{|x|
  prime << x if isPrime[x]
}

loop do
  n = gets.to_i
  break if n==0
  c=0
  (0...prime.size).each{|i|
    break if prime[i] > n
    sum =0
    (i...prime.size).each{|j|
      break if sum>n
      sum+=prime[j]
      if sum==n
        c+=1
        break
      end
    }
  }
  puts c
end

Measured memory_bytes: 5788
while True:
    n,x = map(int,input().split())
    if(n==0 and x == 0):
        exit()
    count = 0
    for a in range(1,n+1):
        for b in range(1,n+1):
            for c in range(1,n+1):
                if(a+b+c>x):
                    break
                if(a+b+c==x and a<b<c):
                    count = count + 1
    print(count)


Measured memory_bytes: 5596
fn main() {
  let (mut w, mut h) = get::tuple::<usize,usize>();
  let ps = get::vals::<usize>(w);
  let qs = get::vals::<usize>(h);
  
  let ps = ps.into_iter().map(|p|(p,0)).collect::<Vec<_>>();
  let qs = qs.into_iter().map(|q|(q,1)).collect::<Vec<_>>();
  
  let mut pqs = ps.into_iter().chain(qs.into_iter()).collect::<Vec<_>>();
  pqs.sort();

  let mut ans: usize = 0;
  for (x, d) in pqs {
    match d {
      0 => {ans += x*(h+1); w-=1},
      1 => {ans += x*(w+1); h-=1},
      _ => unreachable!()
    }
  }
  
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 11832
import sys

input = sys.stdin.readline

S = input().strip()
N = len(S)

crs = list(map(len, S.split('R')))
cls = list(map(len, S.split('L')))
converges=[0] * N

current_index = 0
for cr in crs:
    if cr == 0:
        current_index += 1
    else:
        odd = cr // 2
        even = cr - odd
        converges[current_index - 1] += odd
        converges[current_index] += even
        current_index += cr+1

current_index = N - 1
for cl in cls[::-1]:
    if cl == 0:
        current_index -= 1
    else:
        odd = cl // 2
        even = cl - odd
        converges[current_index + 1] += odd
        converges[current_index] += even
        current_index -= cl + 1

print(' '.join(map(str, converges)))

Measured memory_bytes: 11884
// Lower.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <algorithm>

using namespace std;

int x[100005], n, ans = 0, cnt, cnt2;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cnt = 0;
		cnt2 = x[i];
		while (cnt2 >= x[i + 1] && i < n - 1)
			i++, cnt++, cnt2 = x[i];
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct HopcroftKarp {
	int n;
	vector<vector<int>> g;
	vector<int> match, dist;
	vector<bool> used, alive;
	HopcroftKarp(int n) : n(n), g(n), match(n), dist(n), used(n), alive(n, true) {}
	void addEdge(int u, int v) {
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	int maximumMatching() {
		int cnt = 0;
		fill(match.begin(), match.end(), -1);
		while (true) {
			buildAlternatingLevelGraph();
			fill(used.begin(), used.end(), false);
			int flow = 0;
			for (int u = 0; u < n; u++) {
				if (!alive[u])continue;
				if (match[u] == -1 && augment(u))
					flow++;
			}
			if (flow == 0)break;
			cnt += flow;
		}
		return cnt;
	}
	void buildAlternatingLevelGraph() {
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int u = 0; u < n; u++)
			if (match[u] == -1) {
				q.emplace(u);
				dist[u] = 0;
			}
		while (q.size()) {
			int u = q.front(); q.pop();
			for (int v : g[u]) {
				int w = match[v];
				if (w != -1 && dist[w] == -1) {
					dist[w] = dist[u] + 1;
					q.emplace(w);
				}
			}
		}
	};
	bool augment(int u) {
		used[u] = true;
		for (int v : g[u]) {
			if (!alive[v])continue;
			int w = match[v];
			if (w == -1 || (!used[w] && dist[w] == dist[u] + 1 && augment(w))) {
				match[u] = v;
				match[v] = u;
				used[v] = true;
				return true;
			}
		}
		return false;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N), b(N); rep(i, 0, N) {
		cin >> a[i] >> b[i];
	}
	vector<int> c(N), d(N); rep(i, 0, N) {
		cin >> c[i] >> d[i];
	}
	HopcroftKarp hk(N * 2);
	rep(i, 0, N)rep(j, 0, N) {
		if (a[i] < c[j] && b[i] < d[j])
			hk.addEdge(i, j + N);
	}
	cout << hk.maximumMatching() << endl;
	dump(hk.match);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}
LL lcm(LL a,LL b){
    LL g=gcd(a,b);
    return a/g*b;
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    
    string s;
    cin>>s;
    bool a=true; 
    for(int i=0;i<26;++i){
        bool truth=false;
        for(int j=0;j<s.size();++j){
            if(s[j]-'a'==i)truth=true;
        }
        if(!truth){
            cout<<(char)(i+'a')<<endl;
            a=!a;
            break;
        }
    }
    if(a)cout<<"None"<<endl;
    
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n, m;
    while(cin >> n >> m, n+m){
        vi h(n+1), w(m+1);
        h[0] = w[0] = 0;
        rep(i,n) cin >> h[i+1];
        rep(i,m) cin >> w[i+1];
        rep(i,n) h[i+1] += h[i];
        rep(i,m) w[i+1] += w[i];
        vi v1,v2;
        rep(i,n)loop(j,i+1,n+1)v1.push_back(h[j]-h[i]);
        rep(i,m)loop(j,i+1,m+1)v2.push_back(w[j]-w[i]);
/*
        rep(i,v1.size()) cout << v1[i] << endl;
        cout << endl;
        rep(i,v2.size()) cout << v2[i] << endl;
*/
        sort(all(v1));
        sort(all(v2));
        int ans = 0;
        rep(i,v1.size()){
            int t = v1[i];
            ans += upper_bound(all(v2), t) - lower_bound(all(v2), t);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 19668
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int a[200001];
int mapdata[200001];
int ans = 0;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};

std::pair<Weight, Edges> kruskal(Graph const &g) {
	uf_tree uf(g.size());
	Edges es;
	for (auto &adj : g)
		for (auto &e : adj) es.emplace_back(e);
	std::sort(es.begin(), es.end(),
		[](const Edge &e, const Edge &f) { return e.weight < f.weight; });
	Weight total = 0;
	Edges T;
	for (auto &e : es)
		if (!uf.is_same(e.src, e.dst)) {
			T.push_back(e);
			total += e.weight;
			uf.unite(e.src, e.dst);
		}
	return std::make_pair(total, T);
}

vector<pair<int, int>> xy, yx;
map<pair<int, int>, int> posToNum;

int cost(pair<int, int> one, pair<int, int> two) {
	return min(abs(one.first - two.first), abs(one.second - two.second));
}

signed main() {
	int N, cnt = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int inX, inY;
		cin >> inX >> inY;
		xy.push_back(make_pair(inX, inY));
		yx.push_back(make_pair(inY, inX));
		pair<int, int> p = make_pair(inX, inY);
		posToNum[p] = i;
	}
	sort(xy.begin(), xy.end());
	sort(yx.begin(), yx.end());
	Graph g(100001);
	for (int i = 0; i < N-1; i++) {
		add_edge(g, posToNum[xy[i]], posToNum[xy[i + 1]], cost(xy[i], xy[i + 1]));
		auto yx_xy1 = make_pair(yx[i].second, yx[i].first), yx_xy2 = make_pair(yx[i + 1].second, yx[i + 1].first);
		add_edge(g, posToNum[yx_xy1], posToNum[yx_xy2], cost(yx_xy1, yx_xy2));
	}
	cout << kruskal(g).first << "\n";


	return 0;
}

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

int n;
int p[100007];

int main()
{
  cin >> n;
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  
  for (int i = 0; i < n; i++) {
    if(p[i] == i + 1) {
      count++;
      i++;
    }
  }
  cout << count << endl;
 }

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

typedef long long int lli;
typedef pair<lli, lli> ii;

using namespace __gnu_pbds;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 5;
int n, k;
lli a[N];

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

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

    while(cin >> n >> k)
    {


        for(int i = 0; i < n; i++)
            cin >> a[i];

        //0 normalization
        for(int i = 0; i < n; i++)
            a[i] -= k;
        k = 0;

        ordered_set t;

        lli thres = 0;

        lli ans = 0;
        for(int i = 0 ; i < n; i++)
        {
            //Modify thres and insert new element aptly translated
            t.insert({thres, i});
            thres -= a[i];
            ans += (i + 1 - t.order_of_key({thres, (lli)-1}));


        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	if(a - (2 * b) >= 0){
		cout << a - (2 * b) << endl;
	} else if (a - (2 * b) < 0){
		cout << 0 << endl;
	} 	
}


Measured memory_bytes: 3620
n,m= map(int, input().split())
ab=[]
cd=[]
for i in range(n):
  ab.append(list(map(int, input().split())))
for i in range(m):
  cd.append(list(map(int, input().split())))

for a,b in ab:
  cpt=-1
  mind=10**9
  for j in range(len(cd)):
    c,d=cd[j]
    d=abs(a-c)+abs(b-d)
    if d<mind:
      cpt=j+1
      mind=min(mind,d)
  print(cpt)

Measured memory_bytes: 68088
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int q;
vector<LP> ans;
int main(){
    cin >> q;
    priority_queue <ll> lower;
    priority_queue < ll, vector<ll>, greater<ll> > upper;
    ll a,b,a_,b_,low,high,S_low=0,S_high=0;
    int n_low=1,n_high=0,s;
    cin >> s >> a_ >> b_;
    lower.push(a_);
    b+=b_,S_low=a_;
    rep(i,q-1){
        cin >> s;
        if (s == 1){
            cin >> a_ >> b_;
            b+=b_;
            low = lower.top();
            if (n_high != 0) high = upper.top();
            if ((n_low+n_high)%2==0){
                n_low+=1;
                if (high<a_){
                    upper.pop();
                    lower.push(high);
                    upper.push(a_);
                    S_low+=high,S_high+=a_-high;
                }else{
                    lower.push(a_);
                    S_low+=a_;
                }
            }else{
                n_high+=1;
                if (low<=a_){
                    upper.push(a_);
                    S_high+=a_;
                }else{
                    lower.pop();
                    lower.push(a_);
                    upper.push(low);
                    S_low+=a_-low,S_high+=low;
                }
            }
        }else if(s == 2){
            a = lower.top();
             cout << a << " " << n_low*a-S_low+S_high-n_high*a + b << endl;
        //     cout << b << endl;
        //     cout << n_low << " " << n_high << " " << S_low << " " <<S_high << endl;
        }
    }
}
        
        
        

Measured memory_bytes: 3828
#include<iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  string str;
  getline(cin, str);
  rep (iii, n) {
    getline(cin, str);
    rep (i, str.size() - 6) {
      if (str.substr(i, 7) == "Hoshino") str[i + 6] = 'a';
    }
    cout << str << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){
    int a, b, c, x, y, ans;

    cin >> a >> b >> c >> x >> y;

    ans = __INT_MAX__;

    for(int i = 0 ; i <= 100000; i++){
        ans = min(ans, 2*i*c + max(0, x-i)*a + max(0, y-i)*b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long e = lcm(c,d);
    long count = b-a+1;
    count -= b/c - (a-1)/c;
    count -= b/d - (a-1)/d;
    count += b/e - (a-1)/e;
    System.out.println(count);

  }

  private static long lcm(long a, long b){
    long temp;
    long c = a;
    c *= b;
    while((temp = a%b)!=0){
      a=b;
      b=temp;
    }
    return c/b;
  }
}


Measured memory_bytes: 35564
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin(), K = Cin();
    vector<LLONG> ps(N);
    for (auto &pi : ps) cin >> pi;
    LLONG sum = 0;
    for (int i = 0; i < K; ++i) sum += ps[i];
    LLONG maxSum = sum;
    for (int i = K; i < N; ++i)
    {
        sum -= ps[i - K];
        sum += ps[i];
        maxSum = max(maxSum, sum);
    }
    cout << setprecision(12) << static_cast<double>(maxSum + K) / 2.0 << endl;
}


Measured memory_bytes: 1792
abcd = input()
a, b, c, d = abcd
# 0 = -, 1 = + bit探索

for i in range(2**3):
    sum = int(a)
    for j in range(3):
        if (i >> j) & 1:
            sum += int(abcd[3-j])
        else:
            sum -= int(abcd[3-j])

    if sum == 7:
        formula = str(format(i, '03b')).translate(str.maketrans('10', '+-'))
        print(a + formula[0] + b + formula[1] + c + formula[2] + d + '=7')
        break

Measured memory_bytes: 3064
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=int(input())
        max=a
        min=a
        sum=a
        for i in range(1,n):
            b=int(input())
            sum=sum+b
            if max<b:
                max=b
            elif min>b:
                min=b
        print(int((sum-max-min)/(n-2)))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int flag=0,countC=0;
    for (int i=0;i<s.size();i++) {
        if (s.at(0)!='A') {
            cout<<"WA"<<endl;
            flag=1;
            break;
        } else {
            if (i>=2&&i<=s.size()-2) {
                if (s.at(i)=='C') {
                    if (countC==0) {
                        countC++;
                    } else {
                        cout<<"WA"<<endl;
                        flag=1;
                        break;
                    }
                }
                if (i==s.size()-2&&countC==0) {
                    cout<<"WA"<<endl;
                    flag=1;
                    break;
                }
            } else {
                if (i!=0&&islower(s.at(i))==0) {
                    cout<<"WA"<<endl;
                    flag=1;
                    break;
                }
            }
        }
    }
    if (flag==0) {
        cout<<"AC"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<fstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define N 200005
int n,a[N],b[N],l,r;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	l=b[n/2-1];
	r=b[n/2];
	for(int i=0;i<n;i++)
	{
		if(a[i]<=l)printf("%d\n",r);
		else printf("%d\n",l);
	}
	return 0;
}

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

int main()
{
  int n;
  
  cin >> n;
  
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) {
      cout << " " << i;
      continue;
    }
    
    int x = i;
    while (x > 0) {
      if (x % 10 == 3) {
      	cout << " " << i;
      	break;
      }
      x /= 10;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3104
x,y=map(int,input().split())
res = 0
if 0<=x<=y:
    res = y-x
elif 0<y<x:
    res = x-y+2
elif y==0 and x>0:
    res = x+1
elif y==0 and x<0:
    res = abs(x)
elif x==0 and y>0:
    res = y
elif x==0 and y<0:
    res = abs(y)+1
elif x<0<y:
    res = abs(x+y)+1
elif y<0<x:
    res = abs(x+y)+1
elif x<=y<=0:
    res = y-x
elif y<x<=0:
    res = x-y+2
print(res)


Measured memory_bytes: 3064
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    s,t=map(int,input().split())
    a.append(s)
    b.append(t)

c=[]
d=[]
for i in range(m):
    u,v=map(int,input().split())
    c.append(u)
    d.append(v)

for i in range(n):
    min=19**9+1
    arg=1
    for j in range(m):
        if min > abs(a[i]-c[j])+abs(b[i]-d[j]):
            min = abs(a[i]-c[j])+abs(b[i]-d[j])
            arg = j+1
    print(arg)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, i;
	cin >> n;
	vector<int> a(n);
	roop(i, n) {
		cin >> a[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	int average = round((double)sum / (double)n);
	int ans = 0;
	roop(i, n) {
		ans += myPower((a[i] - average), 2);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[0]*m

for i in range(n):
  k=[int(x) for x in input().split()]
  for i in range(1,k[0]+1):
    l[k[i]-1] += 1

c=0
for i in range(m):
  if l[i]==n:
    c +=1

print(c)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] ok = new boolean[11];
        Arrays.fill(ok, true);
        for (int i = 0; i < k; i++) {
            int num = sc.nextInt();
            ok[num] = false;
        }
        
        // que: ルンルン数(次の桁に-1～+1で行ける)
        // ex. 334, 2123, 3234566667
        Queue<Integer> que = new ArrayDeque<Integer>();
        
        // 1～9からBFSスタート
        for (int i = 1; i <= 9; i++) {
            if (ok[i]) {
                que.add(i);
            }
        }
        
        while (!que.isEmpty()) {
            int cur = que.poll();
            int x10 = cur * 10;
            
            // 終了条件: k番目の数が取り出された
            if (cur >= n) {
                System.out.println(cur);
                return;
            }
            
            // 次の桁(-1, 0, +1)の3パターンをキューに入れる
            for (int i = 0; i <= 9; i++) {
                if (ok[i]) {
                    que.add(x10 + i);
                }
            }
        }
    }
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string data;
  cin>>data;
  if(data.at(2)==data.at(3)&&data.at(4)==data.at(5))
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
    
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,x ;
   cin >> a >> b >> c >> x ;
   int count = 0;
   for(int i=0;i<=a;i++){
     for(int j=0;j<=b;j++){
      for(int k=0;k<=c;++k){
        if((i*500+j*100+k*50)==x)count++ ;
      }
     }
   }
  
  cout << count << endl ;
    return 0;
}


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

int main(){
  char str[3];
  cin >> str;
  int top=0;
  int i;

  for(i=0; i<3; i++){
    if(str[i]=='o'){
      top += 100;
    }
  }

  cout << top+700 << "\n";

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L, R, D):
    return R // D - (L-1) // D


def main():
    L, R, D = read_int_n()
    print(slv(L, R, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

struct edge{
    int to,id;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vvec<edge> g(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back({b,i});
        g[b].push_back({a,i});
    }
    int M;
    cin >> M;
    vec<P<int,int>> rest(M);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        rest[i] = {a,b};
    }

    vec<ll> beki2(51,1);
    for(int i=1;i<=50;i++) beki2[i] = beki2[i-1]*2;

    vec<bitset<50>> sets;
    auto calc = [&](int x){
        bitset<50> s;
        auto dfs = [&](auto&& self,int cur,int par,int en)->bool{
            bool ok = false;
            if(cur==en) return true;
            for(auto& e:g[cur]) if(e.to!=par){
                bool res = self(self,e.to,cur,en);
                if(res){
                    s.set(e.id);
                    return true;
                }
            }
            return false;
        };

        dfs(dfs,rest[x].first,-1,rest[x].second);

        return s;
    };

    ll ans = 0;

    for(int i=0;i<M;i++) sets.push_back(calc(i));

    for(int S=0;S<(1<<M);S++){
        int n = __builtin_popcount(S);
        bitset<50> ns;
        for(int i=0;i<M;i++) if(S&(1<<i)) ns |= sets[i];
        ll c = beki2[N-1-ns.count()];
        ans += (n%2? -c:c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	double ans=0;
	int n;cin>>n;
	if(n%2==0)cout<<0.5<<"\n";
	else{
		double m=(double)n;
		cout<<setprecision(8)<<(m+1)/(2*m)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
//061 C - Big Array 2017/05/13

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

/*
int main(){
    int64 n , k; cin >> n >> k;
    int64 num[100001]={0};
    rep(i ,n){
        int a , b;
        cin >> a >> b;
        num[a]+=b;
    }
    rep(i , 1000001){
        if(k <= num[i]){
            cout << i << endl;
            break;
        }
        k -=num[i];
    }
}
*/
int main(){
    int64 n , k; cin >> n >> k;
    vector<pair<int,int>> p(n);
    rep(i , n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    int64 sum=0;int64 i=0;
    for(;i<n;++i) {
        sum+=p[i].second;
        if(sum >= k) break;
    }
    cout << p[i].first << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int n=in();
    rep(i,9)rep(j,9){
        if((i+1)*(j+1)==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,n,k,p,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&k,&p);
		a=k%p;
	printf("%d\n",a==0?p:a);
	}
	return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<cmath>
using namespace std;
#define TRIQ(z) ((z)*(z)*(z))
int main(){
	while(true){
		int ans = 1<<30;
		int z;
		int tz;
		scanf("%d", &z);
		if( z==0 )break;

		tz = TRIQ(z);
		for(int x=1;x<=z;++x){
			int tx = TRIQ(x);
			int y = (int)floor( pow(tz-tx,(double)1/3) );
			int ty = TRIQ(y);
			if( tz >= tx + ty && y > 0 && x > 0 )
				ans = min( ans, tz-(tx+ty) );
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (true) {
			int n = sc.nextInt(); int x = sc.nextInt();
			if (n==0 && x==0) return;
			int sum = 0;
			for (int i=1; i<=n-2; i++) {
				for (int j=i+1; j<=n-1; j++) {
					for (int k=j+1; k<=n; k++) {
						if (i+j+k == x) sum++;
					}
				}
			}
			System.out.println(sum);
		}
		
		
	}
}



Measured memory_bytes: 26428
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int x,y; cin >> x >> y;
    rep(i,x+1) {
        if (y==2*i+4*(x-i)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UF{
    vector<int>p,r;

    void makeSet (int x)
    {
        p.push_back(x);
        r.push_back(0);
    }
    int find(int x)
    {
        if(x==p[x])return x;
        return p[x]=find(p[x]);
    }
    void join(int x,int y)
    {
        x=find(x);
        y=find(y);
        if(x!=y)
        {
            if(r[x]>=r[y])
            {
                if(r[x]==r[y])
                    r[x]++;
                p[y]=x;
            }
            else p[x]=y;
        }
    }
};
int main()
{
    UF sd;
    int v,e,s,t,w,sum=0;
    vector<tuple<int,int,int> >c;
    cin>>v>>e;
    for(int i=0;i<v;i++)
    {
        sd.makeSet(i);
    }
    for(int i=0;i<e;i++)
    {
        cin>>s>>t>>w;
        c.push_back(make_tuple(w,s,t));
    }
    sort(c.begin(),c.end());
    for(int i=0;i<e;i++)
    {
        if(sd.find(get<1>(c[i]))!=sd.find(get<2>(c[i])))
        {
            sd.join(get<1>(c[i]),get<2>(c[i]));
            sum+=get<0>(c[i]);
        }
    }
    cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 4768
N = int(input())
W = list(map(int,input().split()))

S = []
S1 = 0
totalW = sum(W)
S2 = totalW
#print("W,S1,S2=",W,S1,S2)
for i in range(N):
    S1 = S1 + W[i]
    S2 = S2 - W[i]
#    print("i,S1,S2=",i,S1,S2)
    delS = abs(S1-S2)
    S.append(delS)
#    print(S)
print(min(S))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    int N;
    cin >> N;
    vector<pair<int,int>> pairs(N);
    int As[N];
    REP(i,N) {
        int t;
        cin >> t;
        pairs[i] = make_pair(i+1,t);
    }
    sort(ALL(pairs),compare_by_b);
    string s;
    REP (i,N) {
        s+=to_string(pairs[i].first);
        s+=" ";
    }
    s.erase(--s.end());
    cout << s << endl;

    return 0;
}


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

int main() {
  int x;
  cin >> x;
  int i = 0;
  while(x>0) {
    x -= i+1;
    i++;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll minCost(vector<ll> heights,ll k)
{
    if(heights.size()==0)
        return 0;
    else if(heights.size()==1)
        return abs(heights[0]-heights[1]);
    vector<ll> dp(heights.size(),INT_MAX);
    dp[0] = 0;
    for(ll i=1;i<heights.size();i++)
    {
        ll temp = 1;
        while(temp<=i && temp<=k)
        {
            dp[i]=min(dp[i],dp[i-temp]+abs(heights[i-temp]-heights[i]));
            temp++;
        }
    }
    
    return dp[heights.size()-1];
}
int main()
{
    ll n,temp,k;
    cin>>n>>k;
    vector<ll> inpArr;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        inpArr.push_back(temp);
    }
    cout<<minCost(inpArr,k)<<endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> B;
	for (int i = 0; i < N; i++) {
		int b; cin >> b; b--;
		B.push_back(b);
	}

	vector<int> ops;
	while (!B.empty()) {
		int cur = -1;
		for (int i = 0; i < int(B.size()); i++) {
			if (B[i] == i) {
				cur = i;
			}
		}
		if (cur == -1) {
			cout << -1 << '\n';
			exit(0);
		}
		assert(B[cur] == cur);
		ops.push_back(cur);
		B.erase(B.begin() + cur);
	}
	reverse(ops.begin(), ops.end());
	for (int i : ops) {
		cout << i+1 << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
from itertools import product
from collections import deque
import sys
sys.setrecursionlimit(100000)


def read():
    s = input()
    t = input()
    return s, t


def lcs(s, t):
    S = len(s)
    T = len(t)
    dp = [[0 for j in range(T+1)] for i in range(S+1)]
    for i, j in product(range(S), range(T)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
    maxpos = (0, 0)
    maxv = dp[0][0]
    for i, j in product(range(S), range(T)):
        if maxv < dp[i+1][j+1]:
            maxpos = (i, j)
            maxv = dp[i+1][j+1]
    return maxpos, dp


def retrieve(s, t, i, j, dp):
    x = list()
    while i >= 0 and j >= 0:
        if dp[i+1][j+1] == dp[i+1][j]:
            j -= 1
        elif dp[i+1][j+1] == dp[i][j+1]:
            i -= 1
        else:
            x.append(s[i])
            i -= 1
            j -= 1
    return ''.join(reversed(x))


def solve(s, t):
    maxpos, dp = lcs(s, t)
    i, j = maxpos
    ans = retrieve(s, t, i, j, dp)
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 122204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

Measured memory_bytes: 256