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

const int N = 5005;
const int mod = 1e9 + 7;

int n, dp[N][N], f[N], g[N << 1], siz[N];
int head[N], nxt[N << 1], ver[N << 1], cnt;

inline int inc(int u, int v) { u += v; if (u >= mod) u -= mod; return u;}
inline int dec(int u, int v) { u -= v; if (u < 0) u += mod; return u; }
inline int mul(int u, int v) { return 1ll * u * v % mod; }

inline void add(int u, int v)
{
	nxt[++cnt] = head[u];
	ver[cnt] = v;
	head[u] = cnt;
}

inline void solve(int x, int fa = -1)
{
	siz[x] = 1, dp[x][1] = 1;
	for (int i = head[x]; i; i = nxt[i])
	{
		int y = ver[i];
		if (y != fa)
		{
			solve(y, x);
			memset(g, 0, (siz[x] + siz[y] + 2) << 2);
			for (int i = 1; i <= siz[x]; ++i) for (int j = 0; j <= siz[y]; ++j) g[i + j] = inc(g[i + j], mul(dp[x][i], dp[y][j]));
			for (int i = 1; i <= siz[x] + siz[y]; ++i) dp[x][i] = g[i];
			siz[x] += siz[y];
		}
	}
	for (int i = 2; i <= siz[x]; i += 2) dp[x][0] = inc(dp[x][0], mul(dp[x][i], f[i]));
	if (dp[x][0]) dp[x][0] = dec(mod, dp[x][0]);
}

inline char nc()
{
	static char buf[1000000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}

inline int read()
{
	int res = 0; char ch; do ch = nc(); while (ch < 48 || ch > 57);
	do res = res * 10 + ch - 48, ch = nc(); while (ch >= 48 && ch <= 57);
	return res;
}

int main()
{
	n = read(), f[0] = 1;
	for (int i = 2; i <= n; ++i)
	{
		int u = read(), v = read();
		add(u, v), add(v, u);
		f[i] = mul(f[i - 2], i - 1);
	}
	solve(1);
	printf("%d", dec(mod, dp[1][0]));
	return 0;
}


Measured memory_bytes: 98048
using System;

namespace abc156_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(" ");
            long N = long.Parse(strArray[0]);
            long K = long.Parse(strArray[1]);
            long NNow = N;

            int sum = 0;
            while(NNow != 0)
            {
                NNow = NNow / K;
                sum++;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27408
#include <stdio.h>

int main()
{
    int a,b,tm,tm2;
    scanf("%d%d",&a,&b);
    if(a==b)
        printf("Draw\n");
    else if(b==1 && a>b)
        printf("Bob\n");
    else if(a>b)
        printf("Alice\n");
    else if(a==1 && b>a)
        printf("Alice\n");
    else
        printf("Bob\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
bool dp[1000120];
bool notPrime[1000120];
int main(){
    notPrime[0] = notPrime[1] = true;
    for(int i = 2;i*i < 1000010;i++){
        for(int j = 2 * i;j < 1000010;j+=i){
            notPrime[j] = true;
        }
    }
    int n,x;
    while(cin>>n>>x,n){
        dp[0] = true;
        while(n--){
            int a;
            cin>>a;
            for(int i = 0;i <= x;i++){
                if(dp[i]&&i+a <= 1000010)dp[i+a] = true;
            }
        }
        bool flg = false;
        for(int i = x;i >= 2;i--){
            if(!notPrime[i] & dp[i]){
                cout<<i<<endl;
                flg = true;
                break;
            }
        }
        if(!flg)cout<<"NA"<<endl;
        for(int i = 0;i < 1000020;i++)dp[i] = false;
    }
}

Measured memory_bytes: 3112
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    int n;
    cin>>n;
    vll a(n+1);
    ll sum=0;
    for(int i=0;i<n+1;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    vll b(n);
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        ll x=min(b[i],a[i]);
        a[i]-=x;
        b[i]-=x;
        ll y=min(b[i],a[i+1]);
        a[i+1]-=y;
        b[i]-=y;
    }
    for(int i=0;i<n+1;i++)
    {
        sum-=a[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    string s;
    cin>>s;
    ll i,j;
    ll ans=0;
    for(i=0;i<s.length();)
    {
    	if(s[i]=='S') 
    	{
    		i++;
    		continue;
    	}
    	j = i;
    	ll cn=0;
    	while(s[j]=='R' and j<s.length())
    	{
    		j++;
    		cn++;
    	}
    	i = j;
    	ans = max(ans,cn);
    }
    cout<<ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main(){
    
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    for (int i=0; i<n; i++){
        cin >> a.at(i);

        if (a.at(i) == 0LL){
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i=0; i<n; i++){
        ll ans_buf;
        ans_buf = ans;
        ans = ans_buf*(a.at(i));

        if (ans > INF){
            cout << -1 << endl;
            return 0;
        }
        if (ans < ans_buf){
            cout << -1 << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 4044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int A,B; cin >> A >> B;
    string U; cin >> U;

    if (S==U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
void setIO(string name) {
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
vector<int> adj[200005];
int visited[200005]={0};
int ender=-1;

vector<int> c;
void dfs(int node){
  visited[node]=1;
   c.pb(node);
  for(int next:adj[node]){
    if(!visited[next]){
      dfs(next);
    }else{
      ender=next;
    }
  }
 
}

int main() {
   fast();
   int n;
   cin>>n;
   long long k;
   cin>>k;
   for(int i=0;i<n;i++){
    int l;
    cin>>l;
    --l;
    adj[i].pb(l);
   }
   dfs(0);
  
   if(ender!=-1){
     int x;
      for(int i=0;i<c.size();i++){
        if(c[i]==ender){
           x=i;
           break;
        }
      }
     if(k<=x){
       cout<<c[k]+1<<"\n";
       return 0;
     }else{
      long long y=c.size()-x;
      k-=x;
      k%=y;
      cout<<c[k+x]+1<<"\n";
      return 0;
     }
      
   }

   

   

   
   



   
}
 

Measured memory_bytes: 24804
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;

	int N, M, K;

	cin >> N;
	vector<int>T;
	vector<int>m;
	ll ans = 0;
	rep(i, 0, N) {
		cin >> j;
		ans += j;
		T.push_back(j);
	}
	cin >> M;
	rep(i, 0, M) {
		cin >> j >> k;
		m.push_back(T[j-1] - k);
	}
	rep(i, 0, M) {
		cout << ans - m[i] << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 


long long int N,Ma,M,a[100],b[100],c[100],res=0;
long long int cost[405][405]={};
string S;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    if(N*M<=0){cout<<"Zero"<<endl;}
    else if(N>=1){cout<<"Positive"<<endl;}
    else if((M-N)%2==1){cout<<"Positive"<<endl;}
    else{cout<<"Negative"<<endl;}
}    


Measured memory_bytes: 256
k = int(input())

lun_list = [1,2,3,4,5,6,7,8,9]

for i in lun_list:
    if str(i)[-1] == '0':
        for j in range(2):
            lun_list.append(int(str(i)+str(j)))
    elif str(i)[-1] == '9':
        for j in range(8,10):
            lun_list.append(int(str(i)+str(j)))
    else:
        for j in range(int(str(i)[-1])-1,int(str(i)[-1])+2):
            lun_list.append(int(str(i)+str(j)))
    if len(lun_list) > k:
        break

print(lun_list[k-1])

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  ll D0 = A-B;
  if(abs(D0) > 1000000000000000000){
    cout << "Unfair" << endl;
  }
  else{
    if(K%2) cout << -D0 << endl;
    else cout << D0 << endl;
  }
}

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

int main() {
    int A, B, C, D, T, aoki;
    cin >> A >> B >> C >> D;

    T = A / D;
    if (A % D != 0) T++;
    aoki = C / B;
    if (C % B != 0) aoki++;
    if (T >= aoki) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	int x, y;
	cin >> x >> y;
	int flag = 0;
	if(x == 2)
	{
		if(y == 2)flag = 1;
	}
	else if(x == 4 || x == 6 || x == 9 || x == 11)
	{
		if(y == 4 || y == 6 || y == 9 || y == 11)flag = 1;
	}
	else
	{
		if(y == 1 || y == 3 || y == 5 || y == 7 || y== 8 || y == 10 || y == 12)flag = 1;
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c >> n;
	if (a > b) {
		ans += b;
	}
	else {
		ans += a;
	}
	if (c > n) {
		ans += n;
	}
	else {
		ans += c;
	}
	cout << ans;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


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

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

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s.back() == '1') {
        cout << -1 << endl;
        ret();
    }
    if (s.front() == '0') {
        cout << -1 << endl;
        ret();
    }

    rep(i, n - 1) {
        if (s[i] != s[n - i - 2]) {
            cout << -1 << endl;
            ret();
        }
    }

    int last = 0;
    vector<P> ans;
    rep(i, n - 1) {
        if (s[i] == '1') {
            ans.push_back({last, i + 1});
            last = i + 1;
        } else {
            ans.push_back({last, i + 1});
        }
    }

    for (P p : ans) printf("%lld %lld\n", p.first + 1, p.second + 1);


}

Measured memory_bytes: 5492
/***
 *          _           _       _ _                             _                 
 *      ___| |__   ___ | | ___ (_) |__  _   _  __ _ _ __   ___ | |__   ___   __ _ 
 *     / __| '_ \ / _ \| |/ _ \| | '_ \| | | |/ _` | '_ \ / _ \| '_ \ / _ \ / _` |
 *    | (__| | | | (_) | | (_) | | | | | |_| | (_| | | | | (_) | | | | (_) | (_| |
 *     \___|_| |_|\___/|_|\___/|_|_| |_|\__,_|\__,_|_| |_|\___/|_| |_|\___/ \__,_|
 *                                                                                
 *                _       ____            _____     _                             
 *      /\/\     /_\     /___ \  /\ /\    \_   \   /_\                            
 *     /    \   //_\\   //  / / / / \ \    / /\/  //_\\                           
 *    / /\/\ \ /  _  \ / \_/ /  \ \_/ / /\/ /_   /  _  \                          
 *    \/    \/ \_/ \_/ \___,_\   \___/  \____/   \_/ \_/                          
 *                                                                                
 */
#include<bits/stdc++.h>
using namespace std;
int  main(){
long long s;
cin>>s;
long long p=1e9;
   long long m=s/p;
   if(s%p==0){
   	cout<<"0 0   1000000000  0 0 "<<m;
   }
   else {
   	m++;
   	cout<<"0 1 1000000000 0  "<<s%p<<" "<<m;
   }
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int guess(int idx) {
	cout << idx << endl;	
	string s;
	cin >> s;
	if (s == "Vacant") {
		exit(0);
		return -1;
	}
	if (s == "Male") {
		return 0;
	}
	if (s == "Female") {
		return 1;
	}
}

int n;

bool good(pii x, pii y) {
	int dst = (y.fs - x.fs + n) % n;
	return (dst & 1) ^ (x.sc == y.sc);
}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
//	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	int last = guess(n - 1);
	int l = 0, r = n - 2;
	pii left = mp(n - 1, last), right = mp(n - 1, last);
	while (l < r) {
		int m = (l + r) >> 1;	
		int k = guess(m);
		if (good(left, mp(m, k))) {
		 	left = mp(m, k);
		 	l = (m + 1) % n;
		} else {
			right = mp(m, k);
			r = (m - 1 + n) % n;
		}
	}
	guess(l);

	return 0;
}

Measured memory_bytes: 852
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

int main()
{
	ll a,b,c,d;
	scanf("%lld%lld",&a,&b);
	a%=b;
	d=fabs(a-b);
	c=min(a,d);
	printf("%lld\n",c);
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int n, max = 0, total = 0;
  int price[11];
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
  {
    scanf("%d", &price[i]);
    if (max <= price[i])
    {
      max = price[i];
    };
    total += price[i];
  }
  printf("%d\n", total - max / 2);
  return 0;
}

Measured memory_bytes: 128
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = (a..b + 1)
        .filter(|i| {
            let s: String = format!("{}", i);
            let t: String = s.chars().rev().collect();
            s == t
        })
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
const int N = 2e5 + 5;

LL pre[N], tab[N];

int bit[N];

inline void add(int x) {
  for (; x < N; x += x & (- x)) bit[x] ++;
}

inline int sum(int x) {
  int ret = 0;
  for (; x > 0; x -= x & (- x)) ret += bit[x];
  return ret;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i ++) {
    scanf("%lld", &pre[i]);
    pre[i] -= k;
    pre[i] += pre[i - 1];
    tab[i] = pre[i];
  }
  sort(tab, tab + n + 1);
  LL ans = 0;
  for (int i = 0, p; i <= n; i ++) {
    p = lower_bound(tab, tab + n + 1, pre[i]) - tab + 1;
    ans += sum(p);
    add(p);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4096
/**
 * @Author:      H S-J
 * @DateTime:    2018-01-07 20:01:27
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
LL n, y;
const int aa = 10000, bb = 5000, cc = 1000;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> y;
    int ta = y/aa, tb = y/bb, tc = y/cc;
    bool flag = 1;
    rep(i, 0, ta+1) rep(j, 0, tb+1) {
        if((i*aa + j*bb + (n-i-j)*cc) == y && ((i+j) <= n)) {
            cout << i << " " << j << " " << (n-i-j) << endl;
            flag = 0;
            goto nest;
        }
    }
    nest:
    if(flag) cout << "-1 -1 -1" << endl;
	return 0;
}

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007

void solve1(){
	int n;
	cin >> n;
	int tmp;
	int cnt = 0;
	for(int i=2; i<=n; i++){
		tmp = n;
		while(tmp >= i){
			if(tmp % i == 0) tmp/=i;
			else tmp -= i;
		}
		if(tmp == 1){
			//cout << i << endl;
			cnt++;
		}
	}
	cout << cnt << endl;
}

void solve(){
	ll n; cin >> n;
	ll cnt = 0;
	ll tmp;
	for(ll i=2; i*i<=n; i++){
		tmp = n;
		if(tmp % i == 0){
			while(tmp%i == 0){
				tmp/=i;
			}
			if(tmp % i == 1){
				//cout << i << endl;
				cnt++;
			}
		}
	}
	for(ll i=2; i*i <= n-1; i++){
		if(i * i == n-1){
			cnt+=1;
		}
		else if((n-1) % i == 0){
			cnt += 2;
			//cout << i << " " << (n-1)/i << endl;
		}
	}
	if(n > 2)cout << cnt+2 << endl;
	else cout << cnt + 1 << endl;
}

int main(){
	FAST_IO;
	int t=1; //cin >> t;
	while(t--){
		solve();
		//solve1();
	}
}			


Measured memory_bytes: 256
let main = (standardInput) => {
    let lengthList = standardInput.split(' ');
    let x = Number.parseInt(lengthList[0]);
    let y = Number.parseInt(lengthList[1]);

    var euclidGcm = function(x,y){
        /* 前提としてx > yなので != の場合は入れ替えておいてあげる */

        if (y > x) {
            z = x;
            x = y;
            y = z;
        }
        gcm = 1;
        
        for (i=2; i<=x; i++) {
            while(x%i===0 && y%i===0) {
                x /= i;
                y /= i;

                // 今回の除数を乗算
                gcm *= i;
                var ex = 1;
                ex += "*" + i;
            }
        }
        return gcm;
    };
    console.log(euclidGcm(x, y));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15540
package main

import "fmt"

func main() {
        var s string
        fmt.Scanf("%s", &s)

        var count int

        for step := 0; step < len(s)/2; step++ {
                if s[step] != s[len(s)-1-step] {
                        count++
                }
        }

        fmt.Println(count)
}

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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,x,st=0;
    ll i;
    vi v;

    cin>>n; i=n;
    while (i--) {
        cin>>x;
        v.pb(x);
    }

    sort(all(v));

    ll min=LLONG_MAX;
    for (int i=1; i<=100; ++i) {
        st=0;
        for (auto &a:v)
            st += (i-a)*(i-a);
        if (st<min)
            min=st;
    }
    
/*
    int m1=accu/2;
    int m2=(ceil(accu/2.0));

    if (m1==m2) {
        for (auto &a:v) {
            st += (m1-a)*(m1-a);
        }
    }
    else {
        int t1=0, t2=0;
        for (auto &a:v) {
            t1 += (m1-a)*(m1-a);
        }
        for (auto &a:v) {
            t2 += (m2-a)*(m2-a);
        }
        st = min(t1,t2);
    }
*/
    cout<<min<<endl;
}



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

int main(void) {
	int r;
	int c;
	int num[101][101];
	int hsum[101] = {};
	int vsum[101] = {};
	int finish = 0;

	cin >> r >> c;

	for (int i = 1; i <= r; i++) {
		for (int t = 1; t <= c; t++) {
			cin >> num[i][t];
		}
	}

	for (int i = 1; i <= r; i++) {
		for (int t = 1; t <= c; t++) {
			hsum[i] += num[i][t];
		}
	}

	for (int i = 1; i <= c; i++) {
		for (int t = 1; t <= r; t++) {
			vsum[i] += num[t][i];
		}
	}

	for (int i = 1; i <= c; i++) {
		finish += vsum[i];
	}

	for (int i = 1; i <= r; i++) {
		for (int t = 1; t <= c; t++) {
			cout << num[i][t] << " ";
			if (t == c) {
				cout << hsum[i] << "\n";
			}
		}
	}
	for (int t = 1; t <= c; t++) {
		cout << vsum[t] << " ";
	}
	cout << finish << "\n";
	return 0;
}

Measured memory_bytes: 3136
use std::io;
use std::cmp;
use std::collections::VecDeque;
 
fn main() {
    let mut input = Input::new();
    let n = input.next_i64();
    let a = input.next_i64();
    let b = input.next_i64();
    let x = (a + b * (n - 1)) - (a * (n - 1) + b) + 1;
    println!("{}", cmp::max(0, x));
}
 
struct Input {
    queue: VecDeque<String>,
}
 
impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }
 
    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
 
    fn next_i64(&mut self) -> i64 {
        return self.next().parse::<i64>().unwrap();
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define debug cout<<"debug\n";
using namespace std;
int a[40][40];
int main(){
	int k=38;
	int n=k*(k-1)+1;
	//cin>>n>>k;
	cout<<n<<" "<<k<<endl;
	int cnt=2;
	for(int i=0;i<k;i++){
		cout<<"1";
		for(int j=0;j<k-1;j++) {
			a[i][j]=cnt++;
			cout<<" "<<a[i][j];
		}
		cout<<"\n";
	}
	for(int i=2;i<=k;i++){
		for(int p=0;p<k-1;p++){
			cout<<i;
			for(int j=0;j<k-1;j++){
				cout<<" "<<a[j+1][(j+p+(i-2)*j)%(k-1)];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,h,b[111111];
int maxa;
int calc(int x,int y){
	if(x<=0)return 0;
	return x/y+(x%y?1:0);
}
int main(){
	scanf("%d%d",&n,&h);
	maxa = 0;
	for(int i=0; i<n; i++){
		int x;
		scanf("%d%d",&x,&b[i]);
		maxa = max(maxa, x);
	}
	sort(b,b+n);
	int res = 0;
	for(int i=n-1; i>=0; i--)
		if(b[i] >= maxa && h > 0){
			h -= b[i];
			res ++;
		}else
			break;
	res += calc(h, maxa);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int num=n,all=0,t;
  while(num) {
    t = num%10;
    all += t;
    num /= 10;
  }
  if(n%all == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3668
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

const [a, b, c] = input[0].split(' ').map((x:string): number => +x);

if(a+b+c >= 22){
	console.log('bust');
}else{
	console.log('win')
}



Measured memory_bytes: 7372
<?php

$count = readline();

$numbers = readline();

$numbers = explode(" ", $numbers);

$slots = array();

foreach ($numbers as $number)
{
    //handle bad cases
    if ($count % 2 == 0)
    {
        //even
        if ($number % 2 == 0)
        {
            echo "0\n";
            die();
        }
    } else
    {
        //even
        if ($number % 2 == 1)
        {
            echo "0\n";
            die();
        }
    }

    $slots[$number] ++;
}



foreach ($slots as $i => $slot)
{
    if ($i != 0)
    {
        if ($slot != 2)
        {

            echo "0\n";
            die();
        }
    }
}

$result = 1;

for ($i = 1; $i <= floor($count /2); $i++)
{
    $result = ($result * 2 ) % (pow(10,9) + 7);
}

//$result = pow(2, floor($count / 2)) % (pow(10,9) + 7);

echo $result . "\n";




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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v){
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v){
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args){
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args){
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)){
    return next<T>(cin, args...);
}

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

    times(3, i) {
        int s = next<int>() * 60 * 60 + next<int>() * 60 + next<int>(),
            e = next<int>() * 60 * 60 + next<int>() * 60 + next<int>(),
            t = e - s;
        cout << t / 60 / 60 << ' ' << t / 60 % 60 << ' ' << t % 60 ln;
    }

    return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {

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

		//標準入力取得
		int num = sc.nextInt();
		String row = sc.next();

		int numSlime = 0;
		char preSlime = 'X';
		for (int i = 0; i < num; i++) {
			if (preSlime != row.charAt(i)) {
				preSlime = row.charAt(i);
				numSlime++;
			}
		}
		System.out.println(numSlime);

		sc.close();

	}

}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C)
{
    bool kawaisoo = (A == B && A != C) || (B == C && B != A) || (C == A && C != B);
    cout << (kawaisoo ? YES : NO) << endl;
}

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


Measured memory_bytes: 256
H,W,K=map(int,input().split())
s=[]
for i in range(H):
    S=input()
    s.append(S)
a=[[0 for i in range(W)] for j in range(H)]
tmp=-1
flag=False
chk=[0 for _ in range(W)]
for w in range(W):
    count=0
    for h in range(H):
        if not flag:
            if s[h][w]=="#":
                tmp=w
                flag=True
        if s[h][w]==".":
            count+=1
    if count==H:
        chk[w]=1
num=0
flag=True
f=True
for w in range(W):
    if w<tmp:
        continue
    if chk[w]==0:
        num+=1
    f=True
    for h in range(H):
        if chk[w]==0:
            if s[h][w]=="#":
                if flag:
                    num=1
                    flag=False
                if f:
                    pass
                    f=False
                else:
                    num+=1
                a[h][w]=num
            else:
                a[h][w]=num
        else:
            a[h][w]=a[h][w-1]
if tmp!=0:
    for w in range(tmp):
        for h in range(H):
            if (tmp-1-w)<0:
                break
            a[h][tmp-1-w]=a[h][tmp-w]
for i in range(H):
    print(*a[i])

Measured memory_bytes: 47068
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;
constexpr ll MAX = 2000;

std::string S;

int main()
{
    cin >> S;
    if (S[S.size() - 1] == 's')
    {
        cout << S + "es" << endl;
    }
    else
    {
        cout << S + "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void){

  int a , b;
  scanf("%d %d", &a , &b);
  int sa = b - a;
  int sum = 0;

  for(int i = 1 ; i <= sa ; i++){
    sum += i;
  }

  printf("%d", sum - b);
  
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            int cardNum = int.Parse(Console.ReadLine());
            int point1 = 0;
            int point2 = 0;

            for (int i = 0; i < cardNum; ++i)
            {
                string[] temp = Console.ReadLine().Split(' ');

                int result = String.Compare(temp[0], temp[1]);

                if (result < 0)
                {
                    point2+=3;
                }
                else if (result > 0)
                {
                    point1 += 3;

                }
                else 
                {
                    ++point1;
                    ++point2;
                }
            }    
            Console.WriteLine(point1 + " " + point2);
        }
    }
}



Measured memory_bytes: 16764
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(),x.end())
#include<math.h>
using namespace std;

int main()
{
    int n,a[100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    double sum=(a[0]+a[1])/2.0;
    for(int i=2;i<n;i++)
    {
        sum=(sum+a[i])/2.0;
    }
    printf("%.10lf\n",sum);
    return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
vector<vector<int>>field;
int N = 170;
void print_field() {
	if (DBG) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				cout << field[i][j] << (j == N - 1 ? '\n' : ' ');
			}
		}
	}
}
int solve(int x, int y, vector<vector<int>> &field) {
	queue<pair<int, int>>Q;
	Q.push(make_pair(x, y));
	int ans(1);
	vector<int> dx{ 1,1,0,-1,-1,0 }, dy{ 0, 1, 1, 0, -1, -1 };
	while (!Q.empty()) {
		auto a = Q.front(); Q.pop();
		if (field[a.first][a.second] == 1)continue;

		rep(i, 0, dx.size()) {
			int ax = a.first + dx[i], ay = a.second + dy[i];
			if (0 <= ax&&ax < N && 0 <= ay&&ay < N&&field[ax][ay] == -1) {
				field[ax][ay] = max(0, field[a.first][a.second] - 1);
				Q.push(make_pair(ax, ay));
				ans++;
			}
		}
	}

	return ans;
}
signed main() {
	int t, n;
	while (cin >> t >> n, t || n) {
		field = vector<vector<int>>(N, vector<int>(N, -1));

		rep(i, 0, n) {
			int x, y;
			cin >> x >> y;
			x += N / 2; y += N / 2;
			field[x][y] = INF;
		}

		int sx, sy; cin >> sx >> sy;
		sx += N / 2; sy += N / 2;
		field[sx][sy] = t + 1;

		cout << solve(sx, sy, field) << endl;


	}
	return 0;
}

Measured memory_bytes: 3192
#include <cstdio>
int main() {
	int a,b,c;
	std::scanf("%d%d%d", &a,&b,&c);
	int s = c - a + b;
	if (s > 0) {
		std::printf("%d\n", s);
	}
	else {
		std::printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

priority_queue<int, vector<int>, greater<int>> que;
int N, M;

int main()
{
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        que.push(A[i]);
    }
    vector<pair<int, int>> S;
    for (int i = 0; i < M; i++)
    {
        int b, c;
        cin >> b >> c;
        S.emplace_back(c, b);
    }
    sort(S.rbegin(), S.rend());
    for (int i = 0; i < M && S[i].first > que.top(); i++)
    {
        for (int j = 0; j < S[i].second; j++)
        {
            int a = que.top();
            if (a < S[i].first)
            {
                a = S[i].first;
                que.pop();
                que.push(a);
            }
            else
                break;
        }
    }

    ll ans = 0;
    while (!que.empty())
    {
        int a = que.top();
        que.pop();
        ans += a;
        //cout << a << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
var
	N,i:Longint;
	p,A,T:int64;
begin
	read(N,p);
	T:=1000;
	for i:=2 to N do begin
		read(A);
		if p<A then begin
			T:=T mod p+T div p*A;
		end;
		p:=A;
	end;
	writeln(T);
end.

Measured memory_bytes: 1376
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    append = peaks.append
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            append(upPeak)
            append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = [int(raw_input().strip()) for _ in xrange(N)]

orderN(N,L,ices)

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

int main() {
  int N;
  cin >> N;
  
  int a = 0, b = 0, ab = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S[0] == 'B') {
      if (S[S.size()-1] == 'A') {
        ab++;
      } else {
        b++;
      }
    }
    if (S[S.size()-1] == 'A' && S[0] != 'B') {
      a++;
    }
    
    for (int j = 0; j < S.size()-1; j++) {
      if (S[j] == 'A' && S[j+1] == 'B') ans++;
    }
    
  }
  
  if (ab == 0) {
    ans += min(a, b);
  } else {
    if (a + b > 0) {
      ans += ab + min(a, b);
    } else {
      ans += ab - 1;
    }
  }
  
  cout << ans << endl;
                 
  
}

Measured memory_bytes: 3548
import sys
s = input()
t = input()
v = {}
for i, c in enumerate(s):
  if s[i] not in v:
    v[s[i]] = t[i]
  elif v[s[i]] != t[i]:
    print('No')
    sys.exit()
  else:
    v[s[i]] = t[i]
st = set()
for x in v.values():
  if x in st:
    print('No')
    sys.exit()
  else:
    st.add(x)
print('Yes')


Measured memory_bytes: 3632
// AOJ DSL 2 B Range Sum Query
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long long
#define ADD 0

ll N, Q, X, Y, Z;
int COM;
vector<ll> A, B;

void input() {
  cin >> N >> Q;
}

void init() {
  // Nを2の累乗に補正
  ll n = 1;
  while (n < N) n *= 2;
  N = n;
  A = vector<ll>(N*2-1, 0);
  B = vector<ll>(N*2-1, 0);
}


void addRec(ll a, ll b, ll val, ll n, ll l, ll r) {
  // a l r b
  if (a <= l && r <= b) {
    A.at(n) += val;
    return;
  }

  // l  a  r    b
  if (l < b && a < r) {
    B.at(n) += (min(b, r) - max(a, l)) * val;
    addRec(a, b, val, n*2+1, l, (l+r)/2);
    addRec(a, b, val, n*2+2, (l+r)/2, r);
  }
}

void add(ll a, ll b, ll val) {
  addRec(a, b, val, 0, 0, N);
}

ll findRec(ll x, ll y, ll n, ll l, ll r) {
  // i)        l      r    x   y
  // i)  x   y l      r
  if (r <= x || y <= l) return 0;
  // iii)  x    l     r    y
  if (x <= l && r <= y) {
    return A.at(n) * (r - l) + B.at(n);
  }
  // iv)   x    l    y   r
  ll res = (min(y, r) - max(x, l)) * A.at(n);
  res += findRec(x, y, n*2+1, l, (l+r)/2);
  res += findRec(x, y, n*2+2, (l+r)/2, r);
  return res;
}

ll find(ll x, ll y) {
  return findRec(x, y, 0, 0, N);
}

void dumpRec(ll n, int depth) {
  if (n >= A.size()) return;
  for (int i=0;i<depth;i++) cout << "\t";
  cout << "(" << n << ", " << A.at(n) << ", " << B.at(n) << ")" << endl;
  dumpRec(n*2+1, depth+1);
  dumpRec(n*2+2, depth+1);
}

void dump() {
  cout << "====== dump =======" << endl;
  dumpRec(0, 0);
}

void solve() {
  init();

  for (ll q=0; q<Q; q++) {
    cin >> COM >> X >> Y;
    X--;
    if (COM == ADD) {
      cin >> Z;
      add(X, Y, Z);
    }
    else cout << find(X, Y) << endl;
  }
}

int main() {
  input(); solve();
  return 0;
}




Measured memory_bytes: 7068