akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;

int main() {
     
     long long n,h,i,j,t,m,l,r,q;
     long long p=0,k,w,z,x,y,d,p1,h1;
     string s="",st="",s1="",s2="";
     q=1;
     for(l=0;l<q;l++)
     {
          std::cin >> n;
          int a[n];
          p=0;
          for(i=0;i<n;i++)
               cin>>a[i];
          for(i=0;i<n-1;i++)
          {
               if(a[i]>a[i+1])
                    p=p+(a[i]-a[i+1]),a[i+1]=a[i];
          }
          std::cout << p << std::endl;
     }
     return 0;
}

Measured memory_bytes: 4372
n = int(input())
b=[[0] * 2 for i in range(n)]
a = list((map(int,input().split())))
for i in range(n):
    b[i][0] = a[i]
    b[i][1] = i + 1


b.sort()

for i in range(n):
    print(b[i][1],end = ' ')

Measured memory_bytes: 24288
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ");
  let kari3 = input[1].trim().split(" ");

  let kari2 = kari.map(i => parseInt(i));
  let h = kari3.map(i => parseInt(i));
  h.sort(function(a, b) {
    return b-a;
  });

  let n = kari2[0];
  let k = kari2[1];

  if(k<=n){
    let sum = 0;
    for(let i=k;i<n;i++){
      sum += h[i];
    }
    console.log(sum);
  }else{
    console.log(0);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 34628
N = int(input())
X = [0]*N
A = [0]*N
sum_water = 0
A = list(map(int,input().split()))
for i in range(1,N+1):
    if(i % 2 != 0):
        sum_water += A[i-1]
    else:
        sum_water -= A[i-1]
X[0] = sum_water
for i in range(1,N):
    ans = 2*A[i-1] - sum_water
    X[i] = ans
    sum_water = ans
print(" ".join(map(str, X)))


Measured memory_bytes: 19124
#include<iostream>


using namespace std;
int max(int a, int b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}
int min(int a, int b) {
	if (a < b) {
		return a;
	}
	else {
		return b;
	}
}
int main()
{

	int A1, A2,A3;
	cin >> A1 >> A2 >> A3;
	cout << max(A1, max(A2, A3)) - min(A1, min(A2, A3));

	return 0;

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::VecDeque;

fn main() {
    let k: i64 = read();
    let mut vd: VecDeque<i64> = VecDeque::new();
    let mut cnt = 0;
    for i in 1..10 {
        vd.push_back(i);
    }
    let mut current = 0;

    while cnt < k {
        current = vd.pop_front().unwrap();
        cnt += 1;

        if current % 10 != 0 {
            vd.push_back(current * 10 + (current % 10 - 1));
        }

        vd.push_back(current * 10 + (current % 10));

        if current % 10 != 9 {
            vd.push_back(current * 10 + (current % 10 + 1));
        }
    }
    println!("{}", current);
}


Measured memory_bytes: 6396
# abc105_a.py
# https://atcoder.jp/contests/abc105/tasks/abc105_a

# A - AtCoder Crackers /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 高橋君は N枚の AtCoder せんべいを K 人の AtCoder 参加者になるべく公平に配ることにしました。 
# N枚すべてのせんべいを配るとき、せんべいを最も多くもらった人と最も少なくもらった人のもらったせんべいの枚数の差(の絶対値)の最小値を求めてください。

# 制約
#     1≤N,K≤100
#     入力はすべて整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N K

# 出力
# せんべいを最も多くもらった人と最も少なくもらった人のもらったせんべいの枚数の差(の絶対値)の最小値を出力せよ。

# 入力例 1
# 7 3

# 出力例 1
# 1
# 3人にそれぞれ 2,2,3 枚の AtCoder せんべいを配った場合、せんべいを最も多くもらった人と最も少なくもらった人のもらったせんべいの枚数の差(の絶対値)は 1です。

# 入力例 2
# 100 10

# 出力例 2
# 0

# 均等に配ることができます。

# 入力例 3
# 1 1

# 出力例 3
# 0


def calculation(lines):
    N, K = list(map(int, lines[0].split()))
    if N % K == 0:
        ret = 0
    else:
        ret = 1
    return [ret]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['7 3']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['100 10']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['1 1']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > pos (n + 1);
  for (int i = 1; i <= n; i++) {
    int a; cin >> a;
    pos[a] = i;
  }

  ll ans = 0;
  set < int > s;
  s.insert (0);
  s.insert (n + 1);
  for (int i = 1; i <= n; i++) {
    int idx = pos[i];
    auto it = s.lower_bound (idx);
    int r = *it - 1, l = *(--it) + 1;
    ans += (ll)(r - idx + 1) * (idx - l + 1) * (ll)i;
    s.insert (idx);
  }

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


Measured memory_bytes: 13428
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

template <class T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) : from(from), to(to), cost(cost){};

    bool operator<(const Edge<T>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<T>& e) const { return this->cost > e.cost; }
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(u, v, cost)); }
    vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    vector<vector<Edge<T>>> path;
};

class UnionFind {
public:
    vector<int> par, num;

    explicit UnionFind(int N) {
        par.resize(N);
        iota(par.begin(), par.end(), 0);
        num.assign(N, 1);
    }

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (num[u] < num[v]) swap(u, v);
        num[u] += num[v];
        par[v] = u;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return num[find(v)]; }
};

int main() {
    int N;
    cin >> N;
    vector<Edge<int>> edges;
    for (int u = 0; u < N; ++u) {
        for (int v = 0; v < N; ++v) {
            int c;
            cin >> c;
            if (u < v && c >= 0) edges.push_back(Edge<int>(u, v, c));
        }
    }
    sort(edges.begin(), edges.end());

    int ans = 0;
    UnionFind uf(N);
    for (const auto& e : edges) {
        if (uf.same(e.from, e.to)) continue;
        ans += e.cost;
        uf.unite(e.from, e.to);
    }

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



Measured memory_bytes: 3092
from collections import deque

def read_pair():
    return map(int, input().strip().split())

# Read graph
N, M = read_pair()
adj = [[] for x in range(N)]
rev = [[] for y in range(N)]

outdegree = [0] * N
for i in range(M):
    x, y = read_pair()

    # Use 0-indexed labels
    x -= 1
    y -= 1

    adj[x].append(y)
    rev[y].append(x)
    outdegree[x] += 1

maxpath = [0] * N
q = deque()

for x in range(N):
    if outdegree[x] == 0:
        q.append(x)

while q:
    x = q.popleft()
    for y in adj[x]:
        maxpath[x] = max(maxpath[x], 1 + maxpath[y])
    for z in rev[x]:
        outdegree[z] -= 1
        if outdegree[z] == 0:
            q.append(z)

print(max(maxpath))


Measured memory_bytes: 40592
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

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

	int n;
	cin >> n;

	map<string, long long> mp;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		sort(s.begin(), s.end());
		mp[s]++;
	}
	long long ans = 0;
	for (auto p : mp)
	{
		ans += ((p.second) * (p.second - 1)) / 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11264
#include<set>    
#include<map>    
#include<stack>    
#include<ctime>    
#include<cstdio>    
#include<queue>    
#include<cmath>    
#include<vector>    
#include<cstring>   
#include<climits>    
#include<iostream>   
#include<algorithm>
using namespace std;
#define LL long long
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
}
#define MAXN 12000
#define INF 0x3f3f3f3f
int Mod;
int Pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod,y>>=1;
	}
	return ret;
}
int f[MAXN+5][MAXN+5],inv[MAXN+5];
int main(){
	int n=read(),O=3*n;
	Mod=read();
	for(int i=1;i<=3*n;i++)
		inv[i]=Pow(i,Mod-2);
	f[0][O]=1;
	for(int i=1;i<=3*n;i++)
		for(int j=0;j<=6*n;j++){
			f[i][j]+=f[i-1][j-1];
			if(f[i][j]>=Mod) f[i][j]-=Mod;
			if(i>=2)
				f[i][j]+=f[i-2][j+1];
			if(f[i][j]>=Mod) f[i][j]-=Mod;
			if(i>=3)
				f[i][j]+=f[i-3][j];
			if(f[i][j]>=Mod) f[i][j]-=Mod;
			f[i][j]=1ll*f[i][j]*inv[i]%Mod;
		}
	int ans=0,n3=1;
	for(int i=1;i<=3*n;i++)
		n3=1ll*n3*i%Mod;
	for(int i=O;i<=6*n;i++)
		ans=(ans+1ll*n3*f[3*n][i]%Mod)%Mod;
	printf("%d\n",ans);
	return 0;
}


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

string N;
int n, k;
ll f[105][2][10];

ll dq(int id, int tight, int cnt) {
  if (id == 0)
    return (cnt == k);
  if (cnt > k)
    return 0;
  if (f[id][tight][cnt] != -1)
    return f[id][tight][cnt];

  ll res = 0;
  int k = tight ? (N[n - id] - '0') : 9;
  for (int i = 0; i <= k; ++i) {
    res += dq(id - 1, tight && (i == k), cnt + (i != 0));
  }

  return (f[id][tight][cnt] = res);
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> N >> k;
  n = N.length();
  memset(f, -1, sizeof(f));
  cout << dq(n, 1, 0);
  return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    int mass[52][52];
    char c;
    for(int i=0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            if(i == 0 || i == H+1 || j == 0 || j == W+1){
                mass[i][j] = 0;
                continue;
            }
            cin >> c;
            if(c == '#'){
                mass[i][j] = 1;
            }else{
                mass[i][j] = 0;
            }
        }
    }
    for(int i=1; i<H+1; i++){
        for(int j=1; j<W+1; j++){
            if(mass[i][j] && !mass[i-1][j] && !mass[i][j+1] && !mass[i+1][j] && !mass[i][j-1]){
                cout << "No";
                return EXIT_SUCCESS;
            }
        }
    }
    cout << "Yes";
    return EXIT_SUCCESS;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);



int main () {
  int n, c;
  cin >> n >> c;
  vii d(c, vi(c));
  rep (i, c) {
    rep (j, c) {
      cin >> d[i][j];
    }
  }
  vii a(n, vi(n));
  rep (i, n) {
    rep (j, n) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  vii sum(3, vi(c));
  rep (i, n) {
    rep (j, n) {
      rep (k, c) {
        sum[(i + j) % 3][k] += d[a[i][j]][k];
      }
    }
  }
  int ans = inf;
  rep (i, c) {
    rep (j, c) {
      if (i == j) {
        continue;
      }
      rep (k, c) {
        if (i == k || j == k) {
          continue;
        }
        chmin(ans, sum[0][i] + sum[1][j] + sum[2][k]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(1000000)
 
def dfs(l,d,k):
  for i in l[k]:
    if d[i[0]]==-1:
      d[i[0]]=d[k]+i[1]
      dfs(l,d,i[0])

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append([l[i][1]-1,l[i][2]])
  connection[l[i][1]-1].append([l[i][0]-1,l[i][2]])
distance=[-1 for i in range(n)]
x=-1
for i in range(n-1):
  if len(connection[i])==1:
    x=i
    break
distance[x]=0
dfs(connection,distance,x)
for i in range(n):
  print(distance[i]%2)

Measured memory_bytes: 146800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    ll sum = 0;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a.begin(),a.end());
    // a.push_back(0);

    for(int i=0;i<n-1;i+=2){
        if(a[i]>=0 && a[i+1]>=0) break;

        if(a[i]<0 && a[i+1]<0){
            a[i] *= -1;
            a[i+1] *= -1;
        }
        else if(a[i]<0 && a[i+1]>=0){
            if(abs(a[i]) > abs(a[i+1])){
                a[i] *= -1;
                a[i+1] *= -1;
            }
        }
    }

    ll ans = 0;
    for(int i=0;i<n;i++) ans += a[i];
    // for(int i=0;i<n;i++) cout<<a[i]<<endl;

    cout<<ans<<endl;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n,m,k;
    cin >> n >> m >> k;

    v_ll a(n+1), b(m+1);
    irep(i,n) { cin >> a[i+1]; }
    irep(i,m) { cin >> b[i+1]; }
    
    irep(i, n) { a[i+1] += a[i]; }
    irep(i, m) { b[i+1] += b[i]; }
    
    int ans = -1;
    irep(i,n+1) {
        if(a[i] > k) { continue; }
        ll left = k-a[i];
        int l = 0, r = b.size();
        while(r-l>1) {
            int mid = (r+l)/2;
            if(b[mid] <= left) {
                l = mid;
            } else {
                r = mid;
            }
        }
        chmax(ans,i+l);
    }
    cout << ans << endl;
    return 0;
}
/*atcoder*/


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll ans = 0;
ll n;

ll f(ll x){
  ll cnt=0;
  if(x==0) return 0;
  while(x!=0){
   x/=10;
   cnt++;
   }
   return cnt;
}


void solve(ll s,int flag){
  if(s > n) return;
  if(flag == 7) ans++;
  solve(s+7*pow(10,f(s)),flag|4);
  solve(s+5*pow(10,f(s)),flag|2);
  solve(s+3*pow(10,f(s)),flag|1);
}

int main(){
  cin >> n;
  solve(0,0);
  cout<<ans<<endl;
  return 0;
}






Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int Q;
  scanf("%d", &Q);
  for (int i=0;i<Q;i++) {
    int N;
    scanf("%d", &N);
    bool loop = false;
    vector<int> n;
    n.push_back(N);
    while (N/10 > 0) {
      const string sN = to_string(N);
      N = 0;
      for (int j=1;j<sN.size();j++)
        N = max(N, stoi(sN.substr(0,j))*stoi(sN.substr(j)));
      if (find(n.begin(), n.end(), N) != n.end()) {
        loop = true;
        break;
      }
      n.push_back(N);
    }
    if (loop) puts("-1");
    else printf("%d\n", (int)n.size()-1);
  }
  return 0;
}

Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int d, n;
    cin >> d >> n;
    cout << (n + (n-1)/99) * (int)pow(100, d) << endl;
}


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

int main() {
	int x, y;
	int d;

	scanf("%d%d", &x, &y);
	if (x < y) {
		d = x;
		x = y;
		y = d;
	}
	while ((d=x%y) != 0) {
		x = y;
		y = d;
	}

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

	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=1;
	for(int i=1;i<s.length();i++)
	{
		if(s[i]!=s[i-1])
			cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){

  int w,h,n;
  scanf("%d %d %d", &w, &h, &n);
  int x[n];
  int y[n];
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &x[i], &y[i], &a[i]);
  }
  int x_max = w;
  int x_min = 0;
  int y_max = h;
  int y_min = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      if (x[i] > x_min) {
        x_min = x[i];
      }
    }
    if (a[i] == 2) {
      if (x[i] < x_max) {
        x_max = x[i];
      }
    }
    if (a[i] == 3) {
      if (y[i] > y_min) {
        y_min = y[i];
      }
    }
    if (a[i] == 4) {
      if (y[i] < y_max) {
        y_max = y[i];
      }
    }
  }
  int width = x_max-x_min;
  if (width < 0) {
    width = 0;
  }
  int height = y_max-y_min;
  if (height < 0) {
    height = 0;
  }
  printf("%d\n", width*height);

  return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    input_raw = read_func().strip().split()
    K = int(input_raw[0])
    newS =""
    for s in S:
        new_s = s
        if ord(s) - ord('a') > 0 and (K - ((ord('a') - ord(s)) % 26)) >= 0:
            new_s = "a"
            K -= ((ord('a') - ord(s)) % 26)
        newS += new_s
    new_end_char = newS[len(S) - 1]
    if K > 0:
        t = ord(newS[len(S) - 1]) + (K % 26)
        if t > ord('z'):
            t = t - ord('z') + ord('a')
        new_end_char = chr(t)
    print newS[:len(S) - 1] + new_end_char


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

ll l,k;
ll ans;

ll mem[5000][5000];
ll comb(ll a,ll b){
  if(mem[a][b]) return mem[a][b];
  if(b == 0) return mem[a][b] = 1;
  if(a == b) return mem[a][b] = 1;
  return mem[a][b] = comb(a-1,b-1)+comb(a-1,b);
}

int main(){
  cin >> l >> k;
  for(ll i = 1;i+i-1 <= l;i++){
    for(ll j = 0;i+i-1+j*(k-1) <= l && j <= i;j++){
      ans += comb(i,j);
    }
  }
  cout << ans << endl;

}



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

int main() {
	
	int n;
	scanf("%d", &n);
	vector<int> b(n - 1);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d", &b[i]);
	}
	vector<int> a(n);
	a[0] = b[0];
	for(int i = 1; i < n - 1; i++) {
		a[i] = min(b[i], b[i - 1]);
	}
	a[n - 1] = b[n - 2];
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += a[i];
	}
	printf("%d\n", ans);
}

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

int binarySearch(int key, int p, vector<int> S) {
    int left = 0;
    int right = p;
    int mid = (right + left) / 2;
    while(mid != left) {
        if(S.at(mid) > key) {
            right = mid;
        }
        else if(S.at(mid) < key) {
            left = mid;
        }
        else return 1;
        mid = (right + left) / 2;
    }
    if(S.at(mid) == key) return 1;
    return 0;
}

int main() {
    int p;
    cin >> p;
    vector<int> S(p);
    rep(i, p) cin >> S.at(i);
    int q;
    cin >> q;
    vector<int> T(q);
    rep(i, q) cin >> T.at(i);

    int key;
    int ans = 0;

    rep(i, q) {
        key = T.at(i);
        ans += binarySearch(key, p, S);
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    cout << A[2] * 10 + A[1] + A[0] << endl;
}

Measured memory_bytes: 256
N, Y = map(int,input().split())

ans = "-1 -1 -1"

for x in range(N+1) :
    calc = x*10000
    if calc > Y :
        break
    for y in range(N+1-x) :
        calc = x*10000 + y*5000 + (N-x-y)*1000
        if calc > Y :
            break
        
        if calc == Y :
            ans = str(x) + " " + str(y) + " " + str(N-x-y)
            break

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  std::cout << a + b + c - max({a, b, c}) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int main(){

  int N;
  cin >> N;

  string S;
  cin >> S;

  vector<string> candidates;

  rep(i, 10) rep(j, 10) rep(k, 10){
    string str = "";
    str += ('0' + i);
    str += ('0' + j);
    str += ('0' + k);
    
    candidates.push_back(str);
  }

  int cnt = 0;
  for(string candidate: candidates){
    int c_idx = 0;


    rep(i, N){
      if(S[i] == candidate[c_idx]){
        if(c_idx==2){
          cnt++;
          break;
        }else{
          c_idx++;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String s = sc.next();
    
		// 出力
		System.out.println(s.length() >= 4 
                           && s.substring(0, 4).equals("YAKI") 
                           ? "Yes" : "No");
	}
}

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


void solve(long long H, long long W){
    if(W==1){
        cout << 1 << endl;
        return;
    }

    if(H == 1){
        cout << 1 << endl;
        return;
    }

    if(W%2 == 0){
        cout << (W / 2) * H << endl;
        return;
    }

    long long i = ceil(double(W)/2);
    long long j = i-1;

    if(H%2 == 0){
        cout << (i+j) * (H/2) << endl;
        return;
    }

    cout << ((i+j) * (H/2)) + i << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        long P = scan.nextLong();
        if (N == 1) {
            System.out.println(P);
            return;
        }
        List<Pair> list = this.solve(P);
        long answer = 1;
        for (Pair p : list) {
            if (p.count < N) {
                continue;
            }
            for (int i = 0; i < p.count / N; i++) {
                answer *= p.value;
            }
        }
        System.out.println(answer);
    }
    private List<Pair> solve(long P) {
        List<Pair> list = new ArrayList<>();
        Pair p = new Pair(P, 1);
        list.add(p);
        long current = P;
        for (long i = 2; i * i <= P ; i++) {
            if (current % i != 0) {
                continue;
            }
            long count = 0;
            while (current % i == 0) {
                current /= i;
                count += 1;
            }
            p = new Pair(i, count);
            list.add(p);
        }
        return list;
    }
    class Pair {
        long value;
        long count;
        Pair(long value, long count) {
            this.value = value;
            this.count = count;
        }
    }
}


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

int calc(queue<string> name, queue<int> time, int q) {
  int totalTime = 0;

  while (!name.empty()) {
    string tmpName = name.front();
    int tmpTime = time.front();

    time.pop();
    name.pop();

    if (tmpTime > q) {
      tmpTime -= q;
      totalTime += q;
      time.push(tmpTime);
      name.push(tmpName);
    } else {
      totalTime += tmpTime;
      cout << tmpName << " " << totalTime << endl;;
    }
  }

  return 0;
}

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

  queue<string> name;
  queue<int> time;

  for (int i = 0; i < n; i++) {
    string tmpName;
    int tmpTime;

    cin >> tmpName >> tmpTime;

    name.push(tmpName);
    time.push(tmpTime);
  }

  calc(name, time, q);
}



Measured memory_bytes: 6512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h + 2, vector<char> (w + 2, '.'));
    vector<vector<int>> t(h + 2, vector<int> (w + 2, 0));
    vector<vector<bool>> u(h + 2, vector<bool> (w + 2, false));
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            cin >> s.at(i).at(j);
            if (s.at(i).at(j) == '#') {
                u.at(i).at(j) = true;
            }
        }
    }
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            if (u.at(i).at(j)) {
                t.at(i - 1).at(j - 1)++;
                t.at(i - 1).at(j)++;
                t.at(i - 1).at(j + 1)++;
                t.at(i).at(j - 1)++;
                t.at(i).at(j + 1)++;
                t.at(i + 1).at(j - 1)++;
                t.at(i + 1).at(j)++;
                t.at(i + 1).at(j + 1)++;
            }
        }
    }
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            if (u.at(i).at(j)) {
                cout << s.at(i).at(j);
            }
            else cout << t.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

s = deque(input())
ans = 0
while s:
    L = s[0]
    R = s[-1]
    if L == R:
        if 1 == len(s):
            break
        L = s.popleft()
        R = s.pop()
        continue
    elif L == 'x' and R != 'x':
        ans += 1
        s.append('x')
    elif L != 'x' and R == 'x':
        ans += 1
        s.appendleft('x')
    elif L != 'x' and R != 'x':
        ans = -1
        break
print(ans)

Measured memory_bytes: 4212
n = int(input())
lis = list(map(int,input().split()))
cou = {}
for i in range(n):
    if lis[i] in cou:
        cou[lis[i]] += 1
    else:
        cou[lis[i]] = 1
ans = 0
for i in cou:
    if cou[i] < i:
        ans += cou[i]
    else:
        ans += abs(cou[i] -i)
print(ans)

Measured memory_bytes: 18168
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin >> c;
    if (isupper(c)) {
        cout << "A" << newl;
    } else {
        cout << "a" << newl;
    }
}

Measured memory_bytes: 3648
#include<cstdio>
int a[5][105],f[5][105];
int max(int x,int y) {return x>y?x:y;}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[1][i]);
	for(int i=1;i<=n;i++) scanf("%d",&a[2][i]);
	for(int i=1;i<=n;i++) f[1][i]=f[1][i-1]+a[1][i],f[2][i]=max(f[1][i],f[2][i-1])+a[2][i];
	printf("%d\n",f[2][n]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
};

signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	int sum = 0;
	REP(i,N){
		cin>>a[i];
		sum+=a[i];
	}
	int ans = INF;
	int l = 0;
	REP(i,N-1){
		l += a[i];
		CHMIN(ans,abs(sum-l-l));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#pragma warning (disable:4996)
#include<stdio.h>

int main(void) {
	int n;
	int h[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &h[i]);
	}
	int count = 0, max = 0;
	int i, j;
	for (i = 0; i < n; ++i) {
		for (j = i; j < n - 1; ++j) {
			if (h[j] >= h[j + 1]) {
				++count;
			}
			else {
				break;
			}
		}
		if (count > max) {
			max = count;
		}
		if (max > n - i) {
			break;
		}
		count = 0;
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#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 vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll N,sum;
	sum = 1;
	ll mod = 1000000007;
	cin >> N;
	FOR(i, 1, N+1) {
		sum = i*sum;
		sum %= mod;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  std::uint32_t N;
  std::cin >> N;

  std::vector<std::uint32_t> hs(N);
  for (auto& hi : hs) {
    std::cin >> hi;
  }

  const auto max_h = *std::max_element(hs.cbegin(), hs.cend());

  int ans = 0;
  for (auto i = 1u; i <= max_h; ++i) {
    auto it = hs.cbegin();
    while (it < hs.cend()) {
      for (; it < hs.cend() && *it < i; ++it)
        ;

      bool f = false;
      for (; it < hs.cend() && *it >= i; ++it) {
        f = true;
      }
      if (f) ans++;
    }
  }

  std::cout << ans << std::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>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;

bool test(int x, int y)
{
	for (int i = N - 1; i >= 0; --i) {
		if ((x & (1 << i)) && !(y & (1 << i))) {
			return ((x ^ y) & ((1 << i) - 1)) == 0;
		}
	}
	return true;
}

i64 modpow(i64 a, i64 p)
{
	if (p == 0) return 1;
	i64 t = modpow(a, p / 2);
	t = t * t % MOD;
	if (p & 1) t = t * a % MOD;
	return t;
}
i64 dp[5050][5050];
i64 inv2[5050], pows[5050];

i64 solve2()
{
	i64 tbl[2][5050];
	i64 acc[5050];
	int t = 0;

	for (int i = 0; i <= M; ++i) tbl[t][i] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) tbl[1 - t][j] = 0;
		for (int j = 0; j <= M; ++j) {
			acc[j] = tbl[t][j] * j % MOD * inv2[j + 1] % MOD;
		}
		for (int j = 1; j <= M; ++j) ADD(acc[j], acc[j - 1]);
		for (int j = 0; j <= M; ++j) {
			tbl[1 - t][j] = (j > 0 ? acc[j - 1] : 0) * pows[j] % MOD;
			ADD(tbl[1 - t][j], tbl[t][j] * (j + 1));
		}
		t = 1 - t;
	}
	return tbl[t][M];
}

i64 solve()
{
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			if (i == 0 || j == 0) {
				dp[i][j] = 1;
				continue;
			}
			i64 tmp = 0;
			ADD(tmp, dp[i - 1][j] * (j + 1));
			for (int d = 2; d <= j; ++d) {
				ADD(tmp, dp[i - 1][j - d + 1] * (j - d + 1) % MOD * modpow(2, d - 2));
			}
			dp[i][j] = tmp;
		}
	}
	return dp[N][M];
}

int main()
{
	pows[0] = inv2[0] = 1;
	for (int i = 1; i <= 5000; ++i) {
		pows[i] = pows[i - 1] * 2 % MOD;
		inv2[i] = modpow(pows[i], MOD - 2);
	}
	scanf("%d%d", &N, &M);

	printf("%lld\n", solve2()); return 0;

	for (int x = 0; x < (1 << N); ++x) {
		for (int y = 0; y < (1 << N); ++y) {
			bool isok = true;
			for (int m = 0; m < (1 << N); ++m) {
				int xx = x & m, yy = y & m;
				if (xx > yy && __builtin_popcount(xx ^ yy) >= 2) isok = false;
			}
			if (isok != test(x, y)) puts("><");
//			if (isok) printf("%d %d\n", x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 4024
#include<cstdio>
#include<map>
#include<utility>
#include<algorithm>
#define mod 1000000007
typedef long long ll;
using namespace std;

map<pair<ll,ll>,int> ma;

int dfs(ll x, ll y){
    decltype(ma)::iterator it = ma.find(make_pair(x/2,y/2));
    int res;
    //printf("%lld %lld\n",x,y);
    if(x<0||y<0){
        return 0;
    }
    if(x==0){
        return 1;
    }
    if(x==1&&y==1){
        return 2;
    }
    if(it!=ma.end()){
        res=ma[make_pair(x/2,y/2)];
    }
    else{
        res=dfs(x/2,y/2);
    }
    res%=mod;
    it = ma.find(make_pair((x-1)/2,(y-1)/2));
    if(it!=ma.end()){
        res+=ma[make_pair((x-1)/2,(y-1)/2)];
    }
    else{
        res+=dfs((x-1)/2,(y-1)/2);
    }
    res%=mod;
    it = ma.find(make_pair((x-2)/2,min(x-2,y)/2));
    if(it!=ma.end()){
        res+=ma[make_pair((x-2)/2,min(x-2,y)/2)];
    }
    else{
        res+=dfs((x-2)/2,min(x-2,y)/2);
    }
    res%=mod;
    ma.insert(make_pair(make_pair(x,y),res));
    return res;
}

int main(){
    ll n;
    scanf("%lld",&n);
    printf("%d\n",dfs(n,n));
}

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

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



int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    vector<int> l(n),r(n);
    rep(i,n){
        l[i]=lower_bound(b.begin(),b.end(),a[i])-b.begin();
        r[i]=upper_bound(b.begin(),b.end(),a[i])-b.begin()-1;
    }
    int cnt = 0;
    rep(i,n){
        if(l[i]<=i&&i<=r[i])++cnt;
    }
    if(cnt==n){
        cout<<0<<endl;
        return 0;
    }

    int q;
    cin>>q;
    rep(i,q){
        int x,y;
        cin>>x>>y;
        --x;--y;
        if(l[x]<=x&&x<=r[x])--cnt;
        if(l[y]<=y&&y<=r[y])--cnt;
        swap(a[x],a[y]);
        swap(l[x],l[y]);
        swap(r[x],r[y]);
        if(l[x]<=x&&x<=r[x])++cnt;
        if(l[y]<=y&&y<=r[y])++cnt;
        if(cnt==n){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 7640
#include<bits/stdc++.h>
//#include<algorithm>
//#include<iostream>
//#include<cstring>
//#include<cmath> 
//#include<map>
//#include<queue>
#define rg register

using namespace std;

inline void read(int &x){
	rg char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-48;
		ch=getchar();
	}
}

const int N=0;
int T,n,a,b,c;

int main(){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d %d %d\n",c,a,b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

struct Cell {
  int h;
  int w;
  int dist;
};
int main() {
  int H, W;
  cin >> H >> W;
  VEC<string> S(H);
  REP(i, 0, H) cin >> S[i];
  // int dp[H][W][H][W];
  // const int lim = INT32_MAX;
  // REP(i, 0, H) {
  //   REP(j, 0, W) {
  //     REP(k, 0, H) {
  //       REP(l, 0, W) { dp[i][j][k][l] = lim; }
  //     }
  //   }
  // }

  int ma = 0;
  REP(sh, 0, H) {
    REP(sw, 0, W) {
      // DUMP("sh, sw:", sh,sw);
      queue<Cell> q;
      auto used = VEC<VEC<bool>>(H, VEC<bool>(W, 0));
      q.push({sh, sw, 0});
      int far = 0;
      while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int h = p.h;
        int w = p.w;
        int dist = p.dist;

        if (h < 0 || H <= h || w < 0 || W <= w) continue;
        if (S[h][w] == '#') continue;
        if (used[h][w]) continue;

        far = dist;
        used[h][w] = true;
        // dp[sh][sw][h][w] = dist;

        q.push({h + 1, w, dist + 1});
        q.push({h - 1, w, dist + 1});
        q.push({h, w + 1, dist + 1});
        q.push({h, w - 1, dist + 1});
      }
      ma = max(ma, far);
    }
  }
  cout << ma << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  if(s[n-1] == 's'){
    s += "es";
  }else{
    s += "s";
  }

  cout << s << endl;
  
  return(0);
}

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

using namespace std;

typedef long long LL;

const int maxn=105;
const int maxm=10005;
struct match

{

	int un,num,vn;

	int b[maxn],a[maxm],next[maxm];

	int linker[maxn];

	bool used[maxn];

	void init(int unn,int vnn)

	{

		un=unn;vn=vnn;num=0;

		memset(b,0,sizeof(b));

	}

	void addedge(int x,int y)

	{

		++num;a[num]=y;next[num]=b[x];b[x]=num;

	}

	bool dfs(int x)

	{

		for (int i=b[x];i>0;i=next[i])

		{

			int y=a[i];

			if (!used[y])

			{

				used[y]=true;

				if (linker[y]==-1||dfs(linker[y]))

				{

					linker[y]=x;

					return true;

				}

			}

		}

		return false;

	}

	int hungary()

	{

		int ans=0;

		memset(linker,-1,sizeof(linker));

		for (int u=0;u<un;++u)

		{

			memset(used,false,sizeof(used));

			if (dfs(u)) ans++;

		}

		return ans;

	}

}mp;

int n,a[105],b[105],c[105],d[105],ans;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%d%d",&a[i],&b[i]);
	for(int i=0;i<n;++i) scanf("%d%d",&c[i],&d[i]);
	mp.init(n,n);
	for (int i=0;i<n;++i)
		for (int j=0;j<n;++j) if (a[i]<c[j]&&b[i]<d[j]) mp.addedge(i,j);
	ans=mp.hungary();
	printf("%d\n",ans);	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	cout << max(0,C-(A-B)) << endl;
	return 0;
}

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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int N;
	cin >> N; 
	map<int, int>pi;//index,x
	vector<pair<int, int>>v(N);
	map<int, int>py;//y,x
	for (int n = 0; n < N; ++n) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		v[n] = {x,y};
		pi[n] = x;
		py[y] = x;
	}
	sort(v.begin(), v.end());
	UnionFind uf(N);
	priority_queue<int, vector<int>, greater<int> > q;
	for (int i = 0; i < N; ++i) {
		int y = v[i].second;
		int ysub = y;
		while (!q.empty()) {
			int y0 = q.top();
			q.pop();
			if (y0 > y) {
				q.push(y0);
				break;
			}
			else {
				ysub = min(ysub,y0);
				uf.merge(py[y], py[y0]);
			}
		}
		q.push(ysub);
	}
	for (int n = 0; n < N; ++n) {
		cout << uf.size(pi[n]) << endl;
	}
	return 0;
}


Measured memory_bytes: 24516