akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int data[100];
int sp =0;
int empty(){
    return sp <= 0;
}
int pop(){
    sp--;
    return data[sp+1];
}
void push(int v){
    sp++;
    data[sp] = v;
}
int main(){
    int a;
    while(scanf("%d",&a) != EOF){
        if(a != 0){
            push(a);
        }else{
            if(empty()){
                break;
            }
            printf("%d\n",pop());
        }
         
    }
    return 0;
}

Measured memory_bytes: 1804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int W=sc.nextInt();
		int H=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();

		if(x-r>=0&&x+r<=W)
			if(y-r>=0&&y+r<=H){
				System.out.println("Yes");
			}
			else	System.out.println("No");
		else	System.out.println("No");

	}
}

Measured memory_bytes: 26392
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll A, B, C, D;
	std::cin >> A >> B >> C >> D;
	

	while (A > 0 && C > 0) {
		C -= B;
		if (C <= 0) {
			std::cout << "Yes" << endl;
			return 0;
		}
		A -= D;
	}

	std::cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
//
// Created by Tzyark on 2018/9/19.
//
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i-1] != s[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n;
string str;
void solve(){
  if(n% 2 == 0)cout << n << endl;
  else cout << (n*2) << endl;

  return;
}
int main(){
  cin >> n;
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner (System.in);
    String s = sc.next();
    int n = 0;

    for(int i=0 ; i<4 ; i++){
      if(s.charAt(i)=='+'){
        n++;
      }else if(s.charAt(i)=='-'){
        n--;
      }
    }
    System.out.println(n);
  }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main () {
	char buff[1024];
	int a, b;

	while (fgets (buff, 1024, stdin) != NULL) {
		sscanf (buff, "%d %d", &a, &b);

		printf ("%d\n", (int)log10 (a + b) + 1);
	}
	
	return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
string s,t;

int main(){
	cin >> s >> t;
	sort(s.begin(), s.end()); sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	cout << (s<t?"Yes":"No") << endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n;LL sum;
bitset<2005*2005> dp;
int main()
{
    n=read();dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        int x=read();
        dp|=dp<<x;sum+=x;
    }
   for(int i=sum+1>>1;i<=sum;i++)
   if(dp[i])
   {
       printf("%d\n",i);
       return 0;
   }
	return 0;
}

Measured memory_bytes: 1664
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(s) freopen(s".in", "r", stdin), freopen(s."out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 2010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

/*


题意：每次从1~n往两边加数 每次 取的时候从两边取问第k个是1的情况 一共有多少是成立的

首先 我们可以通过观察得出 我1~n加数的这个数列 一定是一个v字形的这么一个序列 然后1在最中间 那么这样的话 我取到1的话是不是说明我前面的k-1一定可以是一个降序序列或者是两个降序序列 那么求一下这个个数我可以dp一下 设f[i][j]表示我已经填了前1~i这么多个位置了 我前面填过的数中最小的是j那我可以知道我现在其实是假设有两个栈 然后分别取数的方案数 比如 我取9 8 7 2

这样 如果下一个数一定要比我大的话 方案数 必须只能转移到当前空缺位置 的最大 否则就是无效的

或者可以选择转移到所有比我小的地方 累积一下方案数

相当于我这个dp要求这样的 有多少个 那么f[i+1][j]自然可以由上一层的f[i][j+1]+f[i+1][j+2]+….得到啊 然后针对这个做一个前缀和优化 变成n^2的情况然后转移的时候要注意一些细节 比如如果k是0的情况

然后那么只要前面k个都确定了 剩下的我是不是还是随便选啦 可以当作是dp 就是每次从两边选一个的方案数一共是多少 那么前面k个确定了 后面我随便放 方案数就是2^(n-k-1)种方案数 为什么呢 因为这次一定剩下的是一条递增的序列了 我想怎么取就怎么取

最后统计答案的时候我只需要把前k-1位的所有情况都取出来 然后后n-k让他随便排 乘一乘就好

*/

int f[N][N], s[N] ;
int n, k, ans ;

signed main(){
    scanf("%d%d", &n, &k) ;
    f[0][n + 1] = 1 ; s[n + 1] = 1 ;
	per(i, n, 1) s[i] = s[i + 1] + f[0][i] ;
	rep(i, 1, k - 1) {
		rep(j, 1, n - i + 1) f[i][j] = s[j] ;
		s[n + 1] = f[i][n + 1] ;
		per(j, n, 1) s[j] = (s[j + 1] + f[i][j]) % MOD ;
	}
	rep(i, 2, n + 1) (ans += f[k - 1][i]) %= MOD ;
	rep(i, 1, n - k - 1) (ans *= 2) %= MOD ;
	printf("%d\n", ans) ;


	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/



Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, sum = 0;
    bool discard = false;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> s[i];
        sum += s[i];
    }
    sort(s, s + n);
    if (sum % 10 != 0) cout << sum;
    else
    {
        for (int i = 0; i < n; i++)
        {
            if (s[i] % 10 != 0)
            {
                cout << sum - s[i];
                discard = true;
                break;
            }
        }
        if (discard == false) cout << '0';
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	ll n;	cin >> n;
	string ans = "";
	while (n) {
		n--;
		ll rem = n % 26;
		//cout << rem << '\n';
		ans += (97 + rem);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

//97 122

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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int h, w;
    DI(h, w);
    vector<string> grid(h);
    F(i, 0, h)
        SI(grid[i]);
    int dp[h][w];
    F(i, 0, h)
    {
        F(j, 0, w)
        {
            if(i == 0 && j == 0)
            {
                dp[i][j] = (grid[i][j] == '#');
                continue;
            }
            dp[i][j] = INF;
            if(i)
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (grid[i-1][j] == '.' && grid[i][j] == '#'));
            if(j)
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (grid[i][j - 1] == '.' && grid[i][j] == '#'));
        }
    }
    SO(dp[h - 1][w - 1]);
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005

int main(){
  ll ans;
  cin >> ans;
  cout << ans*ans*ans << endl;
  return 0;
}


Measured memory_bytes: 3076
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int n,i,j,k,l;
    cin>>n;
    int b[n],a[n+1];
    for(i=1;i<n;i++) cin>>b[i];
    a[1]=b[1];
    for(i=2;i<n;i++)
    {
      a[i]=min(b[i],b[i-1]);
    }
    a[n]=b[n-1];
    int s=0;
    for(i=1;i<=n;i++) s+=a[i];
    cout<<s;
  }

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
void init(void);
void printGraph(void);

int graph[N][N];
int n;
int main() {
	int i, j, l, m, in;

	init();
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &l, &m);
		for (j = 0; j < m; j++)  {
			scanf("%d", &in);
			graph[l - 1][in - 1] = 1;
		}
	}

	printGraph();
	return 0;
}
void init(void) {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			graph[i][j] = 0;
		}
	}
}
void printGraph(void) {
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (j > 0) printf(" ");
			printf("%d", graph[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      int HP = sc.nextInt();//モンスターHP
      int N = sc.nextInt();//必殺技の種類
           
      //必殺技でHPを減らしていく
      for(int i = 1; i<=N; i++){
        int hit = sc.nextInt();
        HP -= hit;       
      }  
      //HPが0以下かどうか出力
       System.out.print(HP<=0 ? "Yes":"No");
    }
}

Measured memory_bytes: 48448
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int s[10][10];

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<int> p(M);
  rep(i,M) {
    cin >> k[i];
    rep(j,k[i]) cin >> s[i][j];
  }
  rep(i,M) cin >> p[i];

  vector<int> sw(N);

  int ans = 0;
  rep(i,1<<N) {
    bool ok = true;
    rep(j,N) {
      if (i>>j&1) sw[j] = 1;
      else sw[j] = 0;
    }
    rep(j,M) {
      int ons = 0;
      rep(l,k[j]) if (sw[s[j][l]-1] == 1) ons++;
      if (ons%2!=p[j]) ok = false;
    }
    if (ok) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3196
//Create Time: 2018-04-15 22:57:03
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
#define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
#define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define DEBUG
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi > vii;
/****head****/
int main(){
    int n;cin>>n;
    if(n==3){
        puts("2 5 63"); return 0;
    }
    vi a,b,c;
    rep(i,5,30001){
        if(i%2!=0){
            if(i%3==0 && i>9)c.pb(i);
            continue;
        }
        if(i%3==0)b.pb(i);
        else a.pb(i);
    }
    int i=0,j=0,k=0;
    vi ans={2,3,4,9};
    while(SZ(ans)<n){
        if(i+1<SZ(a)){
            if(SZ(ans)+1==n){
                ans.pb(b[j++]);
            }else{
                ans.pb(a[i++]);
                ans.pb(a[i++]);
            }
        }else if(k+1<SZ(c)){
            if(SZ(ans)+1==n){
                ans.pb(b[j++]);
            }else{
                ans.pb(c[k++]);
                ans.pb(c[k++]);
            }
        }else{
            assert(j<SZ(b));
            ans.pb(b[j++]);
        }
    }
    assert(SZ(ans)==n);
    // sort(all(ans));
    // rep(i,1,SZ(ans))if(ans[i]==ans[i-1])TST(ans[i-1]),OUT(ans[i]),assert(false);
    // set<int> tt(all(ans));
    // assert(SZ(tt)==SZ(ans));
    for(int i:ans)printf("%d ",i);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, m, cost[] = {0,2,5,5,4,5,6,3,7,6}, anslen = 0;
vector<P> a;
vector<int> dp;

int main() {
    cin >> n >> m;
    a.resize(m);
    REP(i,m){
        cin >> a[i].second;
        a[i].first = cost[a[i].second];
        a[i].second *= -1;
    }
    SORT(a);
    dp.resize(n+10,-1);
    dp[0] = 0;
    REP(i,n){
        REP(j,m){
            if(dp[i]==-1)continue;
            dp[i+a[j].first] = max(dp[i+a[j].first],dp[i]+1);
        }
    }
    string ans;
    int r = n;
    while(r > 0){
        ll num = 0, use = 0;
        REP(i,m) if(r>=a[i].first && dp[r]-dp[r-a[i].first]==1 && num < -a[i].second){
            num = -a[i].second;
            use = a[i].first;
        }
        ans.push_back('0'+num);
        r -= use;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = []
for i in range(m - 1):
    d.append(x[i + 1] - x[i])
d.sort()
# print(d)
if m - n <= 0:
    print(0)
else:
    print(sum(d[: m - n]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string S, T;

int main(void){
  
  I(S);
  I(T);
  REP(i, S.size()) {
    if (S[i] != T[i]) {
      ret++;
    }
  }

  P(ret);

}


Measured memory_bytes: 3888
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

  int a; cin >> a;
  cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
//#include<set>
using namespace std;
int main()
{
	int i, n, left, right, mid;
	vector<long> data;
	vector<long>::iterator it;
	long input;

	cin >> n;
	cin >> input;
	data.push_back(input);
	for (i = 1; i < n; i++) {
		cin >> input;
		it = lower_bound(data.begin(), data.end(), input);
		if (it == data.begin() ){
			data.insert(it,input);
		}
		else {
			it--;
			if (*it == input ) {
					data.insert(it, input);

			}
			else {
				*it = input;
			}
		}
	}

	/*
	multiset<long,greater<long> > data;
	multiset<long,greater<long> >::iterator it;
	multiset<long,greater<long> >::iterator end;
	long input;
	long saitei;

	cin >> n;
	cin >> input;
	data.insert(input);
	for (i = 1; i < n; i++) {
		cin >> input;
		end = data.end();
		end--;
		saitei = *end;
		if (saitei >= input) {
			data.insert(input);
		}
		else {
			end++;
			for (it = data.begin(); it != end; it++) {
				if (*it < input) {
					data.erase(it);
					it = data.insert(input);
					break;
				}
			}
		}
		
		


	}

	*/


	cout << data.size() << endl;

	return 0;
}


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

#define int long long
#define M 1000000009
#define M2 998244353

signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int n;
	cin >> n;
	map<string,int> mp;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,a[200010],d; 

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>d;
	int ans=0ll;
	for(int i=1;i<=n;i++) cin>>a[i],ans+=a[i];
	ans+=(n-1)*d;
	for(int i=2;i<=n;i++) a[i]=min(a[i],a[i-1]+d);
	for(int i=n-1;i>=1;i--) a[i]=min(a[i],a[i+1]+d);
	for(int i=2;i<=n-1;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
H, W = map(int, input().split())
l = []

for i in range(H):
    l.append(list(input()))

for i in range(H):
    for j in range(W):
        
        if l[i][j] == '.':
            pass
        else:
            count = 0
            if i > 0 and l[i-1][j] == '#':
                    count += 1 #上方向
            if i < (H-1) and l[i+1][j] == '#':
                count += 1     #下方向
            if j > 0 and l[i][j-1] == '#':
                count += 1     #左方向
            if j < (W-1) and l[i][j+1] == '#':
                count += 1     #右方向
            if count == 0:
                print('No')
                sys.exit()
                
print('Yes')
            

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

int main()
{
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;
	return 0;
}

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

int main() {
    vector<ll> l(4);
    rep(i, 0, 4) cin >> l[i];
    ll cost1 = min({4*l[0], 2*l[1], l[2]});
    ll n;
    cin >> n;
    ll ans = min((n/2)*l[3]+(n%2)*cost1, n*cost1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int i;
        char str[1201];
        fgets(str,1201,stdin);
        for(i=0; str[i]!='\0'; i++){
                if(str[i] >= 'a' && str[i] <= 'z')
                        str[i] -= ('a'-'A');
                else if(str[i] >= 'A' && str[i] <= 'Z')
                        str[i] += ('a'-'A');
        }
        printf("%s",str);
        return 0;
}


Measured memory_bytes: 2036
package main

import "fmt"

func main() {
	// Code for C - Takahashi's Information
	var c [4][4]int
	for i := 1; i <= 3; i++ {
		for j := 1; j <= 3; j++ {
			fmt.Scan(&c[i][j])
		}
	}

	var a [4]int
	var b [4]int
	a[1] = 0

	for i := 1; i <= 3; i++ {
		b[i] = c[1][i] - a[1]
	}

	for i := 2; i <= 3; i++ {
		a[i] = c[i][1] - b[1]
	}

	var flag int
	for i := 1; i <= 3; i++ {
		for j := 1; j <= 3; j++ {
			if c[i][j] != a[i]+b[j] {
				flag++
			}
		}
	}

	if flag == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
int x[10000];
int main(){

    int N,X,Y;
    cin>>N>>X>>Y;
    for(int i=1;i<N;i++)
    {
        for(int j=i+1;j<=N;j++)
        {
            int h=abs(X-i)+abs(Y-j)+1;
            if(h<j-i)
               x[h]++;
            else
                x[j-i]++;
        }
    }
    x[1]=N;
    for(int i=1;i<N;i++)
        printf("%d\n",x[i]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    ll a = 1, b = 0;
    vector<ll> S = {0};
    rep(i, 100) {
        a *= 26;
        b += a;
        S.push_back(b);
    }
    ll N;
    cin >> N;
    int k = 0;
    rep(i, 101) {
        if (S[i] >= N) {
            N -= S[i - 1];
            k = i;
            break;
        }
    }
    vector<int> ans(k, 0);
    --N;
    for (int i = k - 1; i >= 0; --i) {
        ans[i] = N % 26;
        N /= 26;
    }
    rep(i, k) cout << (char)('a' + ans[i]);
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3648
using System;

namespace TestSpace
{
    class Test
    {
        static void Main(string[] args)
        {
            string[] arrRead;
            arrRead = Console.ReadLine().Split(' ');
            int a, b, c;
            a = int.Parse(arrRead[0]);
            b = int.Parse(arrRead[1]);
            c = int.Parse(arrRead[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("{0}", "Yes");
            }
            else
            {
                Console.WriteLine("{0}", "No");
            }
        }
    }
}


Measured memory_bytes: 17944
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    int n;
    cin>>n;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    sort(all(v));
    vector<int> sum(n+1,0);
    for(int i=1;i<=n;i++)sum[i] = v[i-1];
    
    for(int i=1;i<=n;i++){
        sum[i] += sum[i-1];
    }
    
    auto solve = [&](int mid){
        int t = sum[mid];
        for(int i = mid;i<n;i++){
            if(v[i]<=2*t){
                t+=v[i];
            }else{
                return false;
            }
        }
        return true;
    };
    
    ll left=0, right=n, mid=(left+right)/2LL;
    while(left+1<right){
        bool res = solve(mid);

        if(!res) left = mid;
        else    right= mid;

        mid = (left+right)/2LL;
    }
    
    cout<<n-mid<<endl;
}


Measured memory_bytes: 1792
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){   
    int n;
    cin >> n;
    // n--;
    int a[n - 1];
    in(a, n - 1);
    int f[n + 1] = {0};
    for(int i= 0; i < n - 1; i++){
        f[a[i]]++;
    }
    for(int i = 1; i <= n; i++){
        cout << f[i] << endl;
    }
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("../../input", "r", stdin);
                                                            // freopen("../../output", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

Measured memory_bytes: 5212
/**
 * @author torith
 * @date 2018-10-31
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N; cin >> N;

    ll ans = (N / 11) * 2;
    if (N % 11 == 0) cout << ans << "\n";
    else if (N % 11 > 6) cout << ans + 2 << "\n";
    else cout << ans + 1 << "\n";

    return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<int> p(N);
    rep(i,N) cin >> p[i];
    
    //-----------------------------------
    int c=0;
    rep(i,N){
        if(p[i]!=i+1)c++;
    }

    cout << ((c==0 || c==2) ? "YES" : "NO") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;
using ll = long long;

int main(void)
{
    string s;
    cin >> s;
    
    int judge=0;
    for (int i = 0; i < s.size(); i++)
    {
        judge+=s.at(i)-'0';
    }
    if (judge%9==0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    
}


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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int N, K;

int main(){
	cin.tie(0);
  
  cin>>N>>K;
  
  cout<<(N%K?1:0)<<endl;
  
	return 0;
}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val M = java.util.HashSet<Int>()
    repeat(N) {
        val a = nextInt()
        if (M.contains(a)) M.remove(a)
        else M.add(a)
    }
    var ans = M.size
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


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

int main(void) {
  int A, B;
  cin >> A >> B;
  if (A <= 5)
    cout << 0 << endl;
  else if (A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pb push_back
int cnt[2005];
int main(int argc, char** argv) {
	int n,x,y;
	cin>>n>>x>>y;
	rep(i,1,n)
	{
		rep(j,1,i-1)
		{
			int p=min((i-j),min(abs(i-x)+abs(y-j)+1,abs(i-y)+abs(x-j)+1));
			cnt[p]++;
	//		cout<<i<<" "<<j<<" "<<p<<endl;
		}
	}
	rep(i,1,n-1)
	printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 256
N,K = gets.chomp.split(" ").map(&:to_i)
h = N.times.map{gets.to_i}
h.sort!
i = K-1
min = 10000000000
while i < N
  min = [h[i] - h[i-(K-1)],min].min
  i += 1
end
puts min

Measured memory_bytes: 16376
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,E,N,X[10];
    ll ans=0;
    string S;
    bool F=false;
int main(){
    cin>>A;
    cout<<(A%1000==0?0:1000-A%1000)<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}


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

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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, K;
    cin >> N >> K;

    int num = (N + 1) / 2;

    cout << (num >= K ? "YES" : "NO") << "\n";    

    return 0;
}

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

#define MAXN (1010)
#define sqr(x) ((1ll) * (x) * (x))

template <class T> void readin(T& x,bool mark=0){char tt=getchar();for(;tt<'0'||'9'<tt;tt=getchar()) if(tt=='-') mark=1;for(x=0;'0'<=tt&&tt<='9';x=(x<<1)+(x<<3)+tt-'0',tt=getchar());x=mark?-x:x;}

struct node{
	int x, y, r;
}cir[MAXN];

int n;
bool vis[MAXN];
double dis[MAXN];
double wjj[MAXN][MAXN];

double diss(int i, int j){
	return sqrt(sqr(cir[i].x - cir[j].x) + sqr(cir[i].y - cir[j].y));
}

double get_dis(int i, int j){
	return std::max(0.0, diss(i, j) - cir[i].r - cir[j].r);
}

std::priority_queue<std::pair<int, int> > pq;  
void dijkstra(){
    for(int i = 0; i < MAXN; ++ i){
	    dis[i] = 1e100;
	}
	dis[1] = 0;
	pq.push({- dis[1], 1});
	while(!pq.empty()){
		int u = pq.top().second; pq.pop();
		if(vis[u]) continue;
		vis[u] = true;
		for(int v = 1; v <= n + 2; ++ v){
			if(v == u) continue;
			double w = wjj[v][u];
			if(!vis[v] && dis[v] > dis[u] + w){
			    dis[v] = dis[u] + w;
				pq.push({- dis[v], v});
			}
		}
	}
}

int main(){
	readin(cir[1].x); readin(cir[1].y); readin(cir[2].x); readin(cir[2].y);
	readin(n);
	for(int i = 3; i <= n + 2; ++ i){
		readin(cir[i].x);
		readin(cir[i].y);
		readin(cir[i].r);
	}
	for(int i = 1; i <= n + 2; ++ i){
		for(int j = 1; j <= n + 2; ++ j){
			wjj[i][j] = get_dis(i, j);
		}
	}
	dijkstra();
	printf("%.10lf\n", dis[2]);
	return 0;
}

Measured memory_bytes: 10356
l, r = map(int, input().split())
x = []

if l <= 2019 <= r:
  print(0)
elif r - l > 2018:
  print(0)
else:
  x = []
  for i in range(l, r):
    for j in range(i+1, r+1):
      m = i * j % 2019
      x.append(m) 
  print(min(x))

Measured memory_bytes: 75428
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 0;

    for(int i = 0 ; i < 4 ; i++){
        if(s[i] == '+') ans++;
        else ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <tuple>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> d(n, -1);
    for (int i = 0; i < m; i++) {
        int s, m;
        cin >> s >> m;
        s--;
        if (d[s] == -1) d[s] = m;
        else if (d[s] != m) {
            cout << -1 << endl;
            return 0;
        }

        if (s == 0 && m == 0 && n != 1) {
            cout << -1 << endl;
            return 0;
        }

    }
    if (d[0] == -1) {
        if (n == 1) cout << 0;
        else cout << 1;
    }
    else cout << d[0];
    for (int i = 1; i < n; i++) {
        cout << (d[i] == -1 ? 0 : d[i]);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n, k, d;
	cin>>n>>k>>d;
	ll ans = n;
	n = abs(n);
		ll toZero = n/d;
		if(k<toZero){
			ans = n - k * d;
		}
		else{
			ans = n - toZero * d;
			n = ans;
			k = k-toZero;
			if(k%2){
				ans = abs(n-d);
			}
		}
	cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
  vector<mint> fact, ifact;
  combination(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];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
};
// comb(5, 2) → 10, comb.p(5, 2) → 20, comb.fact[4] → 24

int N;

mint power(int x) {
  // 2のx乗をmintで返す
  if (x == 0) return 1;
  mint res = power(x / 2);
  res *= res;
  if (x&1) res *= 2;
  return res;
}

mint choose(int x) {
  // nCxをmintで返す
  mint num = 1, den = 1;
  rep(i, x) {
    num *= (N-i);
    den *= (x-i);
  }
  return num / den;
}
int main() {
  int A, B;
  cin >> N >> A >> B;
  mint ans = power(N);
  ans -= (choose(A) + choose(B) + 1);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

  int h, n;
  int cnt=0;
  cin >> h >> n;
  int a;
  rep(i, n){
    cin >> a;
    cnt += a;
  }
  if(cnt>=h)
    cout<< "Yes" << endl;
    else{
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            using namespace std;
     
            int main() {
              int H, W, A, B;
              cin>> H >>W >>A >>B; 
              
              for(int i=1; i<=H; i++){
                for(int j=1; j<=W; j++){
                  if(i<=B){
                    if(j<=A){
                      cout<< 1 ;
                    }else{
                      if(j==W) cout << 0 <<endl;
                      if(j<W)  cout << 0 ;
                    }
                   // i<=Bのケース終わり
                  }else{
                    if(j<=A){
                      cout<< 0 ;
                    }else{
                      if(j==W) cout << 1 <<endl;
                      if(j<W)  cout << 1 ;
                    }
                  }// i>Bのケース終わり
                }// for j終わり
              }
     
            }

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

#define MAX 101
int N, ans;
bool seen[MAX];
vector<int> M[MAX];

void dfs(int u, int d){
    seen[u] = true;
    ans = max(ans, d);
    vector<int>::iterator it;
    for(it = M[u].begin(); it != M[u].end(); it++){
        if(seen[*it]) continue;
        else dfs(*it, d + 1);
    }
    seen[u] = false;
    return;
}



int main(){
    while(cin >> N){
        if(N == 0) return 0;
        ans = 0;
        for(int i = 1; i <= MAX; i++) M[i].clear();
        for(int i = 1; i <= N; i++){
            int u, v;
            cin >> u >> v;
            M[u].push_back(v);
            M[v].push_back(u);
        }
        for(int i = 1; i <= MAX; i++){
            for(int j = 1; j <= MAX; j++) seen[j] = false;
            dfs(i, 1);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

int main()
{
    double r;
    cin >> r;

    cout << fixed;
    cout << setprecision(6) << r * r * pi << ' ' << 2 * r * pi << endl;
}



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

typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	int n;
	n = s.size();
	int gcount = 0;
	int score = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'g') {
			if (gcount > 0) {
				gcount--;
				score++;
			}
			else {
				gcount++;
			}
			
		}
		else {
			if (gcount > 0) {
				gcount--;
				
			}
			else {
				gcount++;
				score--;
			}
		}
	}
	cout << score << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge {
	int to; // 行き先
	ll cap; // 容量
	int rev; // 逆辺
	edge() {}
	edge(int to, ll cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G; // グラフの隣接リスト表現
vector<int> used; // DFSですでに調べたらフラグ

				  // fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, ll cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

// 増加パスをDFSで探す
ll dfs(int v, int t, ll f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// sからtへの最大流を求める
ll max_flow(int s, int t) {
	ll flow = 0;
	for (;;) {
		fill(used.begin(), used.end(), 0);
		ll f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	G.resize(N + 2); used.resize(N + 2);

	ll Sum = 0;
	for (int i = 1; i <= N;i++) {
		ll a; cin >> a;
		for (int j = 2 * i; j <= N; j += i) add_edge(i, j, LINF);
		if (a > 0) {
			Sum += a;
			add_edge(i, N + 1, a);
		}
		else {
			add_edge(0, i, -a);
		}
	}
	cout << Sum - max_flow(0, N + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,x,i,m;
	int l[1000],d[1000];
	while(~scanf("%d%d",&n,&x))
	{
		m=0;
		for(i=1;i<=n;i++)
		scanf("%d",&l[i]);
		for(i=1;i<=n;i++)
		{
			d[0]=0;
			d[i]=d[i-1]+l[i];
		}
		for(i=0;i<=n;i++)
		{
			if(d[i]<=x)
			m++;
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main (){ 
	long long int N, sum = 1;
	scanf("%lld",&N);
	long long int A[N]; 



for(int i = 0; i < N; i++){
	scanf("%lld", &A[i]); }
	for(int i = 0; i < N; i++){

if(A[i] == 0){
	printf("0"); return 0; } 
} 
for(int i = 0; i < N; i++){
	if(A[i] <= 1000000000000000000 / sum){
	sum *= A[i]; } 
else 
{
	printf("-1"); return 0; } 
} 

printf("%lld", sum); 
return 0; }

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

int main(){
    int k;
    cin >> k;
    while(k--)cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3632