akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 500010, LOG=20;

int n, m, k, u, v, x, y, t, a, b;
int P[MAXN], ans[MAXN];
int deg[MAXN];
vector<int> G[MAXN];
set<pii> st;
priority_queue<int, vector<int>, greater<int>> pq;

void add_edge(int u, int v){
	if (!u || v==n+1) return ;
	G[u].pb(v);
	deg[v]++;
	//debug2(u, v)
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	st.insert({0, 0});
	st.insert({n+1, n+1});
	for (int i=1; i<=n; i++){
		cin>>P[i];
		if (i>k) st.erase({P[i-k], i-k});
		auto it=st.lower_bound({P[i], 0});
		add_edge(i, it->second);
		it--;
		add_edge(it->second, i);
		st.insert({P[i], i});
	}
	
	for (int i=1; i<=n; i++) if (!deg[i]) pq.push(i);
	/*while (pq.size())*/for (int i=1; i<=n; i++){
		int v=pq.top();
		pq.pop();
		ans[v]=i;
		for (int u:G[v]) if (!--deg[u]) pq.push(u);
	}
	for (int i=1; i<=n; i++) cout<<ans[i]<<'\n';
	
	return 0;
}


Measured memory_bytes: 60800
from sys import stdin
N = int(input())
A = list(map(int, stdin.readline().split()))
if 0 in A:
    print(0)
else:
    ans = 1
    for a in A:
        ans = ans*a
        if ans > 10**18:
            break
    """from functools import reduce
    ans = reduce(lambda x,y:x*y,A)"""
    """import numpy as np
    A = np.array(A)
    ans = np.prod(A)"""
    if ans >10**18:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 21780
#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
int dp[3005][3005];
int a[3005],b[3005];
int main(){
	int i,j,k,n,t,s;
	scanf("%d%d%d",&n,&t,&s);
	for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<n;i++){
		for(j=0;j<=t;j++){
			if(j-b[i]>=0){
				if(j<=s || s<=j-b[i])dp[i+1][j]=Max(dp[i][j],dp[i][j-b[i]]+a[i]);
				else dp[i+1][j]=Max(dp[i][j],dp[i+1][s]);
			}else{
				dp[i+1][j]=dp[i][j];
			}
			//printf("%2d ",dp[i+1][j]);
		}
		//printf("\n");
	}
	printf("%d\n",dp[n][t]);
	return 0;
}

Measured memory_bytes: 0
//クイックソート
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

void merge(vector<pair<char,int>> &a,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    vector<pair<char,int>> L(n1+1),R(n2+1);
    for(int i=0;i<n1;i++)L[i]=make_pair(a[left+i].first,a[left+i].second);
    for(int i=0;i<n2;i++)R[i]=make_pair(a[mid+i].first,a[mid+i].second);
    int i=0,j=0;
    L[n1].second=2000000000,R[n2].second=2000000000;
    for(int k=left;k<right;k++){
        if(L[i].second<=R[j].second){
            a[k]=make_pair(L[i].first,L[i].second);
            i++;
        }else{
            a[k]=make_pair(R[j].first,R[j].second);
            j++;
        }
    }
}

void mergesort(vector<pair<char,int>> &a,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(a,left,mid);
        mergesort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int partition(vector<pair<char,int>> &a,int p,int r){
    int x=a[r].second;
    int i=p-1;
    for(int j=p;j<r;j++){
        if(a[j].second<=x){
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return (int)(i+1);
}

void quick_sort(vector<pair<char,int>> &a,int p,int r){
    if(p<r){
        int q=partition(a,p,r);
        quick_sort(a,p,q-1);
        quick_sort(a,q+1,r);
    }
}

int main(){
    int n,x;
    char c;
    cin>>n;
    vector<pair<char,int>> vec(n),vec2(n);
    rep(i,n){
        cin>>c>>x;
        vec[i]=make_pair(c,x);
        vec2[i]=make_pair(c,x);
    }
    quick_sort(vec,0,n-1);
    mergesort(vec2,0,n);
    int ans=1;
    rep(i,n){
        if(vec[i].first!=vec2[i].first){
            ans=0;
            break;
        }
    }
    cout<<(ans?"Stable":"Not stable")<<endl;
    rep(i,n){
        cout<<vec[i].first<<" "<<vec[i].second<<endl;
    }
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using Lint = long long;
#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define PB push_back
#define MP make_pair
using P=pair<int, int>;
using V=vector<int>;
using M=map<int, int>;
using S=set<int>;

#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
template <class T>bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
/* vector<T>のイテレータはvector<T>::iterator型
vector<int>::iterator it = vc.begin();  // begin()はvectorの最初の要素を指すイテレータを返す
vector<int>::iterator endIt = vc.end(); // end()はvectorの終端位置を指すイテレータを返す
while (it != endIt)
{
  cout << *it << '\n'; // イテレータの指す要素は、ポインタのように*演算子でアクセス
  it++;                // インクリメントすることで次の要素を指します。
}
}*/
int main(){
string s,t;
  int cnt=0;
cin >> s>>t;
  REP(i,s.size()){
    
    if(s[i]!=t[i]){
    cnt++;
    } 
  }
    COUT(cnt); 
   }


Measured memory_bytes: 3844
N = int(input())
A = []
B = []
C = []
for i in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
dp = [[0 for _ in range(3)] for _ in range(N)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1, N):
    dp[i][0] = max(dp[i-1][1] + A[i], dp[i-1][2] + A[i])
    dp[i][1] = max(dp[i-1][0] + B[i], dp[i-1][2] + B[i])
    dp[i][2] = max(dp[i-1][0] + C[i], dp[i-1][1] + C[i])
print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))

Measured memory_bytes: 80436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextInt();
		long m = scan.nextInt();
		long ans = 0;
		if (n >= 3 && m >= 3) ans = (n-2)*(m-2);
		else if (n == 2 || m == 2) ans = 0;
		else if (n == 1 && m== 1) ans = 1;
		else if (n == 1) ans = m-2;
		else if (m == 1) ans = n-2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 25172
/***********************************************
#
#      Filename: e.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-04-29 21:51:42
***********************************************/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
typedef pair<int, int> pii;
vector<pii> d;
set<pii> s;

int main()
{
    int N;
    cin >> N;
    int r, b;
    for (int i = 0; i < N; ++ i) { 
        cin >> r >> b;
        if (r > b) swap(r, b);
        d.push_back(make_pair(r, b));
    }
    sort(d.begin(), d.end());
    set<pii> red, blue;
    for (int i = 0; i < d.size(); ++ i) {
        red.insert(pii(d[i].first, i));
        blue.insert(pii(d[i].second, i));
    }
    LL ans = ( red.rbegin()->first - red.begin()->first ) * 1LL * ( blue.rbegin()->first - blue.begin()->first );
    for (int i = 0; i < d.size(); ++ i) {
        red.erase(pii(d[i].first, i));
        blue.erase(pii(d[i].second, i));
        red.insert(pii(d[i].second, i));
        blue.insert(pii(d[i].first, i));
        LL tmp = ( red.rbegin()->first - red.begin()->first ) * 1LL * ( blue.rbegin()->first - blue.begin()->first );
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21104
#include <cstdio>
#include <vector>
#include <map>
#define pb push_back
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	while(scanf("%d", &n),n){
		bool f[401][401];
		vector<P> v;
		for(int i = 0; i < 401; i++){
			for(int j = 0; j < 401; j++) f[i][j] = false;
		}
		v.pb(P(200,200));
		f[200][200] = true;
		for(int i = 0; i < n-1; i++){
			int a, b;
			scanf("%d%d", &a, &b);
			int fa = v[a].fi,fs = v[a].sec;
			if(b == 0){
				f[fa-1][fs] = true;
				v.pb(P(fa-1,fs));
			} else if(b == 1){
				f[fa][fs-1] = true;
				v.pb(P(fa,fs-1));
			} else if(b == 2){
				f[fa+1][fs] = true;
				v.pb(P(fa+1,fs));
			} else{
				f[fa][fs+1] = true;
				v.pb(P(fa,fs+1));
			}
		}
		int X = -1,x = 500,Y = -1,y = 500;
		for(int i = 0; i < 401; i++){
			for(int j = 0; j < 401; j++){
				if(f[i][j] == true){
					X = max(X,i);
					x = min(x,i);
					Y = max(Y,j);
					y = min(y,j);
				}
			}
		}
		printf("%d %d\n", (X-x+1), (Y-y+1));
	}
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
struct UnionFind {
	vector<int>par;

	UnionFind(int N) :par(N) {
		for (int i = 0; i < N; ++i) {
			par[i] = i;
		}
	}

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

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
//.......クラスカル法......//

int main() {
	int N;
	cin >> N;
	vector<pair<ll,int>>x, y;
	for (int i = 0; i < N; ++i) {
		ll a, b;
		cin >> a >> b;
		x.push_back({ a,i });
		y.push_back({ b,i });
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	using edge = pair<ll, pii>;
	vector<edge>edges;
	for (int i = 0; i < N-1; ++i) {
		int v1 = x[i].second;
		int v2 = x[i + 1].second;
		ll cost = x[i + 1].first - x[i].first;
		edges.push_back(edge(cost,pii(v1,v2)));
	}
	for (int i = 0; i < N-1; ++i) {
		int v1 = y[i].second;
		int v2 = y[i + 1].second;
		ll cost = y[i + 1].first - y[i].first;
		edges.push_back(edge(cost,pii(v1,v2)));
	}
	sort(edges.begin(), edges.end());
	UnionFind uf(N);
	ll ans = 0;
	for (auto e : edges) {
		int u = e.second.first, v = e.second.second;
		ll cost = e.first;
		if (!uf.same(u,v)) {
			uf.unite(u,v);
			ans += cost;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9700
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
 
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}
 
fn main() {
    let v = read_vec::<i64>();
    let (h, w) = (v[0], v[1]);
    if h == 1 || w == 1 {
        println!("1");
        return;
    }
    let ans = (h * w + 1) / 2;
    println!("{}", ans);
}
 
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  rep(i,0,n){
    ll p,q;cin>>p>>q;
    x[i]=p+q;
    y[i]=p-q;
  }
  sort(ALL(x));
  sort(ALL(y));
  cout<<max(x[n-1]-x[0],y[n-1]-y[0])<<endl;
  return 0;
}

Measured memory_bytes: 6340
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let n = read int
    let bs = reada int
    let st = SortedSet<int>(bs)
    if st.Count = n then "YES" else "NO"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 38216
def solve(s, k):
    buff = []
    for start in range(len(s)):
        for end in range(1, k+1):
            if start + end > len(s):
                continue
            buff.append(s[start:start+end])
    buff = list(set(buff))
    buff.sort()
    return buff[k-1]

def main():
    s = input()
    k = int(input())
    ans = solve(s, k)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5068
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>

using namespace std;

int main(){

    int H, W;
    cin >> H >> W;

    int field[1005][1005];    // 0: black, -1: white 
    queue<pair<int,int>> que; 
    int h, w;
    char c;
    
    for(h=0;h<H;++h){
        for(w=0;w<W;++w){
            cin >> c;
            if(c=='#') {
                field[h][w] = 0;
                que.push(make_pair(h,w));
            }
            else if(c=='.') field[h][w] = -1;
        }
    }

    int ans(0);
        
    while(!que.empty()){

        h = que.front().first;
        w = que.front().second;
        que.pop();

        // 4方向を探索
        for(int dh=-1;dh<=1;++dh){
            for(int dw=-1;dw<=1;++dw){
                // 斜め移動を省く
                if( (dh + dw) % 2 == 0 ) continue;
                int nh = h + dh, nw = w + dw; 
                // 場外は省く
                if( nh < 0 or nh >= H or nw < 0 or nw >= W )  continue;
                
                // 既に行ったところは除く                
                if( field[nh][nw] != -1 ) continue;
                
                field[nh][nw] = field[h][w] + 1;
                ans = max( ans, field[nh][nw] );
                que.push( make_pair(nh, nw));

            }
        }
    }

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


Measured memory_bytes: 12304
N,A,B = map(int,input().split())

if (B-A) % 2 == 0:
    print((B-A)//2)
else:
    if A-1<N-B:
        print(A-1+1+((B-A-1)//2))
    else:
        print(N-B+1+((B-A-1)//2))

Measured memory_bytes: 2940
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int l[] = new int[N];
        for (int i=0;i<N;i++){
            l[i] = sc.nextInt();
        }
        
        l = MaxSort(l);
        
        int len = 0;
        for(int i=0;i<K;i++){
            len += l[i];
        }
        System.out.println(len);
    }
    static int[] MaxSort(int[] s){
        int ans[] = s;
        
        for (int i=0;i<ans.length;i++){
            int max = ans[i];
            for (int k=i+1;k<ans.length;k++){
                if (max < ans[k]){
                    ans[i] = ans[k];
                    ans[k] = max;
                    max = ans[i];
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 21972
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const lint mod=1e9+7;
const int K=1e6+10;

int pr[K];
void init(){
  rep(i,K)if(i>=2)pr[i]=1;
  for(int i=2;i<K;++i){
    if(!pr[i])continue;
    for(int j=2;j*i<K;++j)pr[i*j]=0;
  }
}

const int N=110000;
lint dp[N];

int main(){
  init();
  int n;
  cin>>n;
  vi q(n+1);
  rep(i,n)cin>>q[i];
  q[n]=K;
  dp[n]=1;
  for(int i=n-1;i>=0;--i){
    if(pr[q[i]]&&q[i]<q[i+1]){
      dp[i]=(dp[i]+dp[i+1])%mod;
    }
    if(i<n-1&&pr[q[i]]&&q[i+1]>=2&&q[i]<q[i+2]){
      dp[i]=(dp[i]+dp[i+2])%mod;
    }
  }
  cout<<dp[0]<<endl;
}



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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ld a, b, x;
    cin >> a >> b >> x;
    x /= a;
    if(x >= a*b/2){
        ld c = 2*(a*b-x)/a;
        ld angle = atan(c/a);
        cout << angle*180/acos(-1) << "\n";
    }
    else{
        ld c = 2*x/b;
        ld angle = atan(b/c);
        cout << angle*180/acos(-1) << "\n";
    }
    return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0, N, C, K;
vll T;
vector<pii> vp;
int cnt, cur, tmp = 0, num, t, tprev;

void solve(){
    sort(T.begin(), T.end());

    ans++;
    cur = T[0];
    tmp = 1;

    for(int i = 1; i < N; ++i){
        if(tmp == C || T[i] - cur > K){
            ans++;
            tmp = 1;
            cur = T[i];
        } else tmp++;
    }

    cout << ans << endl;
}

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

    T.resize(N);
    rep(i, N) {
        cin >> T[i];
    }

    solve();
}


Measured memory_bytes: 1024
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x;
	cin >> x;
	if(x >= 1800)
		return cout << 1 << '\n', 0;
	if(x >= 1600)
		return cout << 2 << '\n', 0;
	if(x >= 1400)
		return cout << 3 << '\n', 0;
	if(x >= 1200)
		return cout << 4 << '\n', 0;
	if(x >= 1000)
		return cout << 5 << '\n', 0;
	if(x >= 800)
		return cout << 6 << '\n', 0;
	if(x >= 600)
		return cout << 7 << '\n', 0;
	if(x >= 400)
		return cout << 8 << '\n', 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<double, double> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
/*next_combination*/
#define it vector<int>::iterator
bool next_combination(it first1,it last1,it first2,it last2){
    if((first1==last1)||(first2==last2))return false;
    it m1=last1,m2=last2;
    m2--;
    while(--m1!=first1&&!(*m1<*m2));
    bool result=(m1==first1)&&!(*first1<*m2);
    if(!result){
        while(first2!=m2&&!(*m1<*first2))first2++;
        first1=m1;
        iter_swap(first1,first2);
        first1++;first2++;
    }
    if((first1!=last1)&&(first2!=last2)){
        m1=last1;m2=first2;
        while((m1!=first1)&&(m2!=last2))iter_swap(--m1,m2++);
        reverse(first1,m1);
        reverse(first1,last1);
        reverse(m2,last2);
        reverse(first2,last2);
    }
    return !result;
}
double p(double temp){return temp*temp;}
typedef pair<pii,double> piii;
double Power(piii a, piii b){
    return (p(a.first.first-b.first.first)+p(a.first.second-b.first.second)+p(a.second-b.second));
}
bool next_combination(it first,it middle,it last){
    return next_combination (first , middle , middle , last );
}int main(){
    int n,m;
    cin>>n>>m;
    vi v(n);rep(i,n)v[i]=i;
    vector<piii>u;
    rep(i,n){
        piii temp; cin>>temp.first.first>>temp.first.second>>temp.second;
        u.push_back(temp);
    }
    double ans=0;
    do{
        double t=0;
        //cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<endl;
        rep(i,m){for(int j=i+1;j<m;j++){t+=Power(u[v[i]],u[v[j]]);}}
        //cout<<t<<endl;
        cmax(ans,t);
    }while(next_combination(v.begin(),v.begin()+m,v.end()));
    printf("%.10f\n",ans);
}

Measured memory_bytes: 3296
#include <iostream>

using namespace std;

int N, M;
int a[200005], b[200005];
bool pos1[200005], posN[200005];

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 1; i <= N; i++) {
		pos1[i] = false;
		posN[i] = false;
	}

	for (int j = 1; j <= M; j++) {
		if (a[j] == 1) { pos1[b[j]] = true; }
		if (b[j] == 1) { pos1[a[j]] = true; }
		if (a[j] == N) { posN[b[j]] = true; }
		if (b[j] == N) { posN[a[j]] = true; }
	}

	bool ans = false;

	for (int i = 2; i <= N-1; i++) {
		if (pos1[i] && posN[i]) { ans = true; }
	}
	if (ans) { cout << "POSSIBLE" << endl; }
	else { cout << "IMPOSSIBLE" << endl; }

	//system("pause");
	return 0;
}

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

#define MAX 100
int main() {
  int n, m;
  int i, j;
  int j_max;
  int ans;

  vector<string> blue_str(MAX);
  vector<string> lst(MAX);
  vector<int> score(MAX);
  string buf;
  
  cin >> n;
  
  j_max = 1;
  for (i = 0; i < n; i++) {
    cin >> blue_str.at(i);
    
    if (i == 0) {
      lst.at(0) = blue_str.at(i);
      score.at(0) = 1;
    } else {
      for (j = 0; j < j_max; j++) {
        if (blue_str.at(i) == lst.at(j)) {
          score.at(j)++;
          break;
        }
      }
      if (j == j_max) {
        lst.at(j_max) = blue_str.at(i);
        score.at(j_max) = 1;
        j_max++;
      }
    }
  }
  
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> buf;
    for (j = 0; j < j_max; j++) {
      if (buf == lst.at(j)) {
        score.at(j)--;
        break;
      }
    }
  }
  
  ans = 0;
  for (j = 0; j < j_max; j++) {
//    cout << lst.at(j) << " : " << score.at(j) << endl;
    if (ans < score.at(j)) {
      ans = score.at(j);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
   int k;cin>>k;
   if (k%2==0)
   {
      /* code */
      cout<<k/2*k/2<<endl;
   }
   else
   {
     
   cout<<(k+1)/2*(k/2)<<endl;
   }
   
   
   
   }
   

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		long c = in.nextLong();

		System.out.println(Math.min(a * b,  c));

	}

}

Measured memory_bytes: 22228
// ABC144_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset 初期化
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）



ll digitSum(ll n) {
    ll res = 0;
    while (n != 0) {
        res += 1;
        n /= 10;
    }
    return res;
}

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    // calculation
    if (digitSum(N) > 1 || digitSum(M) > 1) {
        cout << -1 << "\n";
    } else {
        cout << N*M << "\n";
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np


def main():
    h, w = map(int, input().split())
    ss = np.array([list(input()) for _ in range(h)])
    ans = np.zeros((h, w))
    xs, ys = np.where(ss == '#')
    for x, y in zip(xs, ys):
        coord = np.array([[x, y]])
        surround = np.array([[-1, -1], [-1, 0], [-1, +1], [0, -1], [0, +1], [+1, -1], [+1, 0], [+1, +1]])
        mines = np.tile(coord, (8, 1)) - surround
        for mx, my in mines:
            if mx < 0 or my < 0 or mx >= h or my >= w:
                continue
            ans[mx, my] += 1
    ans = ans.astype(np.int16).tolist()
    for x, y in zip(xs, ys):
        ans[x][y] = '#'

    for line in ans:
        print(''.join(map(str, line)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12404
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int &i : p)
  {
    cin >> i;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  p.at(0) /= 2;
  int ans = 0;
  for (int i : p)
  {
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  bool kekka = false;
  
  for(int i = a;i < b + 1;i ++){
    if(i % k == 0)kekka = true;
  }
  
  if(kekka == true)cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int N;
  long int x;
  scanf("%d%ld",&N,&x);
  int i,j;
  unsigned int a[N];
  for(i=0;i<N;i++){
    scanf("%ld",&a[i]);
  }
  long int tmp;
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(a[i]>a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  int count=0;
  i=0;
  while(x>0&&a[i]!=0){
    x=x-a[i];
    //printf("%d ",x);
    i++;
    count++;
  }
  if(x!=0){
    printf("%d",count-1);
  }
  else{
    printf("%d",count);
  }
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))
i = 0
odd = 0
while odd == 0:
    for n in range(len(a)):
        if a[n]%2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const int mod = 1000000007;
struct Mint {
    LL x;
    Mint(LL x=0):x((x%mod+mod)%mod){}
    Mint operator-() const { return Mint(-x);}
    Mint& operator+=(const Mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator-=(const Mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator*=(const Mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    Mint operator+(const Mint& a) const {
        Mint res(*this);
        return res+=a;
    }
    Mint operator-(const Mint& a) const {
        Mint res(*this);
        return res-=a;
    }
    Mint operator*(const Mint& a) const {
        Mint res(*this);
        return res*=a;
    }
    Mint pow(LL t) const {
        if (!t) return 1;
        Mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    Mint inv() const {
        return pow(mod-2);
    }
    Mint& operator/=(const Mint& a) {
        return (*this) *= a.inv();
    }
    Mint operator/(const Mint& a) const {
        Mint res(*this);
        return res/=a;
    }
};

struct Comb {
  vector<Mint> fact, ifact;
  Comb(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  Mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    Comb C(n+5);
    Mint ans = 0;
    REP(j,2) {
        REP(i, n) {
            Mint now = C(i,k-1);
            if(j%2) now=-now;
            ans+=now*a[i];
        }
        reverse(ALL(a));
    } 
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 2176
n = int(input())

max_num = 0

for i in range(2):
    if i == 0:
        array_1 = list(map(int, input().split()))
    elif i == 1:
        array_2 = list(map(int, input().split()))

if n == 1:
    print(array_1[0] + array_2[0])
    exit()

for i in range(n):
    sum_num = 0
    a = sum(array_1[:i+1])
    b = sum(array_2[i:])
    sum_num += sum(array_1[:i+1])
    sum_num += sum(array_2[i:])
    if sum_num >= max_num:
        max_num = sum_num

print(max_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, m, i;
	cin >> n >> m;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	int sum = accumulate(arr, arr + n, 0);
	int y = 4 * m;
	int x = (sum % y ? sum / y + 1 : sum / y);
	int cnt = 0;
	fo(i, 0, n) {
		if(arr[i] >= x)
		cnt++;
	}
	cout << (cnt < m ? "No" : "Yes");
}


Measured memory_bytes: 256
def v():
 from collections import deque
 H,W,N=map(int,input().split())
 e='X'*(W+2)
 M=e+''.join('X'+input()+'X'for _ in[0]*H)+e
 m=(1,-1,W+2,-W-2)
 def f(s,g):
  p,t=s,0
  q=deque()
  b=[1]*len(M);b[s]=0
  while 1:
   for d in m:
    n=p+d
    if'X'!=M[n]and b[n]:
     if M[n]==g:return(n,t+1)
     b[n]=0;q.append([n,t+1])
   p,t=q.popleft()
 s=M.find('S')
 a=0
 for i in range(1,N+1):
  s,t=f(s,str(i))
  a+=t
 print(a)
v()


Measured memory_bytes: 14948
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum uint64

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	T, _ := strconv.Atoi(read())
	t := make([]int, N)
	for i := 0; i < N; i++ {
		t[i], _ = strconv.Atoi(read())
	}

	for i := 0; i < N-1; i++ {
		if T <= t[i+1]-t[i] {
			ans += uint64(T)
		} else {
			ans += uint64(t[i+1] - t[i])
		}
	}
	fmt.Println(ans + uint64(T))
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 5120
n,m = map(int,input().split())
ans = [0]*n
for i in range(m):
  s,c = map(int,input().split())
  if ans[s-1] != 0 and ans[s-1] != c:
    print(-1)
    exit()
  elif n != 1 and s == 1 and c == 0:
    print(-1)
    exit()
  else:
    ans[s-1] = c
ans_f = "".join((map(str,ans)))
if n>1 and ans_f[0] == "0":
  print("1"+ans_f[1::])
else:
  print(ans_f)


Measured memory_bytes: 9156
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double mTheta = 360.0 * ((double) m / 60.0);
    double hTheta = 360.0 * ((double) h / 12.0) + 30.0 * ((double) m / 60.0);
    double[] hp = new double[2];
    hp[0] = a * Math.cos(Math.toRadians(hTheta));
    hp[1] = a * Math.sin(Math.toRadians(hTheta));
    double[] mp = new double[2];
    mp[0] = b * Math.cos(Math.toRadians(mTheta));
    mp[1] = b * Math.sin(Math.toRadians(mTheta));
    double ans = Math.hypot(hp[0] - mp[0], hp[1] - mp[1]);
    System.out.println(ans);
  }
}

Measured memory_bytes: 33136
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2)cout << "Borys\n";
    else cout << "Alice\n";
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll n; cin >> n;
  vector<pair<pair<string, ll>, ll>> x(n);
  REP(i, n){
    string s; cin >> s;
    ll p; cin >> p;
    x[i] = mp(mp(s, -p), i + 1);
  }
  sort(x.begin(), x.end());
  REP(i, n) cout << x[i].second << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	long int n, a[10000], i, e, c;

	scanf("%ld", &n);
	a[n] = 0;

	for (i = 0; i<n; i++){

		scanf("%ld", &a[i]);

	}

	for (i = n - 1; i >= 0; i--)
	{
		for (c = 0; c < i; c++)
		{
			if (a[c]>a[c + 1])
			{
				e = 0;
				e = a[c];
				a[c] = a[c + 1];
				a[c + 1] = e;

			}
		}



	}

	for (i = 0; i<n; i++){
		a[n] += a[i];
	}

	printf("%ld %ld %ld\n", a[0], a[n - 1], a[n]);


	return 0;
}

Measured memory_bytes: 680
#include <stdio.h>

int main(){
	double height,max,min;

	scanf("%lf",&height);
	min = height;
	max = height;

	while(scanf("%lf",&height) != EOF){
		if(max < height){
			max = height;
		}
		if(min > height){
			min = height;
		}
	}

	printf("%f\n",max-min);

	return 0;
}

Measured memory_bytes: 648
<?php
fscanf(STDIN, "%d", $n);
$d = explode(" ", trim(fgets(STDIN)));
$ans = 0;
for($i = 0; $i < $n; $i++) {
    for($j = $i+1; $j < $n; $j++) {
        $ans += $d[$i] * $d[$j];
    }
}

echo $ans;

// var_dump($d);


Measured memory_bytes: 4856
/*
	1137:Numeral System
*/
#include	<iostream>
#include	<string>
#include	<stack>

using namespace std;

const char mcxiList[4] = { 'i', 'x', 'c', 'm'};

int MCXI_to_Num(string str);
string Num_to_MCXI(int x);

int main(void) {
	int data;
	cin >> data;
	for(int i = 0; i < data; i++) {
		string str01, str02;
		
		cin >> str01 >> str02;
		
		cout << Num_to_MCXI( MCXI_to_Num(str01) + MCXI_to_Num(str02) ) << endl;
	}
	return 0;
}

int MCXI_to_Num(string str) {
	int out = 0;
	string::iterator it = str.begin();
	
	while(it != str.end()) {
		int memo = 1;
		bool frag = false;
		for(int i = 0; i < 4; i++) {
			if(*it == mcxiList[i]) {
				frag = true;
				break;
			}
		}
		if(frag == false) {
			memo = *it - '0';
			it++;
		}
		switch(*it) {
		case 'm':
			out += memo * 1000;
			break;
		case 'c':
			out += memo * 100;
			break;
		case 'x':
			out += memo * 10;
			break;
		default:
			out += memo;
			break;
		}
		it++;
	}
	
	return out;
}

string Num_to_MCXI(int x) {
	string out;
	stack<char> str;
	int count = 0;
	
	while(x != 0) {
		int n = x % 10;
		if(n != 0) {
			str.push( mcxiList[count] );
			if(n != 1) {
				str.push( n + '0' );
			}
		}
		count++;
		x /= 10;
	}
	while( str.size() ) {
		out += str.top();
		str.pop();
	}
	return out;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  int n,m;
  cin>>n>>m;
  string s[n];
  rep(i,n){
    cin>>s[i];
  }

  bool a[110]={},b[110]={};
  rep(i,n){
    int j=0;
    while(j<m&&s[i][j]=='.') j++;
    if(j==m) a[i]=true;
  }

  rep(j,m){
    int i=0;
    while(i<n&&s[i][j]=='.') i++;
    if(i==n) b[j]=true;
  }

  rep(i,n){
    if(a[i]) continue;
    rep(j,m){
      if(b[j]) continue;
      cout<<s[i][j];
    }
    cout<<endl;
  }


}

Measured memory_bytes: 256