akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define range(i, n) for (int i = 0; i < n; ++i)
#define sz(v) int(v.size())
#define back_range(i, n) for (int i = n - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define eb emplace_back

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair <int, int>;

void fastIO() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

template <class T1, class T2>
istream& operator >> (istream &in, pair <T1, T2> &a) {
    in >> a.first >> a.second;
    return in;
}

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> &a) {
    out << a.first << ' ' << a.second;
    return out;
}

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;

    return in;
}

template <class T>
ostream& operator << (ostream& out, vector <T> &a) {
    for (T i: a) out << i << ' ';
    return out;
}

void solve();

int main() {
    fastIO();

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a + b) {
        cout << min(a, k);
    }

    else {
        cout << a + (-1) * (k - a - b);
    }

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
	point(){}
	point(double _x,double _y){
		x=_x;y=_y;
	}
	point operator +(const point &b) const{
		return point(x+b.x,y+b.y);
	}
	point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	double operator ^(const point &b) const{
		return (x*b.x)+(y*b.y);
	}
	double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
	point operator *(const double &b) const{
		return point(x*b,y*b);
	}
};
point a[105];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i].x>>a[i].y;
	double ans=0;
	for(int i=0;i<n;++i)
		ans+=a[i]*a[(i+1)%n];
	ans/=2;
	printf("%.1lf\n",ans);
	return 0;
} 


Measured memory_bytes: 3208
#include<iostream>
#include<algorithm> 
#include<cstring>
#define ios ios::sync_with_stdio(false)
#define mem(arr) memset(arr,0,sizeof(arr))
using namespace std;
typedef long long ll;
const ll maxn = 1e6 + 10;

int n,a[10],b[10],ans = 0; 

void solve(int a[],int b[])
{
	do
	{
		int flag = 1;
		for(int i = 0;i < n; i++)
		{
			if(a[i] != b[i])
			{
				flag = 0;
				ans++;
				break;
			}
		}
		if(flag) 
			break;
	}while(next_permutation(a,a+n));
}

int main()
{
	cin>>n;
	for(int i = 0;i < n; i++) 
		cin>>a[i];
	for(int i = 0;i < n; i++) 
		cin>>b[i];
	for(int i = 0;i < n; i++)
	{
		if(a[i] < b[i])
		{
			solve(a,b);
			break;
		}
		else if(a[i] > b[i])
		{
			solve(b,a);
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int z = 0;
        int f = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if(a % 4 == 0) f++;
            else if(a % 2 != 0)  z++;
        }
        if(f >= z || (f + 1 == z && f + z == n)) System.out.println("Yes");
        else System.out.println("No");

        sc.close();
    }

}


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

int main(){
    int n;
    cin>>n;
    int h[100010];
    rep(i, n) cin >> h[i];
    ll dp[100010];
    rep(i, n) dp[i]=INF;
    dp[0]=0;

    for(int i=1;i<n;i++){
        dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>=2){
            dp[i]=min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4776
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;

    REP (i, 3) {
        cnt += s[i] == t[i];
    }

    OUT(cnt);
    return 0;
}



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

using namespace std;

int main() {
    int a, b;
    char op;

    while (true) {
        cin >> a >> op >> b;
        switch (op) {
            case '?':
                return 0;
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            default:
                break;
        }
    }
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

VI2 A, B;
int N, M;

int main() {
    std::cin >> N >> M;
    A.resize(N, VI(N));
    B.resize(N, VI(N));

    REP(i, N) REP(j, N) if(i != j) B[i][j] = 1<<28;
    REP(i, M) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a--, b--;
        A[a][b] = A[b][a] = B[a][b] = B[b][a] = c;
    }
    REP(k, N) REP(i, N) REP(j, N) {
        B[i][j] = std::min(B[i][j], B[i][k]+B[k][j]);
    }

    long ans = 0;
    REP(i, N) FOR(j, i+1, N) {
        ans += (A[i][j] > B[i][j]);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int a[maxn];
int b[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int A,B,M;
  cin>>A>>B>>M;
  for(int i=1;i<=A;i++)cin>>a[i];
  for(int i=1;i<=B;i++)cin>>b[i];
  int ma = a[1], mb = b[1];
  for(int i=1;i<=A;i++)ma = min(ma,a[i]);
  for(int i=1;i<=B;i++)mb = min(mb,b[i]);
  int ret = ma+mb;
  while(M--){
    int x,y,c;
    cin>>x>>y>>c;
    ret = min(ret, a[x]+b[y]-c);
  }
  cout<<ret<<endl;
  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  long atack = 0;
  vector<long> hp(n);
  for (int i = 0; i < n; i++) {
    cin >> hp[i];
  }
  sort(hp.begin(), hp.end());
  if(k > n){
      cout << 0 << endl;
      return 0;
  }
  for (int i = 0; i < hp.size() - k; i++) {
      atack += hp[i];
  }
  cout << atack << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main{
    static int num = 200000;
    static int[] hoge = new int[num];
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long, Long> human = new HashMap<>();
        int[] a = new int[n+1];
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
            
        }

        Long count = 0L;
        for(int i=1;i<=n;i++){
            Long v = (long)a[i] + i;
            if(human.containsKey(v)){
                human.put(v, human.get(v)+1);
            }
            else{
                human.put(v, 1L);
            }
        }        
        for(int i=1;i<=n;i++){
            Long v = (long)i - a[i];
            if(human.containsKey(v)){
                count += human.get(v);
            }
        } 
        
        
        System.out.println(count);

    }
}


Measured memory_bytes: 56700
#include<bits/stdc++.h>
#define mo 1000000007
#define N 200005
using namespace std;
int a[N],cnt[N],n,ans;
int val0[N],val1[N],t[N];
int invval1[N],nxt[N],pre[N];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s; 
}
void add(int x,int y){
	for (;x<=n;x+=x&(-x)) t[x]=(t[x]+y)%mo;
}
int ask(int x){
	int s=0;
	for (;x;x-=x&(-x)) s=(s+t[x])%mo;
	return s;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),cnt[a[i]]++;
	for (int i=n-1;i;i--) cnt[i]+=cnt[i+1]-1;
	for (int i=n;i;i--)
		if (cnt[i]<=0) return puts("0"),0;
	val0[0]=val1[0]=1;
	for (int i=1;i<=n;i++){
		val0[i]=1ll*val0[i-1]*cnt[i]%mo;
		val1[i]=1ll*val1[i-1]*max(cnt[i]-1,1)%mo;
	}
	for (int i=1;i<=n;i++){
		val1[i]=1ll*val1[i]*power(val0[i],mo-2)%mo;
		invval1[i]=power(val1[i],mo-2);
	}
	nxt[n]=n;
	for (int i=n-1;i;i--)
		nxt[i]=(cnt[i+1]==1?i:nxt[i+1]);
	for (int i=n;i;i--){
		int tmp=(ask(nxt[a[i]])+mo-ask(a[i]-1))%mo;
		ans=(ans+1ll*tmp*invval1[a[i]]%mo)%mo;
		add(a[i],val1[a[i]]);
	}
	memset(t,0,sizeof(t));
	pre[1]=1;
	for (int i=2;i<=n;i++)
		pre[i]=(cnt[i]==1?i:pre[i-1]);
	for (int i=n;i;i--){
		int tmp=(ask(a[i]-1)+mo-ask(pre[a[i]]-1))%mo;
		ans=(ans+mo-1ll*tmp*val1[a[i]]%mo)%mo;
		add(a[i],invval1[a[i]]);
	}
	ans=1ll*ans*power(2,mo-2)%mo;
	memset(t,0,sizeof(t));
	for (int i=n;i;i--){
		ans=(ans+ask(a[i]-1))%mo;
		add(a[i],1);
	}
	printf("%d",1ll*ans*val0[n]%mo);
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3648
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(1e5)+5;
int T[maxn];

int main() {
    int n,C,K;
    read(n);read(C);read(K);
    REP(i,1,n) read(T[i]);
    sort(T+1,T+n+1);
    int ps=1,res=0;
    REP(i,1,n) {
        if(T[i]-T[ps]>K || i-ps+1>C) {
            ps=i;res++;
        }
    } res++;
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N, M;
  cin >> N >> M;
  int64 mx = 0;
  for (int64 i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (i >= N) mx = max(mx, M / i);
      if (M / i >= N) mx = max(mx, i);
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define m (l+r)/2
#define lson node<<1
#define rson node<<1|1
const int N=6e5+5;
int a[N];
int tree[N*4];
void update(int node,int pos,int v,int l,int r)
{
    if(l==r)
    {
        tree[node]=v;
        return ;
    }
    if(pos<=m)
        update(lson,pos,v,l,m);
    else
        update(rson,pos,v,m+1,r);
    tree[node]=max(tree[lson],tree[rson]);
}
int query(int node,int ql,int qr,int l,int r)
{
    if(ql<=l&&qr>=r)
    {
        //cout<<ql<<" "<<qr<<" ";
       // cout<<node<<" "<<tree[node]<<endl;;
        return tree[node];
    }
    int ans=0;
    if(ql<=m)
        ans=max(query(lson,ql,qr,l,m),ans);
    if(qr>m)
        ans=max(query(rson,ql,qr,m+1,r),ans);
    return ans;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int now;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        now=query(1,max(0,a[i]-k),a[i]+k,0,N)+1;
        ans=max(now,ans);
        update(1,a[i],now,0,N);

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



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

int main(){
    int n;cin >> n;
    string s;
    cin >> s;
    int temp = 0;
    rep(i,n) if(s[i]=='.') temp++;
    int ans = temp;
    rep(i,n){
        if(s[i]=='#') temp++;
        else temp--;
        ans = min(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll ans[201000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, Y;
    cin >> N >> X >> Y;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            ll d = j - i;
            chmin(d, abs(j - Y) + abs(i - X) + 1);
            ans[d]++;
        }
    }
    for(int i = 1; i < N; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}

console.log(main());

function main() {
    let N = next();
    let K = next();
    let A = nexts(N);
    let i, k, left, right;
    for (k = 0; k < K; k++) {
        left = xArray(0, N);
        right = xArray(0, N);
        for (i = 0; i < N; i++) {
            // 各Aiの電球が照らす範囲の端の数を計算する。
            left[Math.max(i + 1 - A[i], 1) - 1]++;
            right[Math.min(i + 1 + A[i], N) - 1]++;
        }
        // 両端にすべての灯りが届いているかどうかをチェック。
        if (left[0] == N && right[N - 1] == N) {
            return xArray(N, N).join(" ");
        }
        // 各範囲の数を合計する。
        A[0] = left[0];
        for (i = 1; i < N; i++) {
            A[i] = A[i - 1] + left[i] - right[i - 1];
        }
    }
    return A.join(" ");
}

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

vector<vector<int>> G;
ll c[200000];
bool seen[200000];

void dfs(int x){
    seen[x]=true;

    for(auto i : G[x]){
        if(seen[i])continue;
        c[i]+=c[x];
        dfs(i);
    }
}

int main(){
    int N,Q; cin>>N>>Q;
    G.resize(N);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    rep(i,N){
        seen[i]=false;
        c[i]=0;
    }
    rep(i,Q){
        int p,x;
        cin>>p>>x;
        c[p-1]+=x;
    }
    dfs(0);
    rep(i,N){
        if(i!=N-1)cout<<c[i]<<" ";
        else cout<<c[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 25376
#include <cstdio>

using namespace std;

int main(void) {
    while (1) {
        int y1, m1, d1, y2, m2, d2;
        scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
        if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) {
            break;
        }
        int d = 0;
        while (y1 != y2 || m1 != m2 || d1 != d2) {
            d++;
            d1++;
            /* 2 4 6 9 11 */
            /* 1 3 5 7 8 10 12 */
            // printf("%4d %2d %2d\n", y1, m1, d1);
            if (((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 > 30) ||
                ((m1 == 1 || m1 == 3 || m1 == 5 ||m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12) && d1 > 31)) {
                d1 = 1;
                m1++;
            } else if (m1 == 2) {
                if (y1 % 4 == 0 && y1 % 100 != 0 || y1 % 400 == 0) {
                    if (d1 > 29) {
                        d1 = 1;
                        m1++;
                    }
                } else if (d1 > 28) {
                    d1 = 1;
                    m1++;
                }
            }
            if (m1 > 12) {
                m1 = 1;
                y1++;
            }
        }
        printf("%d\n", d);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;


int main(){
    string s, t;
    cin >> s >> t;
    int n = s.length(), count = 0;
    for (int i = 0; i < n; i++){
        if (s[i] != t[i])
            count++;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int A[110];
  for (int i = 0; i < N; i++) cin >> A[i];

  int ans = X;

  for (int i = 0; i < N; i++) {
    int j = 0;
    while (A[i] * j + 1 <= D) {
      ans++;
      j++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def pw_calc(arr)
  stack = []
  arr.each do |str|
    if str =~ /[0-9]+/
      stack.push(str.to_f)
    else
      b, a = stack.pop, stack.pop
      case str
        when "+"
          stack.push(a+b)
        when "-"
          stack.push(a-b)
        when "*"
          stack.push(a*b)
        when "/"
          stack.push(a/b)
      end
    end
  end
  return stack.pop
end

while gets do
  arr = $_.chomp.split(' ')
  num = pw_calc(arr)
  puts sprintf("%.7f", num)
end

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;

int main(){
  int n, x;
  cin >> n >> x;
  int a[110000];
  ll ans = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  if(a[0] > x){
    ans += a[0] - x;
    a[0] = x;
  }
  for(int i = 0; i < n-1; i++){
    if(a[i] + a[i+1] > x){
      ans += a[i+1] + a[i] - x;
      a[i+1] = x - a[i];
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    int k;
    int n[5];
    for(int i=0;i<5;i++){
        cin >> n[i];
    }
    cin >> k;
    bool jg=true;
    for(int i=0;i<5;i++){
        for(int j=i;j<5;j++){
            if(abs(n[i]-n[j])>k) jg=false;
        }
    }
    cout << (jg ? "Yay!" : ":(") << endl;
    return 0;
}

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


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

    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i]>>b[i]>>c[i];
    }

    int dp[n][3];
    dp[0][0]=a[0];	dp[0][1]=b[0];	dp[0][2]=c[0];

    for(int i=1;i<n;i++)
    {
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];    	
    }

    int ans=0;
    for(int i=0;i<3;i++)
    {
    	if(dp[n-1][i]>ans)
    		ans=dp[n-1][i];
    }

    cout<<ans;
}

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

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

int main(){
  int k;
  cin >> k;
  queue<long long> todo;
  for(long long i = 1; i <= 9; i++) todo.push(i);

  long long x = 0;
  for(int i = 0; i < k; i++){
    x = todo.front();
    todo.pop();
    if(x % 10 != 0) todo.push(10*x + x % 10 - 1);
    todo.push(10*x + x % 10);
    if(x % 10 != 9) todo.push(10*x + x % 10 + 1);
  }
  cout << x << endl;

  

  return 0;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define I_L_T_S ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
const int N = 1e5 + 2;
const int mod = 1e9 + 7;

long long binpow(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
int w[N] , val[N];
int foo(int n ,int weight ){
	if(n == 0 || weight == 0) return 0;
	if(weight < w[n - 1]){
         return foo(weight , n - 1);
	 }
     int ans = max(val[n -1] + foo(n - 1 , weight - w[n - 1] ) , foo(n - 1 , weight ));
	return ans ;
}
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
}
int fun(int n , int weight){
	int dp[n + 1][weight + 1];
	for(int i = 0 ; i <= n ;i++){
		for(int j = 0 ; j <= weight ; j++){
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(w[i - 1] <= j){
				 dp[i][j] = max(val[i -1] + dp[i - 1][j - w[i - 1]] , dp[i - 1][j]); 	
			}
			else dp[i][j] = dp[i - 1][j];
		}
	}
	return dp[n][weight];
}

int32_t main(){
   I_L_T_S;
   int n , weight;
   cin >> n >> weight ;
   std::vector < pair <int , pair < int , int > > > v;
   for(int i = 0 ; i < n ; i++){
   		cin >> w[i] >> val[i];
   }
   cout  << fun( n , weight);
   return 0;
}















Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	int x;
	cin>>x;
	cout<<(x>=30?"Yes":"No");
	
}



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

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

enum dir{ RIGHT = 0, UP = 1, LEFT = 2, DOWN = 3 };

struct state{
    int x;
    int y;
    int mem;
    dir vec;
    state(){}
    ~state(){}
    state(int a, int b, int v, dir d): x(a), y(b), mem(v), vec(d) {}
}; 
int main(){
    string str[20];
    bool visited[20][20][16][4];
    int r, c;
    cin >> r >> c;
    for(int i = 0; i < r; i++){
        cin >> str[i];
        for(int j = 0; j < c; j++){
            for(int k = 0; k < 16; k++){
                for(int l = 0; l < 4; l++){
                    visited[i][j][k][l] = false;
                }
            }
        }
    }
    queue<state> que;
    que.push(state(0, 0, 0, (dir)0));
    bool stop = false;
    while(!que.empty()){
        state s = que.front(); que.pop();
        int x = s.x, y = s.y;
        if(visited[x][y][s.mem][s.vec]) continue;
        visited[x][y][s.mem][s.vec] = true;
        if(str[x][y] == '@'){
            stop = true;
            break;
        }
        if(str[x][y] == '?'){
            for(int i = 0; i < 4; i++){
                que.push(state((x+dx[i]+r)%r, (y+dy[i]+c)%c, s.mem, (dir)i));
            }
            continue;
        }
        if(str[x][y] == '<'){
            s.vec = LEFT;
        }
        if(str[x][y] == '>'){
            s.vec = RIGHT;
        }
        if(str[x][y] == '^'){
            s.vec = UP;
        }
        if(str[x][y] == 'v'){
            s.vec = DOWN;
        }
        if(str[x][y] == '_'){
            if(s.mem == 0){
                s.vec = RIGHT;
            }else{
                s.vec = LEFT;
            }
        }
        if(str[x][y] == '|'){
            if(s.mem == 0){
                s.vec = DOWN;
            }else{
                s.vec = UP;
            }
        }
        if('0' <= str[x][y] && str[x][y] <= '9'){
            s.mem = str[x][y] - '0';
        }
        if(str[x][y] == '+'){
            s.mem = (s.mem+1)%16;
        }
        if(str[x][y] == '-'){
            s.mem = (s.mem+15)%16;
        }
        que.push(state((x+dx[s.vec]+r)%r, (y+dy[s.vec]+c)%c, s.mem, s.vec));
    }
    if(stop){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int n;
  cin >> n;
  vector<int> v(n+1, 0), b(n+1, 0);

  rep(i, n+1){
    if(i == 0) continue;
    cin >> b[i];
  }

  int i = 1, count = 1;
  while(true){
    if(b[i] == 2){
      cout << count << endl;
      return 0;
    }
    else if(v[i] == 0){
      v[i] = 1;
      count++;
      i = b[i];
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 1152
import bisect
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_acc = [0]
b_acc = [0]
now = 0
for i in range(n):
  now += a[i]
  a_acc.append(now)

now = 0
for i in range(m):
  now += b[i]
  b_acc.append(now)

ans = 0
for i in range(n+1):
  t = k - a_acc[i]
  if t < 0:
    break
  ind = bisect.bisect_left(b_acc, t)
  if ind == m+1:
    ans = max(ans, i+m)
    ind -= 1
  if b_acc[ind] == t:
    ans = max(ans, i+ind)
  else:
    ans = max(ans, i+ind-1)

print(ans)


Measured memory_bytes: 47396
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int K, X;
    cin >> K >> X;
    if(500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/*
 * Author : Sadi
 * Wed 08/07/2020
 * 17:03:54.55
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b, c;
    cin >> a >> b >> c;
    if(a - b > c) {
    	cout << 0 << endl;
    }
    else {
    	cout << c - (a - b) << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next , *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil){
            break;
        }
        if(isf++ > 0){
            printf(" ");
        }
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t == nil){
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key,n;
    char com[20];
    scanf("%d",&n);
    init();
    for(int i = 0;i < n;i++){
        scanf("%s",&com);
        scanf("%d",&key);
        if(com[0] == 'i'){
            insert(key);
        }else if(com[0] = 'd'){
           if(strlen(com) > 6){
               if(com[6] == 'F'){
                   deleteFirst();
               }else if(com[6] == 'L'){
                   deleteLast();
               }
           }else{
               deleteKey(key);
           }
        }
    }
    printList();
    return 0;
}


Measured memory_bytes: 33968
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	string s[n];
	lp2(i,n)cin>>s[i];
	sort(s,s+n);
	lp2(i,n)cout<<s[i];
	cout<<endl;
	return 0;
}


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

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

//0:ツづ按つオ
//1:ツ債カ
//2:ツ可コ
//3:ツ猟シツ陛サ
int mat[20][20];
long long mp[20][20];

int main() {
  int n,gx,gy,p,px,py,qx,qy,i,j;
  cin>>n;
  while(n--) {
    memset(mp, 0, sizeof(mp));
    memset(mat, 0, sizeof(mat));
    cin>>gx>>gy;
    cin>>p;
    rep(i,p) {
      cin>>qx>>qy>>px>>py;
      if(qx == px) {
	mat[qx][min(qy,py)] += 2;
      } else {
	mat[min(qx,px)][qy] += 1;
      }
    }

    mp[0][0] = 1;
    rep(i,gy+1) {
      rep(j,gx+1) {
	if(i == 0) {
	  if(j > 0 && mat[j-1][i]%2 == 0) mp[j][i] += mp[j-1][i];
	  continue;
	}
	if(j == 0) {
	  if(i > 0 && mat[j][i-1]/2 == 0) mp[j][i] += mp[j][i-1];
	  continue;
	}
	if(mat[j][i-1]/2 == 0) mp[j][i] += mp[j][i-1];
	if(mat[j-1][i]%2 == 0) mp[j][i] += mp[j-1][i];
      }
    }

if(mp[gx][gy] == 0) {
cout<<"Miserable Hokusai!"<<endl;
}else{
    cout<<mp[gx][gy]<<endl;
}
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;

void solve(){

  int x, n;
  std::cin >> x >> n;
  std::set<int> p;
  for(int i=0; i<n; i++){
    int tmp;
    std::cin >> tmp;
    p.insert(tmp);
  }

  int diff=0;
  while(true){
    int test_1 = x-diff;
    if(p.find(test_1)==p.end()){
      std::cout << test_1 << std::endl;
      return;
    }
    int test_2 = x+diff;
    if(p.find(test_2)==p.end()){
      std::cout << test_2 << std::endl;
      return;
    }
    diff++;
  }



  return;
  
}

int main(void){

  solve();
  
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>

using namespace std;

string s;
int main(){
	cin >> s;
	int len = s.length();
	for(register int i = 0; i < len; i++){
		if (s[i] == 'C'){
			for (register int j = i; j < len; j++){
				if (s[j] == 'F'){
					cout << "Yes"<< endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
S, T = input(), input()
rewrite_num = float('inf')
for i in range(len(S) - len(T) + 1):
    
    t = len(list(filter(lambda x: x[0] != x[1], zip(S[i:i+len(T)+1], T))))
    rewrite_num = t if t < rewrite_num else rewrite_num
    
print(rewrite_num)


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define MAX 3004
const int inf = 1e9;
#define rrep(i,n) for(int i = 1;i <= n;i++)

int a[MAX], b[MAX], res[MAX];
int dp1[MAX][MAX], dp2[MAX][MAX];//店,時間
int main(){
	int n, t, s;
	scanf("%d%d%d", &n, &t, &s);
	rrep(i,n)scanf("%d%d", &a[i], &b[i]);
	
	for(int i = 1;i <= n;i++){
		for(int j = s;j >= 0;j--){
			dp1[i][j] = max(dp1[i][j], dp1[i-1][j]);
			if(b[i] <= j)
			dp1[i][j] = max(dp1[i][j], dp1[i-1][j-b[i]]+a[i]);
		}
	}
	
	for(int i = 1;i <= n;i++){
		int m = n-i+1;
		for(int j = t-s;j >= 0;j--){
			dp2[i][j] = max(dp2[i][j], dp2[i-1][j]);
			if(b[m] <= j)
			dp2[i][j] = max(dp2[i][j], dp2[i-1][j-b[m]]+a[m]);
		}
	}
	
	for(int i = 1;i <= n;i++)res[i] = max(res[i-1], dp2[i][t-s]);
	/*for(int i = 0;i <= n;i++)printf("%d ", res[i]);
	printf("\n");*/
	
	int ans = 0;
	for(int i = 0;i <= n;i++){
		ans = max(ans, dp1[i][s]+res[n-i]);
	}
	
	/*for(int i = 1;i <= n;i++){
		for(int j = 0;j <= t-s;j++)printf("%d ", dp2[i][j]);
		printf("\n");
	}*/
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 62388
n,k=map(int,input().split())
a=list(map(int,input().split()))

d=[0]*n
for i in range(n):
    d[a[i]-1]+=1

d.sort(reverse=True)

sm=0
for i in range(k):
    if i>=n:
        break
    sm+=d[i]

print(n-sm)    

Measured memory_bytes: 32276
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int N_MAX = 100001;
int main()
{
  int n,t,i,j,res=0;
  int b[N_MAX];
  string s;
  char c[N_MAX];
  cin >> s;
  n=s.size();
  fill(b,b+N_MAX,0);
  for(i=0,t=0;i<n;i++)
    if(s[i]=='x'){
      b[t]++;
    }else{
      c[t]=s[i];
      t++;
    }
  for(i=0;i<(t+1)/2;i++){
    if(c[i]!=c[t-1-i]){
      cout << "-1" << endl;
      return 0;
    }
    res+=abs(b[i]-b[t-i]);
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> I(N, -1);
  bool ok = true;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (I[s] != -1 and I[s] != c) {
      ok = false;
    }
    I[s] = c;
  }
  if (N > 1 and I[0] == 0) {
    ok = false;
  }
  if (ok) {
    for (int i = 0; i < N; i++) {
      if (I[i] == -1) {
        if (N > 1 and i == 0) {
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        cout << I[i];
      }
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())
#n,m=input_list()
a=input_list()
ans=1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()



print(ans)


Measured memory_bytes: 40104
S=input()
a=0
for i in range(len(S)-2):
  if S[i]==S[i+1] or S[i]==S[i+2] or S[i+1]==S[i+2]:
    a=1
    print(i+1,i+3)
    break

if a==0:
 if len(S)>1 and S[-1]==S[-2]:
  print(len(S)-1,len(S))
 else:
  print(-1,-1)



Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i=x-k+1;i<x+k;i++){
            if(i>-1000000&&i<1000000){
                System.out.print(i);
                if(i!=x+k-1){
                    System.out.print(" ");
                }
            }
        }
    }
}

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

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> lamps(N);
    for(int i=0; i<N; i++){
        cin >> lamps.at(i);
    }

    int k;
    for(k=0; k<K; k++){
        int minIntensity = *min_element(lamps.begin(), lamps.end());
        if(minIntensity == N)break;

        vector<int> next(N+1,0);
        for(int i=0; i<N; i++){
            int intensity = lamps.at(i);

            int l = max(0, i-intensity);
            int r = min(N-1, i+intensity);

            next.at(l)++;
            if(r+1<N)next.at(r+1)--;
        }

        for(int i=1; i<N; i++)next.at(i) += next.at(i-1);

        copy(next.begin(), next.end(), lamps.begin());
    }

    // cout << "k: " << k << endl;
    for(int i=0; i<N; i++){
        if(i==N-1)cout << lamps.at(i) << endl;
        else cout << lamps.at(i) << " ";
    }
}

Measured memory_bytes: 4840
def solve(n, a, b, c, d):
    if n == 1:
        return d
    if n == 0:
        return 0
    
    if n in memo:
        return memo[n]
    
    ans = min(
        n * d, 
        
        abs(n-n//2*2)*d + a + solve(n//2, a, b, c, d),
        abs(n-(n+1)//2*2)*d + a + solve((n+1)//2, a, b, c, d),
        
        abs(n-n//3*3)*d + b + solve(n//3, a, b, c, d),
        abs(n-(n+2)//3*3)*d + b + solve((n+2)//3, a, b, c, d),
        
        abs(n-n//5*5)*d + c + solve(n//5, a, b, c, d),
        abs(n-(n+4)//5*5)*d + c + solve((n+4)//5, a, b, c, d)        
        )
    memo[n] = ans
    return ans


t = int(input())
for i in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {}
    print(solve(n, a, b, c, d))

Measured memory_bytes: 10800
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int X;
	cin >> X;
	int a = X / 100;
	int num = X % 100;
	if (num > a * 5)cout << 0;
	else cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int head[N],nn[N][2],cnt,f[N],v[N],d[N],c[N];
int col[N],st[N],g[N],vis[N];
#define link(x,y) (nn[++cnt][1]=y,nn[cnt][0]=head[x],head[x]=cnt)
void bfs(int x,int D,int cl){
    int l=0,r=1,s,t; st[1]=x,g[1]=D;
    while(l<r){
	s=st[++l];
	if (!vis[s]) vis[s]=1,col[s]=cl;
	if (g[l]<=f[s]) continue;
	f[s]=g[l];
	for (int i=head[s]; i; i=nn[i][0])
	    t=nn[i][1],st[++r]=t,g[r]=g[l]-1;
    }
    return;
}
int main(){
    int n=gi(),m=gi(),q,x,y;
    for (int i=1; i<=m; ++i)
	x=gi(),y=gi(),link(x,y),link(y,x);
    q=gi();
    for (int i=1; i<=q; ++i)
	v[i]=gi(),d[i]=gi(),c[i]=gi();
    for (int i=q; i>=1; --i)
	bfs(v[i],d[i],c[i]);
    for (int i=1; i<=n; ++i)
	printf("%d\n",col[i]);
    return 0;
}


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

int main() {
  
  int N, a, b, c, d;
  cin >> N;
  a = N % 1000;
  b = N / 10 % 111;
  c = N % 1111;
  
  if (a == 0 || a == 111 || b == 0 || c == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}
  
  
  
  
  
    
  

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

bool bit[11];
int D;
int imax; //0のmax

void make_bit(int n){
    for(int i=0; i<D; i++){
        bit[i]=n%2;
        if(n%2==0) imax=i;
        n /=2;
    }
    return;
}

int main(){
    int G;
    long long p[11], c[11];
    cin >> D >> G;
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    long long dp[1000]; //i問解いた時のmaxの点数
    fill(dp,dp+1000,0);
    long long sum = 0;
    long long ans = 0;
    for(int i=0; i<D; i++){
        sum +=p[i];
        ans += (i+1)*p[i]*100+c[i];
    }

    dp[sum] = ans;

    for(int i=0; i<pow(2,D)-1; i++){
        long long s =0, a=0;
//        cout << D << endl;
        make_bit(i);
//        cout << imax << endl;
        for(int j=0; j<D; j++){
            s += bit[j]*p[j];
            a += bit[j]*( p[j]*(j+1)*100+ c[j]);
        }
//        cout << s << " " << a << endl;
        for(int k=0; k<p[imax]; k++){
            dp[s+k] = max(dp[s+k], a+(imax+1)*100*k);
        }
    }
//    for(int i=0; i<=sum; i++){
//        cout << dp[i] << endl;
//    }
    cout << lower_bound(dp, dp+sum+1, G) - dp << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K; cin>>N>>K;
  ll A[N], B[2*N], x=0, y=0, MOD=1000000007;
  for(int i=0; i<N; i++){ll a; cin>>a; A[i]=a, B[i]=a;}
  for(int i=0; i<N; i++){B[i+N]=B[i];}
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      if(A[i]>A[j]) x++;
    }
  }
  for(int i=0; i<2*N-1; i++){
    for(int j=i+1; j<2*N; j++){
      if(B[i]>B[j]) y++;
//      cout<<"i:"<<i<<" B[i]:"<<B[i]<<" B[j]:"<<B[j]<<endl;
    }
  }
  ll ans=x*K%MOD;
  ll b=(K-1)*K/2%MOD;
  ans+=(y-2*x)*b%MOD;
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] h = new int[n];


		for(int i = 0; i < n ; i++) {
			h[i] = scan.nextInt();
		}

		Arrays.sort(h);

		long ans = 0;
		for(int i = 0; i < n-k; i++) {
			ans += h[i];
		}


		System.out.println(ans);

	}

}

Measured memory_bytes: 87064
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; std::vector<int> d;
    for(int i=0; i<N;i++){
      int a; cin>>a; d.push_back(a);
    }
    sort(d.begin(), d.end());
    int ans = d[N/2] - d[N/2-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>

using namespace std;

void sort(int a[],int N)
{
	for(int i = N-1;i>0;i--)
	{
		for(int j=0;j<i;j++)
		{
			if(a[i] > a[j])
			{
				int tmp = a[j];
				a[j] =a[i];
				a[i] = tmp;
			}
		}
	}
}

int main()
{
	int card[3];

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

	sort(card,3);

	cout << card[0]*10 + card[1] + card[2] << endl;

	return 0;
}


Measured memory_bytes: 256