akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<char>> v(3,vector<char>(3));
  REP(i,3) {
    REP(j,3) cin >> v[i][j];
  }
  cout << v[0][0] << v[1][1] << v[2][2] << endl;
}

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

int main()
{
    int a, b, n;

    cin >> a >> b >> n;

    int c[n], d[n];

    for( int i = 0; i < n; i++ )
        cin >> c[i] >> d[i];
    
    bool j = false;
    for( int i = 0; i < n; i++ )
    {
        if( d[i] <= a );
        else if( b <= c[i] );
        else
        {
            j = true;
            break;
        }
    }

    cout << j << endl;

    return 0;
}


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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	int A[N];
	int B[N];

	for (int i=0; i<N; i++){
		cin >> A[i];
	}
	for (int i=0; i<N; i++){
		cin >> B[i];
	}

	vector<int> diff(N);
	for (int i=0; i<N; i++){
		diff[i] = A[i] - B[i];
	}
	sort(diff.begin(),diff.end());

	long long minus_sum = 0;
	int minus_num = 0;

	for (int i=0; i<N; i++){
		if (diff[i] < 0){
			minus_sum += diff[i];
			minus_num += 1;
		}
		else{
			break;
		}
	}

	if (minus_num == 0){
		cout << 0 << endl;
		return 0;
	}

	for (int i=1; i<=N; i++){
		if (diff[N-i] > 0){
			minus_sum += diff[N-i];
			if (minus_sum >= 0){
				cout << minus_num + i << endl;
				return 0;
			}
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}

}

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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define pb push_back
#define mk make_pair
#define MAX 100010
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef unsigned long long int ull;
vector<int> adj[MAX];
int pd[MAX];

int solve(int u) {
	int &ans = pd[u];
	if(ans != -1) return ans;
	int t = adj[u].size();
	ans = 0;
	rep(i, 0, t) {
		int v = adj[u][i];
		ans = max(ans, solve(v)+1);
	}
	return ans;
}

int main(int argc, char** argv) {
	int N, M, a, b, ans = 0;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &a, &b);
		adj[a].pb(b);
	}
	memset(pd, -1, sizeof pd);
	REP(i, 1, N) ans = max(ans, solve(i));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    string A,B,C,ans;
    cin >> A >> B >> C;
    ans = A[0];
    ans += B[0];
    ans += C[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 50;

class State{
public:
  int ly, lx, ry, rx;
};

int h, w;

bool visited[N][N][N][N];
char data[2][N][N];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

bool bfs(int sly, int slx, int sry, int srx){
  State u, v;
  u.ly = sly;
  u.lx = slx;
  u.ry = sry;
  u.rx = srx;
  queue<State> Q;
  Q.push(u);
  while(!Q.empty()){
    u = Q.front(); Q.pop();
  //cout << ly << ' ' << lx << ' ' << ry << ' ' << rx << endl;
    if(data[0][u.ly][u.lx] == '%' && data[1][u.ry][u.rx] == '%') return true;
    else if(data[0][u.ly][u.lx] == '%' || data[1][u.ry][u.rx] == '%') continue;
    for(int i=0;i<4;i++){
      int lty = u.ly + dy[i];
      int ltx = u.lx + dx[i];
      int rty = u.ry + dy[i];
      int rtx = u.rx - dx[i];
      //cout << "       " << lty << ' ' << ltx << ' ' << rty << ' ' << rtx << endl;
      if(lty<0 || lty>=h){
	lty = u.ly;
	ltx = u.lx;
      }
      if(ltx<0 || ltx>=w){
	lty = u.ly;
	ltx = u.lx;
      }
      if(rty<0 || rty>=h){
	rty = u.ry;
	rtx = u.rx;
      }
      if(rtx<0 || rtx>=w){
	rty = u.ry;
	rtx = u.rx;
      }
      if(data[0][lty][ltx] == '#'){
	lty = u.ly;
	ltx = u.lx;
      }
      if(data[1][rty][rtx] == '#'){
	rty = u.ry;
	rtx = u.rx;
      }
      if(visited[lty][ltx][rty][rtx]) continue;
      visited[lty][ltx][rty][rtx] = true;
      v.ly = lty;
      v.lx = ltx;
      v.ry = rty;
      v.rx = rtx;
      Q.push(v);
    }
  }
  return false;
}

main(){
  int slx, sly, srx, sry;
  while(cin >> w >> h){
    if(h == 0 && w == 0) break;
    fill(visited[0][0][0], visited[N][0][0], false);
    for(int i=0;i<h;i++){
      for(int k=0;k<2;k++){
	for(int j=0;j<w;j++){
	  cin >> data[k][i][j];
	  if(data[k][i][j] == 'L'){
	    slx = j;
	    sly = i;
	    data[k][i][j] = '.';
	  }else if(data[k][i][j] == 'R'){
	    srx = j;
	    sry = i;
	    data[k][i][j] = '.';
	  }
	}
      }
    }
    if(bfs(sly, slx, sry, srx)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int main()
{
    int k,a,b;
    scanf("%d %d %d",&k,&a,&b);
    int x=a/k;
    if((k*x>=a&&k*x<=b)||(k*(x+1)>=a&&k*(x+1)<=b)){
        cout<<"OK";
    }else{
        cout<<"NG";
    }
    return 0;
}

Measured memory_bytes: 3168
using System;

namespace abc156_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nStr = Console.ReadLine().Split();
            int N = int.Parse(nStr[0]);
            int R = int.Parse(nStr[1]);

            if(N >= 10)
            {
                Console.WriteLine(R);
            }
            else
            {
                int RAns = R + (100 * (10 - N));
                Console.WriteLine(RAns);
            }
        }
    }
}


Measured memory_bytes: 27480
H, W, K = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n - 2):
            a, b = b, a + b
        return b


dp = [[0 for j in range(W + 5)] for i in range(H + 5)]  # dp[h][k]
dp[0][1] = 1
for i in range(1, H + 1):
    for j in range(1, W + 1):
        for t in [-1, 0, 1]:
            if 1 <= j + t <= W:
                used = [0 for _ in range(W + 1)]
                for y in [j, j - 1, j + t, j + t - 1]:
                    if y >= 0:
                        used[y] = 1
                l = -(used[0] == 0)
                for x in used:
                    if x == 0:
                        l += 1
                    else:
                        break
                r = -(used[W] == 0)
                for x in used[::-1]:
                    if x == 0:
                        r += 1
                    else:
                        break
                dp[i][j] += Fib(l + 3) * Fib(r + 3) * dp[i - 1][j + t]
                dp[i][j] %= mod
print(dp[H][K])

Measured memory_bytes: 3064
use std::io;
use std::collections::HashSet;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let N = read_line().parse::<i64>().unwrap();
    let mut d:Vec<i64> = Vec::new();
    for _ in 0..N {
        d.push(read_line().parse::<i64>().unwrap());
    }
    let uniq:HashSet<i64> = d.into_iter().collect();
    println!("{}",uniq.len());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) cin >> a[i];
    ll b = 0;
    rep(i, n) {
        rep(j, n) {
            if (a[i] > a[j]) {
                if (j > i) {
                    b += k;
                    b %= MOD;
                }
                b += k * (k-1) / 2;
                b %= MOD;
            }
        }
    }

    cout << b << endl;
    return 0;
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<vector<int>> to(n),cost(n);
    for(int i=0;i<n-1;i++){
        int a,b,w;
        cin >> a >> b >> w;
        a--; b--;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }
    vector<int> ans(n,-1);
    queue<int> q;
    ans[0] = 0; q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i=0;i<to[v].size();i++){
            int u = to[v][i];
            int w = cost[v][i];
            if(ans[u] != -1) continue;
            ans[u] = (ans[v]+w)%2;
            q.push(u);
        }
    }
    for(int i=0;i<n;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11904
import java.awt.Polygon;
import java.awt.geom.Line2D;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		while(true){
			int n = Integer.parseInt(scan.next());
			if(n==0) break;

			for (int i = 0; i < n; i++) {
				int m = Integer.parseInt(scan.next());
				Polygon[] tetragon = new Polygon[m];
				Line2D[][] lines = new Line2D[m][4];
				for (int j = 0; j < m; j++) {
					int[] xs = new int[4];
					int[] ys = new int[4];
					for (int j1 = 0; j1 < 4; j1++) {
						xs[j1] = Integer.parseInt(scan.next());
						ys[j1] = Integer.parseInt(scan.next());
					}
					tetragon[j] = new Polygon(xs,ys,4);
					for (int k = 0; k < 4 ; k++) {
						lines[j][k] = new Line2D.Double(xs[k], ys[k], xs[(k+1)%4], ys[(k+1)%4]);
					}
				}

				UnionFin uni = new UnionFin(m);
				for (int j = 0; j < m; j++) {
					for (int j2 = j+1; j2 < m; j2++) {
						boolean flag= false;
						if(tetragon[j].contains(tetragon[j2].xpoints[0],tetragon[j2].ypoints[0]) || tetragon[j2].contains(tetragon[j].xpoints[0],tetragon[j].ypoints[0]))
							flag=true;
						for (int k = 0; k < 4; k++) {
							for (int k2 = 0; k2 < 4; k2++) {
								if(lines[j][k].intersectsLine(lines[j2][k2])) flag=true;
							}
						}
						if(flag) uni.unite(j, j2);
					}
				}
				out.println(uni.num);
			}
		}
		out.flush();
	}
}

class UnionFin {

	int[] par;
	int[] rank;
	int num;

	UnionFin(int n){
		num=n;
		par = new int[n];
		rank = new int[n];

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

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

	void unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return;

		if(rank[x]<rank[y])
			par[x]=y;
		else{
			par[y]=x;
			if(rank[x]==rank[y])
				rank[x]++;
		}
		num--;
	}

	boolean isSame(int x,int y){
		return root(x)==root(y);
	}
}

Measured memory_bytes: 32420
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5924
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
ll ans;
int n;
struct node{
	int a1,a2,a3,a4;
	node() {}
	node(int aa1,int aa2,int aa3,int aa4):a1(aa1),a2(aa2),a3(aa3),a4(aa4) {}
	bool operator <(const node &a) const {
		if(a1!=a.a1)
			return a1<a.a1;
		if(a2!=a.a2)
			return a2<a.a2;
		if(a3!=a.a3)
			return a3<a.a3;
		return a4<a.a4;
	}
	bool operator ==(const node &a) const{
		if(a1==a.a1&&a2==a.a2&&a3==a.a3&&a4==a.a4)
			return 1;
		return 0;
	}
}t[MAXN];
map<node,ll> used;
void solve(int b1,int b2,int b3,int b4){
	used[node(b1,b2,b3,b4)]++;
}
ll check(node x,node y){
	ll res=0;
	if(x==y)
		res++;
	int tx=y.a1;
	y.a1=y.a2;y.a2=y.a3;y.a3=y.a4;y.a4=tx;
	if(x==y)
		res++;
	tx=y.a1;
	y.a1=y.a2;y.a2=y.a3;y.a3=y.a4;y.a4=tx;
	if(x==y)
		res++;
	tx=y.a1;
	y.a1=y.a2;y.a2=y.a3;y.a3=y.a4;y.a4=tx;
	if(x==y)
		res++;
	return res;
}	
void count(int b1,int b2,int b3,int b4,int b5,int b6,int b7,int b8){
	//PF("{%d %d %d %d %d %d %d %d}\n",b1,b2,b3,b4,b5,b6,b7,b8);
	node x1=node(b1,b2,b6,b5);
	node x2=node(b2,b3,b7,b6);
	node x3=node(b3,b4,b8,b7);
	node x4=node(b4,b1,b5,b8);
	node sp1=node(b4,b3,b2,b1);
	node sp2=node(b5,b6,b7,b8);
	ll res1=used[x1];
	ll res2=used[x2];
	ll res3=used[x3];
	ll res4=used[x4];
	res1=res1-check(sp1,x1)-check(sp2,x1);
	res2=res2-check(sp1,x2)-check(sp2,x2)-check(x1,x2);
	res3=res3-check(sp1,x3)-check(sp2,x3)-check(x1,x3)-check(x2,x3);
	res4=res4-check(sp1,x4)-check(sp2,x4)-check(x1,x4)-check(x2,x4)-check(x3,x4);
	ans+=res1*res2*res3*res4;
	//PF("{%lld %lld %lld %lld %lld}\n",used[x1],res1,check(sp1,x1),check(sp2,x1),res4);
}
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++){
		SF("%d%d%d%d",&t[i].a1,&t[i].a2,&t[i].a3,&t[i].a4);
		solve(t[i].a4,t[i].a3,t[i].a2,t[i].a1);
		solve(t[i].a3,t[i].a2,t[i].a1,t[i].a4);
		solve(t[i].a2,t[i].a1,t[i].a4,t[i].a3);
		solve(t[i].a1,t[i].a4,t[i].a3,t[i].a2);
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			count(t[i].a1,t[i].a2,t[i].a3,t[i].a4,t[j].a4,t[j].a3,t[j].a2,t[j].a1);	
			count(t[i].a1,t[i].a2,t[i].a3,t[i].a4,t[j].a3,t[j].a2,t[j].a1,t[j].a4);	
			count(t[i].a1,t[i].a2,t[i].a3,t[i].a4,t[j].a2,t[j].a1,t[j].a4,t[j].a3);	
			count(t[i].a1,t[i].a2,t[i].a3,t[i].a4,t[j].a1,t[j].a4,t[j].a3,t[j].a2);	
		}
	PF("%lld",ans/3ll);
}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)

int main(){
	int n;
	int k;
	cin >> n >> k;
	int i=0;
	int j=n;
	ll minsum=0;
	ll maxsum=0;
	ll ans=0;
	while(i < k) {
		minsum+=i; 
		i++;
	}
	//cout << minsum<<" ";
	while(j > n-k){
		maxsum+=j;
		j--;
	}
	//cout << maxsum<<" ";
	i--;
	j++;
	
	while(i <= n){
		//cout << maxsum << " " << minsum << "\n"; 
		ans+=(maxsum-minsum+1)  ;
		ans%=1000000007;
		j--;i++;
		maxsum+=j;
		minsum+=i;
		

	}
	cout << ans<<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n; cin >> n;
  if (n == 0) return cout << "0" << '\n', 0;
  string s;
  lint i = 0;
  while (n) {
    if (n % (1LL << (i + 1))) {
      s = "1" + s;
      n -= (i & 1 ? -1 : 1) * (1LL << i);
    } else s = "0" + s;
    i++;
  }
  cout << s << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(ll i=0; i<n; i++)
using namespace std;
typedef long long ll;

struct UnionFind {
    int p[100002];
    int N;
    UnionFind(int n){
        rep(i, n) p[i] = -1;
        N = n;
    }
    int parent(int k){
        int l=k;
        while(p[l] > -1){l = p[l];}
        if(k != l) p[k] = l;
        return l;
    }
    int unite(int a,int b){
        int x = parent(a);
        int y = parent(b);
        // cout << "before p["<<x<<"]="<<p[x] << ", p["<<y<<"]="<<p[y] << endl;
        if(x == y) return 0;
        if(p[x] > p[y]){ p[x] += p[y]; p[y] = x;}
        else{ p[y] += p[x]; p[x] = y;}
        // cout << "after p["<<x<<"]="<<p[x] << ", p["<<y<<"]="<<p[y] << endl;
        return 1;
    }
    int find(int a,int b){
        int x = parent(a);
        int y = parent(b);
        if(x == y) return 1;
        return 0;
    }
};

int main(){
    int n, m, k; cin >> n >> m >> k;
    int a[m], b[m], c[k], d[k];
    vector<int> dislike[n];
    vector<int> friends[n];
    UnionFind uf(n);
    rep(i, m){
        cin >> a[i] >> b[i];
        uf.unite(a[i]-1, b[i]-1);
        friends[a[i]-1].push_back(b[i]-1);
        friends[b[i]-1].push_back(a[i]-1);
    }
    rep(i, k){
        cin >> c[i] >> d[i];
        dislike[c[i]-1].push_back(d[i]-1);
        dislike[d[i]-1].push_back(c[i]-1);
    }
    rep(i, n){
        int minus=0;
        for(int j=0; j<dislike[i].size(); j++){
            minus += uf.find(i,dislike[i][j]);
        }
        for(int j=0; j<friends[i].size(); j++){
            minus += uf.find(i,friends[i][j]);
        }
        cout << -uf.p[uf.parent(i)]-minus-1;
        //cout << " "<< minus  <<" "<<-uf.p[uf.parent(i)]<< endl;
        if(i != n-1) cout << " ";
    }
    rep(i, n){
        //cout << uf.p[uf.parent(i)] << endl;
    }
}

Measured memory_bytes: 16208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    int n;  cin >> n;
    map<pair<ll, ll>, ll> key;
    priority_queue<tuple<ll, ll, ll>> que;
    REP(i, n){
        ll x, y;    cin >> x >> y;
        key[{x,y}] += 1;
        que.emplace(x+y, x, y);
    }

    ll res=0;   bool index=true;
    while(!que.empty()){
        tuple<ll, ll, ll> x = que.top();
        que.pop();
        
        if(index) res += get<1>(x);
        else res -= get<2>(x);
        index = !index;
    }
    cout << res << endl;
}

Measured memory_bytes: 9264
#include<iostream>
using namespace std;
int main()
{
	int D;//日数
	uint32_t c[26+1];// 満足度低下係数
	uint32_t s[365+1][26+1]; //d日目にコンテストタイプiを実施したときの満足度増加幅
	uint32_t t[365+1]; //D日目にどのコンテストタイプを実施するか
	
	// 入力
	cin >> D;
	for(int i = 1; i <= 26; ++i) {
		cin >> c[i];
	}
	for(int i = 1; i <= D; ++i) {
		for(int j = 1; j <= 26; ++j) {
			cin >> s[i][j];
		}
	}
	//for(int i = 1; i <= D; ++i) {
	//	cin >> t[i];
	//}
	
	//計算
	int last[26+1];
	
	
	for(int d = 1; d <= D; ++d) {
		
		int32_t max_v = 0; //最大満足度
		int type = 1;
		for(int tmpType = 1; tmpType <=26; ++tmpType) {
			int32_t v = 0; //満足度
			
			//増加
			v += s[d][ tmpType ];
			//減少
			for(int i = 1; i <= 26; ++i) {
				v -= c[i] * (d - last[i]);
			}
			v += c[tmpType] * (d - last[tmpType]);
			if ( v > max_v) {
				max_v = v;
				type = tmpType;
			}
		}
		
		last[type] = d;
		cout << type << endl;
	}
	

	return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define debug(x) cout<<#x<<": "<<x<<endl

typedef long long ll;

typedef complex<ll> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

bool compy(const Point &a, const Point &b) {
    return a.Y < b.Y;
}

int main(void){
    int N,K;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K;
    VP p(N);
    rep(i,N){
        ll x,y;
        cin>>x>>y;
        p[i] = Point(x,y);
    }
    sort(all(p));
    ll res = LLONG_MAX;
    rep(r,N)rep(l,r){
        ll w = p[r].X-p[l].X;
        if(r-l+1<K)continue;
        VP pp;
        for(int i=l;i<=r;i++){
            pp.push_back(p[i]);
        }
        int n = pp.size();
        sort(all(pp),compy);
        rep(i,n-K+1){
            ll h = pp[i+K-1].Y-pp[i].Y;
            res = min(res,w*h);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# 左端から考えていった場合
# 考えうるK区間を全探索して、最小の時間を出力すれば良い
N, K =  map(int, sys.stdin.readline().split())
L =  list(map(int, sys.stdin.readline().split()))

d = 10 ** 10
for i in range(N - K + 1):
    left_search = abs(L[i]) + abs(L[i + K - 1] - L[i])
    right_search = abs(L[i + K - 1]) + abs(L[i + K - 1] - L[i])
    d = min(d, min(left_search, right_search))

print(d)

Measured memory_bytes: 84332
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	s := nextWord()
	count := 0
	for _, c := range s {
		if c == '1' {
			count++
		}
	}
	fmt.Println(count)
}

func nextWord() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def fast_pow(num, kata, mod):
    if kata == 0:
        return 1

    res = 1
    while kata > 0:
        if kata & 1 == 1:
            res = res * num % mod
        num = num * num % mod

        kata >>= 1
    return res


def choose(n, r, MOD):
    res = 1
    fac = 1
    for i in range(r):
        res *= n - i
        res %= MOD
        fac *= i + 1
        fac %= MOD
    return res * fast_pow(fac, MOD - 2, MOD) % MOD


# nCrの左項にはn以外も来るバージョン、1!～(n-1)!を保持
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def main():
    k = ni()
    s = input()
    l = len(s)

    # 使い方
    facts, invs = prepare(k + l, MOD)

    ans = 0
    for ki in range(k + 1):
        tmpa = fast_pow(25, k - ki, MOD)
        tmpb = fast_pow(26, ki, MOD)
        tmpc = facts[k - ki + l - 1] * invs[l - 1] * invs[k - ki + l - 1 - (l - 1)] % MOD
        tmpd = (tmpa * tmpb * tmpc) % MOD
        ans += tmpd
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 178620
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n, m;
		
	while(cin >> n, n) {
		cin >> m;
		string s;
		cin >> s;

		int ans = 0;
		vi dp(m, 0);
		FOR(i, 2, m-1) {
			if(s[i] == 'I') {
				if(s[i-1] == 'O') {
					if(s[i-2] == 'I') {
						dp[i] = dp[i-2]+1;
					}
				}
			}
		}

		REP(i, m) {
			if(n <= dp[i]) {
				ans++;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5988
H, W = map(int, input().split())
a = [input() for _ in range(H)]

WARU = 10**9+7

dp = [[0]*(W+1) for _ in range(H+1)]

dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            continue
        
        dp[i][j] %= WARU

        dp[i+1][j] += dp[i][j]
        dp[i][j+1] += dp[i][j]

print(dp[H-1][W-1])

Measured memory_bytes: 51824
#C
n=int(input())
inf=float("inf")
dp=[[-inf for i in range(3)] for j in range(n+1)]
dp[0][0]=0
dp[0][1]=0
dp[0][2]=0
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(3):
        cst_list=[]
        for k in range(3):
            if j!=k:
                cst_list.append(dp[i][k]+x[j])
        dp[i+1][j]=max(cst_list)
print(max(dp[n]))            
    
    

Measured memory_bytes: 92904
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
pair<string, pair<int,int>> a[101];
bool comp(pair<string, pair<int, int>> x, pair<string, pair<int, int>> y) {
	if (x.first == y.first) {
		return x.second.first > y.second.first;
	}
	return x.first < y.first;
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second.first;
		a[i].second.second = i + 1;
	}
	sort(a, a + n, comp);
	for (int i = 0; i < n; i++) {
		cout << a[i].second.second << '\n';
	}



}
// 335


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {

	long long n;

	std::cin >> n;

	std::vector<long long> v(n);
	long long ans = 0;

	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
		ans += v[i] - 1;
	}

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

	return 0;
}


Measured memory_bytes: 256
from math import factorial

n, m = map(int, input().split())
calc = pow(10, 9)+7

if abs(n-m) == 1:
    print(factorial(n) % calc * factorial(m) % calc)
elif abs(n-m) == 0:
    print((factorial(n) % calc * factorial(m) % calc *2) % calc)
else:
    print(0)

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

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k ;
	int ans = 1;
	while(n--)
	{
		if(2*ans > ans + k)
			ans += k;
		else
			ans *= 2;
	}

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

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

struct Rectangle {
    ll start, height;
};

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

    vector<ll> histogram(w + 1, 0);

    rep(x, w) cin >> histogram[x];

    ll ans = 0;
    stack<Rectangle> s;
    rep(x, w + 1) {
        Rectangle rectangle;
        rectangle.start = x;
        rectangle.height = histogram[x];
        if (s.empty()) s.push(rectangle);
        else {
            if (s.top().height < rectangle.height) {
                s.push(rectangle);
            } else if (s.top().height > rectangle.height) {
                ll target = x;
                while (!s.empty() && s.top().height >= rectangle.height) {
                    Rectangle pre = s.top();
                    s.pop();
                    ll size = pre.height * (x - pre.start);
                    cmax(ans, size);
                    target = pre.start;
                }
                rectangle.start = target;
                s.push(rectangle);
            }
        }
    }
    cout << ans << endl;

}





Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int c=0,x,y,z;
  for(int i=0;i<n;i++){
    x=a[i];
    for(int j=i+1;j<n;j++){
        if(a[j]!=a[i]){
            for(int k=j+1;k<n;k++){
                if((a[i]+a[j])>a[k]&&a[k]!=a[j])
                    c++;
            }
        }
    }
  }
  cout<<c<<"\n";
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args)throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");
        int n=Integer.parseInt(s[0].trim());
        int k=Integer.parseInt(s[1].trim());
        String[] s2=br.readLine().split(" ");
        long[] a=new long[n];
        for(int i=0;i<n;i++){
            a[i]=Long.parseLong(s2[i].trim());
        }
        algo(a,k);
    }
 
    public static void algo(long[] a,int k){
        long mul=0;
        for(int i=0;i<k;i++){
            mul+=a[i];
        }
 
        for(int i=k;i<a.length;i++){
            long r=(mul)-a[i-k];
            r=r+a[i];
            if(r>mul){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
            mul=r;
        }
    }
 
 
 
}

Measured memory_bytes: 92456
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	char s[101];
	scanf("%s", s);
	for(int i = 0; s[i] != '\0'; i++) {
		if(i % 2 == 0) {
			if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
				puts("No");
				return 0;
			}
		} else {
			if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
				puts("No");
				return 0;
			}
		}
	}

	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
import sys
import bisect
a,b,q=map(int,input().split())
s=sorted([int(input()) for i in range(a)])
t=sorted([int(input()) for i in range(b)])
i=0
for line in sys.stdin:
    ans=999999999999
    x=int(line)
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            tmp=abs(x-s[w-j])+abs(s[w-j]-t[z-k])
            if ans>tmp:
                ans=tmp
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            tmp=abs(x-t[w-j])+abs(t[w-j]-s[z-k])
            if ans>tmp:
                ans=tmp
    print(ans)
    i+=1

Measured memory_bytes: 95320
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long


ll pow2(ll p,ll n){
    long long num = 1;
    while(n){
        if(n%2 == 1){
            num *= p;
        }
        n/=2;
        p *= p;
    }
    return num;
}

int main(void){
    ll two[30];
    rep(i,30)two[i]=pow2(2,i+1);
    ll n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    rep(i,n){cin>>a[i];}
    sort(a,a+n);
    brep(i,30){
        int num = 0;
        brep(j,n){
            if(a[j]==-INT_MAX||a[j]>=two[i])continue;
            if(a[j]<(two[i]+1)/2)break;
            
            for(int k=num;k<j;k++){
                if(a[k]==-INT_MAX)continue;
                if(a[j]+a[k]==two[i]){
                    a[j] = -INT_MAX;
                    a[k] = -INT_MAX;
                    ans++;
                    num = k+1;
                    break;
                }
                else if(a[j]+a[k]>two[i]){num=k;break;}
            }
        }
    }
    //rep(i,n)cout <<a[i]<< endl;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n,k,m;
  while(cin>>n>>k>>m&&n+k+m){
    int a[10000];
    for(i=0;i<n;i++)
      a[i]=(i+1)%n;
    m-=2;
    if(m<0)
      m+=n;
    a[m]=a[a[m]];
    for(;n>1;n--){
      for(i=1;i<k;i++)
	m=a[m];
      a[m]=a[a[m]];
    }
    cout<<m+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]


int main() {

	Int N; cin >> N;
	Container P(N);
	rep(i, N)cin >> P[i];
	Int ans = 0;
	Int min = P[0];
	rep(i, N) {
		if (min >= P[i]) {
			ans++;
			min = P[i];
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve():
    # implement process
    pass

def main():
    # input
    s,t= input().split()
    
    # process
    ans = t+s
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
humu humu
"""
_EXPECTED = """\
humuhumu

"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 8992
N = input().split()
N = [int(n) for n in N]
#print(N)
c = 1001
for i in range(N[0]):
    #print(i)
    data = input().split()
    data = [int(n) for n in data]
    if(data[1]<=N[1]):
        if(data[0] < c):
            c = data[0]

if(c==1001):
    print('TLE')
else:
    print(c)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

#define MAX 10000

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

int main(int argc, char const *argv[])
{
	int H,i,A[MAX+1];

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

	for (int i = 1; i <= H; ++i)
	{
		cout<<"node "<<i<<": key = "<<A[i]<<", ";
		if (parent(i)>=1)
		{
			cout<<"parent key = "<<A[parent(i)]<<", ";
		}
		if (left(i)<=H)
		{
			cout<<"left key = "<<A[left(i)]<<", ";
		}
		if (right(i)<=H)
		{
			cout<<"right key = "<<A[right(i)]<<", ";
			
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3076
N, A, B, C, D = map(int, input().split())
S = input()

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+2):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int main() {
  int N, C, K;
  cin >> N >> C >> K;

  int T[N] = {0};
  for (int i = 0; i < N; i++) cin >> T[i];

  sort(T, T+N);

  queue<int> q;
  for (int i = 0; i < N; i++) q.push(T[i]);

  int buses = 0;
  while (0 < q.size()) {
    int first = q.front();
    q.pop();
    for (int i = 1; i < C && 0 < q.size(); i++) {
      int next = q.front();
      if (next <= first + K) q.pop();
      else break;
    }
    buses++;
  }

  cout << buses << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1000005

int W,M;
int input[NUM];
int number[NUM];
int BIT[NUM],ans[NUM];
vector<int> V[NUM];

int N;
int table[6*NUM];

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] += value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = max(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}

int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return -BIG_NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_max = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_max = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return max(left_max,right_max);
}

int main(){

	scanf("%d %d",&W,&M);

	if(M == 1){

		printf("0\n");
		return 0;
	}

	for(int i = 0; i < M; i++){

		number[i] = 0;
		ans[i] = BIG_NUM;
	}

	for(int i = 0; i < W; i++){

		scanf("%d",&input[i]);
		input[i]--;
		number[input[i]] += 1;
	}

	N = 1;
	init(M);

	int tmp;

	for(int start = 0; start <= 1; start++){

		for(int i = start; i+1 <= W-1; i += 2){

			V[input[i]].push_back(input[i+1]);
			V[input[i+1]].push_back(input[i]);
		}

		for(int i = 0; i <= 2*N-2; i++)table[i] = 0;

		for(int i = 0; i < M; i++){
			update(i,number[i]);
		}

		for(int i = 0; i < M; i++){

			for(int k = 0; k < V[i].size(); k++){

				update(V[i][k],-1);
			}
			tmp = max(query(0,i-1,0,0,N-1),query(i+1,M-1,0,0,N-1));

			ans[i] = min(ans[i],W-(number[i]+tmp));

			for(int k = 0; k < V[i].size(); k++){

				update(V[i][k],1);
			}
		}

		for(int i = 0; i < M; i++){
			V[i].clear();
		}
	}

	for(int i = 0; i < M; i++){

		printf("%d\n",ans[i]);
	}

	return 0;
}



Measured memory_bytes: 77776
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
ll p(ll a , ll n , ll mod){
    if(n == 0){
        return 1;
    }
    ll res = p((a*a)%mod, (n/2), mod);
    if(n&1){
        res = (res*a)%mod;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    if(n == 1){
        cout<<"0\n";
        return 0;
    }
    ll ans = p(10, n , MOD);
    ans -= 2LL * p(9 , n , MOD);
    ans += p(8, n , MOD);
    ans %= MOD;
    if(ans < 0){
        ans += MOD;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3640
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var K = parseInt(input[0])
var S = input[1]
var ans = (() => {
  if (K < S.length) {
    return S.substring(0, K) + '...'
  }
  return S
})()
console.log(ans)


Measured memory_bytes: 29684
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0]-1]

for i in range(1, N):
  ans += B[A[i]-1]
  if A[i] == A[i-1] + 1:
    ans += C[A[i-1]-1]
print(ans)


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


int n,x[110000];P p[110000];
signed main(){
  cin>>n;
  rep(i,n)cin>>p[i].first>>p[i].second;
  int li = 0, mi = 0;
  sort(p, p+n);
  rep(i,n){
    if(p[li].second - p[li].first < p[i].second - p[i].first)li = i;
    if(p[mi].second > p[i].second)mi = i;
  }
  int l = 0, r = INF;
  rep(i,n){
    if(i == li)continue;
    chmax(l, p[i].first);
    chmin(r, p[i].second);
  }
  int ans = p[li].second - p[li].first + 1 + max(0LL, r - l + 1), mm = INF, mx = 0;
  for(int i = n-1;i >= 0;i--){
    if(i == mi)continue;
    chmin(mm, p[i].second);
    chmax(mx, p[i].first);
    x[i] = max(0LL, mm-mx+1LL);
  }
  rep(i,n-1){
    if(i == mi || (i == n-2 && i+1 == mi))continue;
    int a = max(0LL, p[mi].second - p[i].first +1) + x[i+1];
    chmax(ans, a);
  }
  l = 0, r = INF;
  rep(i,n){
    if(i == mi)continue;
    chmax(l, p[i].first);
    chmin(r, p[i].second);
  }
  chmax(ans, max(0LL, p[mi].second - p[mi].first + 1) + max(0LL, r-l+1));
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdio>

const int N = 100 + 10;

int n, m;
int cnt[26];

bool check() {
  int cur[3] = {0, 0, 0};
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      ++cur[(i != n - 1 - i) + (j != m - 1 - j)];
  cur[1] /= 2, cur[2] /= 4;
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] & 1) {
      if (cur[0]) --cur[0], --cnt[i]; else return false;
    }
  }
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] % 4 == 2) {
      if (cur[1]) --cur[1], cnt[i] -= 2; else return false;
    }
  }
  return true;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char ch;
      scanf(" %c", &ch);
      ++cnt[ch - 'a'];
    }
  }
  puts(check() ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 1000010
#define inf 1e18

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return f ? -s : s;
}

struct Edge {
    int nxt;
    int to;
}e[MAXN];

int n, m, ans, tot;

int a[MAXN], head[MAXN];

inline void add(int from, int to) {
    e[++tot].to = to;
    e[tot].nxt = head[from];
    head[from] = tot;
}

void dfs(int x) {
    for (rr int i = head[x]; i; i = e[i].nxt) {
        int to = e[i].to;
        if (a[x] <= a[to])
            return ;
    }
    ans++;
}

signed main() {
    n = read();
    m = read();
    for (rr int i = 1; i <= n; i++) a[i] = read();
    for (rr int i = 1; i <= m; i++) {
        int x = read(), y = read();
        add(x, y);
        add(y, x);
    }
    for (rr int i = 1; i <= n; i++) dfs(i);
    cout << ans << "\n";
}

Measured memory_bytes: 8328
#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>;

void Main(void) { return; }

int main() {
  Main();
  char charS[11];
  char charT[11];
  bool flag = false;

  cin >> charS;
  cin >> charT;

  if (strlen(charS)+ 1 == strlen(charT)) {
    int i;
    for (i = 0; i < strlen(charS); i++) {
      if (charS[i] != charT[i]) {
              break;
      }
    }
    if (i == strlen(charS)) {
      flag = true;
    }
  }

  if (flag == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#define ri register int
using namespace std;
     
const int N = 2e5 + 50;
     
int n, v, m;
int lb[N], rb[N], ans[N];
int pre[N][18], nxt[N][18];
int a[N], f[1 << 18 | 5], g[1 << 18 | 5];

int main() {
  scanf("%d%d", &n, &v);
  int rec = v; v >>= 1;
  for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
  for (int t = v; t; t >>= 1) m ++;
  m ++;
  for (int j = 1; j < m; j ++)
    nxt[n + 1][j] = n + 1;
  lb[0] = 1; rb[n + 1] = n;
  for (ri i = 1; i <= n; i ++) {
    lb[i] = (a[i] - a[i - 1] > rec) ? i : lb[i - 1];
    for (ri j = 0; j < m; j ++)
      pre[i][j] = ((a[i] - a[i - 1]) > (v >> j)) ? i - 1 : pre[i - 1][j];
  }
  for (ri i = n; i; i --) {
    rb[i] = (a[i + 1] - a[i] > rec) ? i : rb[i + 1];
    for (ri j = 0; j < m; j ++)
      nxt[i][j] = ((a[i + 1] - a[i]) > (v >> j)) ? i + 1 : nxt[i + 1][j];
  }
  for (ri i = 0, l, r; i < (1 << m); i ++) {
    l = 1; r = n;
    for (ri j = 0; j < m; j ++)
      if ((i >> j) & 1) {
    	l = max(l, nxt[f[i ^ (1 << j)]][j]);
    	r = min(r, pre[g[i ^ (1 << j)]][j]);
      }
    f[i] = l; g[i] = r;
  }
  bool allok = 0;
  int U = (1 << m) - 1;
  for (ri i = 0, p; i < (1 << m); i ++) {
    p = rb[f[i]];
    if (g[U ^ i] <= p) ans[p] = 1;
    if (g[U ^ i] < f[i]) allok = 1;
  }
  for (int i = 1; i <= n; i ++)
    if (ans[rb[i]] || allok) puts("Possible");
    else puts("Impossible");
  return 0;
}


Measured memory_bytes: 35712