akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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


int main() {
  string S;
  cin >> S;
  
  int lose = 0;
  rep(i, S.size()) {
    if(S[i]=='x') lose ++;
  }
  
  if(lose>7) cout << "NO" << endl;
  else cout << "YES" <<  endl;
  
  return 0;
}

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

ll n;

bool check(ll d) {
    ll tmp = n;
    while (tmp % d == 0) tmp /= d;
    return tmp % d == 1;
}

int main() {
    cin >> n;
    ll cnt = 0;

    for (ll d = 1; d * d <= n; d++) {
        if (n % d != 0ll) {
            continue;
        }
        if (d != 1) {
            cnt += check(d);
        }
        if (n / d > d) {
            cnt += check(n / d);
        }
    }
    n--;
    for (ll d = 1; d * d <= n; d++) {
        if (n % d != 0ll) {
            continue;
        }
        if (d != 1) {
            cnt++;
        }
        if (n / d > d) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int r;
  scanf("%d", &r);
  printf("%d\n", (int)pow(r, 2));
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec s(n);
  vec t(m);
  for(ll i=0;i<n;i++) {
    cin >> s[i];
  }
  for(ll i=0;i<m;i++) {
    cin >> t[i];
  }
  mat dp(n+1,vec(m+1));
  mat sum(n+1,vec(m+1));
  sum[0][0]=0;
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<m;j++) {
      if(s[i]==t[j]) {
        dp[i+1][j+1]=(sum[i][j]+1)%mod;
      }
      sum[i+1][j+1]=(sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]+mod)%mod;
    }
  }
  cout << (sum[n][m]+1)%mod << endl;
}

Measured memory_bytes: 62976
#include<stdio.h>

int main()
{
 int r,g,b;
 int n;
 int flag;

 scanf("%d %d %d",&r,&g,&b);

 n=100*r+10*g+b;

 if(n%4==0){
  printf("YES\n");
 }
else{
  printf("NO\n");
 }

return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v) {  \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

struct info {
  int x, y, h;
  info() { x = 1, y = 1, h = 1; }
  info(int _x, int _y, int _h) { x = _x, y = _y, h = _h; }
};
// h(x,y ) = max(0,h + |cx - x| + |cy - y|
int main() {
  int n;
  cin >> n;
  vector<info> v(n);
  rep(i, n) { cin >> v[i].x >> v[i].y >> v[i].h; }

  info base = info(1, 1, 1);
  for (auto info : v) {
    if (info.h != 0) {
      base = info;
      break;
    }
  }
  for (int px = 0; px <= 100; px++) {
    for (int py = 0; py <= 100; py++) {
      // 中心座標を(px,py)とした時，vの情報と矛盾しないか確かめる
      bool ok = true;
      int H   = base.h + max((abs(px - base.x) + abs(py - base.y)), 0);
      // cout << px << " " << py << " " << H << endl;
      for (int i = 0; i < v.size(); i++) {
        info a = v[i];
        if (a.h == max(0, H - abs(px - a.x) - abs(py - a.y))) {
          continue;
        } else {
          ok = false;
          break;
        }
      }
      if (ok) {
        cout << px << " " << py << " " << H << endl;
      } else {
        continue;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    arr = input().split(' ')
    max = int(arr[0])
    min = int(arr[0])
    for i in range(1, n):
        if int(arr[i]) > max:
            max = int(arr[i])
        if int(arr[i]) < min:
            min = int(arr[i])
    print(max - min)
main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int A, B;
  cin >> A >> B;
  
  if(A > 12){
    cout << B << endl;
  }else if(A < 6){
    cout << "0" << endl;
  }else{
    cout << B / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#define int long long

using namespace std;

const int maxn = 200;

bool g[maxn][maxn];
int d[maxn][maxn];
uint8_t used[maxn], usd[maxn];
int n;
bool flg = 1;

void dfs(int x) {
    for (int i = 0; i < n; i++) {
        if (!g[x][i]) continue;
        if (used[i] == 0) {used[i] = used[x] ^ 1; dfs(i);}
        else if (used[i] == used[x]) flg = 0;
    }
}

vector<vector<int> > cmt;
int cc = 0;

void fcm(int x) {
    usd[x] = 1;
    cmt[cc].push_back(x);
    for (int i = 0; i < n; i++)
        if (g[x][i] && !usd[i])
            fcm(i);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            char c; cin >> c;
            g[i][j] = (c == '1');
        }
    used[0] = 1; dfs(0);
    if (!flg) {cout << -1; return 0;}
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            d[i][j] = (g[i][j] ? 1 : 1148822869);
        }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int l = 0; l < n; l++)
                d[j][l] = min(d[j][l], d[j][i] + d[i][l]);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (usd[i]) continue;
        cmt.push_back(vector<int>());
        fcm(i);
        int mx = 0;
        for (int j = 0; j < cmt[cc].size(); j++)
            for (int l = 0; l < cmt[cc].size(); l++)
                mx = max(mx, d[cmt[cc][j]][cmt[cc][l]]);
        ans += mx + 1;
        ++cc;
    }
    cout << ans;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    ll ans=1;
  bool ng = false;
    rep(i,n){
        ll a; cin>>a;
        if(a==0){
            cout << 0 << endl;
          return 0;
        }
        if(ans>1000000000000000000/a){
            ans=-1;
          ng=1;
        }
        ans*=a;
    }
  if(ng)ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3552
using System;
using System.Linq;

// 割り算

public class ITP1_4_A
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = input[0];
        int b = input[1];

        Console.WriteLine($"{a / b} {a % b} {(double)a / b:F5}");
    }
}



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

int main(){
    int a,b,c,n;
    cin>>a>>b>>c>>n;
    int count =0;
    int flag=1;
    while(b<=a){
        b = b*2;
        count++;
        if(count>n){flag=0;break;}
    }
    if(count>n || flag==0){cout<<"No";return 0;}
    while(c<=b){
        c = c*2;
        count++;
        if(count>n){flag=0;break;}
    }
    if(count>n || flag==0){cout<<"No";return 0;}
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string w,c,r;int q,a,b,i;cin >> w >> q;
    for(i=0;i<q;i++){
        cin >> c >> a >> b;
        if(c == "print") cout << w.substr(a,b-a+1) << endl;
        else if (c == "reverse") reverse(w.begin()+a,w.begin()+b+1);
        else{
            cin >> r;
            w.replace(a,b-a+1,r);
        }
    }
    
}


Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    string s;
    cin>>s;
    int n=s.size()-1;
    if(s[n]=='s'){
        s+="es";
    }
    else{
        s+='s';
    }
    cout<<s<<endl;


    return 0;
}



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

struct Problem {
public:

	void Solve() {
		while (true) {
			UL N; scanf("%d", &N);
			if (N == 0) break;
			int x1, x2, y1, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			int X, Y; scanf("%d%d", &X, &Y);
			int ans = 0;
			rep(i, N) {
				int x, y; scanf("%d%d", &x, &y);
				int a, b, c;
				a = max(x1 - x, max(x - x2, 0)) + max(y1 - y, max(y - y2, 0));
				b = max(x1 - X, max(X - x2, 0)) + max(y1 - Y, max(Y - y2, 0));
				b = max(b - 1, 0);
				c = abs(X - x) + abs(Y - y);
				ans += min(a + b, c);
				X = x; Y = y;
			}
			printf("%d\n", ans);
		}
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
struct UnionFind {
  /*
  UnionFind uf(x)で初期化
  root(x) xの根を返す
  unite(x,y) xとyを同一の根にする
  same(x,y) xとyの根が同一ならtrue
  size(x)　集合の大きさを返す*/
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {  // xの根を返す
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);  // xとyを連結する
    y = root(y);
    if (x == y) return 0;
    if ((d[x] > d[y])) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<vector<int>> Fre(N), Blo(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    Fre[a].push_back(b);
    Fre[b].push_back(a);
    uf.unite(a, b);
  }
  unordered_map<int, int> uo;
  REP(i, N) { uo[uf.root(i)]++; }
  vector<int> Ans(N);
  REP(i, N) { Ans[i] = uo[uf.root(i)]; }
  REP(i, K) {
    int a, b;
    cin >> a >> b, a--, b--;
    if (uf.root(a) == uf.root(b)) {
      Ans[a]--, Ans[b]--;
    }
  }
  REP(i, N) {
    cout << Ans[i] - 1 - Fre[i].size() <<" ";
    if (i != N - 1) cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 13824
import numpy as np

N = int(input())
A = np.zeros(N).astype(int)
B = np.zeros(N).astype(int)

for i in range(N):
    A[i], B[i] = map(int, input().split())

ans = 0
for i in reversed(range(N)):
    A[i] = A[i] + ans
    if A[i] % B[i] == 0:
        continue
    elif B[i] - A[i] > 0:
        ans += B[i] - A[i]
    else:
        ans += B[i] - (A[i] % B[i])
    
print(ans)

Measured memory_bytes: 14072
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

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

    vector<int> V(N, 0);
    for (int i = 0; i < N;++i){
        int z;
        cin >> z;
        z--;
        V[i] = z;
    }

    int now = 0;
    int c = 0;
    while(true){
        if(now==1){
            cout << c << endl;
            break;
        }else if( c>=N){
            cout << -1 << endl;
            break;
        }
        c++;
        now = V[now];
    }

    return 0;
}

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

using namespace std;

template <typename T> bool is_prime(T n) {
  if (n == 0 || n == 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (T i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> prime;
  for (int i = 0; i <= 55555; i++) {
    if (is_prime(i) && i % 5 == 1) prime.emplace_back(i);
  }
  for (int i = 0; i < N; i++) {
    cout << prime[i] << (i != N - 1 ? ' ' : '\n');
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

bool isStable (char C[], int A[], int N, char c[], int a[]) {

    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int x = 0; x < N - 1; x++) {
                for (int y = x + 1; y < N; y++) {
                    if (A[i] == A[j] && A[i] == a[x] && A[i] == a[y] && c[x] == C[j] && c[y] == C[i]) {
                        // cout << "i, j, x, y: " << i << j << x << y << endl;
                        // cout << A[i] << " == " << A[j] << " && " << c[x] << " == " << C[j] << " && " << c[y] <<  " == "  << C[i] << endl;
                        return false;
                    }
                }
            }
        }
    }

    return true;

}

bool bubbleSort (char C[], int A[], int N, char c[], int a[]) {

    // int cnt = 0;
    // bool stable = true;

    bool flag = true;

    while (flag) {
        flag = false;
        for (int i = N - 1; i > 0; i--) {
            if (A[i] < A[i - 1]) {
                swap (C[i], C[i - 1]);
                swap (A[i], A[i - 1]);
                flag = true;
                // disp (A, N);
            }
        }
        // cout << endl;
    }

    return isStable(C, A, N, c, a);

}

bool selectionSort (char C[], int A[], int N, char c[], int a[]) {
    
    // int cnt = 0;    // 入れ替え回数のカウント変数
    // bool stable = true;

    for (int i = 0; i < N - 1; i++) {
        int minj = i;

        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }

        if (i != minj) {
            swap (C[i], C[minj]);
            swap (A[i], A[minj]);
        }
    } 

    return isStable(C, A, N, c, a);

}

void disp (char C[], int A[], int N, bool stable) {

    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C[i] << A[i];
    }

    cout << endl;
    
    if (stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

}

int main () {

    int N;
    char C[36], Cb[36], Cs[36];
    int A[36], Ab[36], As[36];

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> C[i] >> A[i];
        Cb[i] = C[i];
        Cs[i] = C[i];
        Ab[i] = A[i];
        As[i] = A[i];
    }

    bool stableB = bubbleSort(Cb, Ab, N, C, A);
    bool stableS = selectionSort(Cs, As, N, C, A);

    disp (Cb, Ab, N, stableB);
    disp (Cs, As, N, stableS);

    return 0;
}


Measured memory_bytes: 3120
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
res4row = []
res4col = []
res = [[]]

for j, row in enumerate(a):

    tf = False
    for el in row:
        if el == '#':
            tf = True
    if tf is True:
        res4row.append(j)

for k, col in enumerate(a[0]):
    tf2 = False
    for row2 in a:
        if row2[k] == '#':
            tf2 = True
    if tf2 is True:
        res4col.append(k)

res = [[] for z in range(h)]
for num4row in res4row:
    # res.append([])
    for num4col in res4col:
        res[num4row].append(a[num4row][num4col])

for r in res:
    st = ''
    if len(r) != 0:
        for c in r:
            st = st + c
        print(st)

Measured memory_bytes: 3188
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=parseMap(split(readline()))
    if b-a==c-b
        println("YES")
    else
        println("NO")
    end
end
main()

Measured memory_bytes: 164876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll N;

int main(){
   cin >> N;
   ll ans = 0;
   FOR(i,1,N+1){
      for(ll j = 1;j * i < N;j++){
         ans++;
      }
   }
   cout << ans << endl;
}

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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  
  int A,B,C;
  
  A = Z;
  B = X;
  C = Y;
  
  cout << A << " " << B << " " << C << endl;
}


Measured memory_bytes: 3624
N = int(input())
S = dict()
word = []
ans = 0
for i in range(N):
    s = input()
    if s not in word:
        word.append(s)
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

M = int(input())
T = dict()
for i in range(M):
    t = input()
    if t not in word:
        word.append(t)
    if t in T:
        T[t] += 1
    else:
        T[t] = 1

for w in word:
    if w in S and w in T:
        money = S[w] - T[w]
    elif w in S:
        money = S[w]
    else:
        money = -1 * T[w]
    if money > ans:
        ans = money
print(ans)





Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long m=sc.nextLong();
		String s=sc.next();
		String t=sc.next();
		boolean yes=true;

		int a=(int)Math.min(n, m);
		int b=(int)Math.max(n,m);
		int c;

		while (a!=0){
			c=b%a;
			b=a;
			a=c;
		}

		for(int i=0;i<b;++i){
			if(s.charAt(s.length()/b*i)==t.charAt(t.length()/b*i));
			else {yes=false; break;}
		}

		if (yes==true)System.out.println(n/b*m);
		else System.out.println(-1);


	}
}


Measured memory_bytes: 27468
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    int res = 0;
    for (int i = 1; i <= N; i++) {
        int j = i;
        int count = 0;
        while (j > 0) {
            j /= 10;
            count++;
        }
        if (count % 2 == 1) {
            res++;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
int a[114];
signed main() {
	ll n, d, x, ans = 0;
	cin >> n >> d >> x;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (d%a[i] == 0)ans += d / a[i];
		else ans += d / a[i] + 1;
	}
	cout << x + ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
num = 0
for i in range(1,len(p)-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        num+=1
print(num)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static char Calc(string a, string b, string c) {
        var xs = new List<Queue<char>>() {
            new Queue<char>(a),
            new Queue<char>(b),
            new Queue<char>(c),
        };

        int p = 0;
        while (true) {
            if (xs[p].Count == 0) {
                return (char)(p + 'A');
            }

            switch (xs[p].Dequeue()) {
            case 'a': p = 0; break;
            case 'b': p = 1; break;
            case 'c': p = 2; break;
            }
        }
    }

    static void Main() {
        var a = Console.ReadLine();
        var b = Console.ReadLine();
        var c = Console.ReadLine();

        Console.WriteLine(Calc(a, b, c));
    }
}

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

int main(){
	bool a[32];
	fill(a,a+32,false);
	int in;
	for(int i=0;i<28;i++){
		scanf("%d",&in);
		a[in]=true;
	}
	for(int i=1;i<=30;i++){
		if(!a[i])printf("%d\n",i);
	}
}

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

char in[10];
pair<pair<string,int>,int> p[100];

int main(){
int n; cin >> n;
for(int i=0; i<n; i++) {
    int t; scanf("%s %d\n",in,&t);
    string tmp=in;
    p[i] = make_pair(make_pair(in,-t),i);
}
sort(p,p+n);
for(int i=0; i<n; i++) printf("%d\n",p[i].second+1);
return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int a , b ;
	cin >> a >> b ;
	if(a == b){
		for(int i = 0 ; i < min(a,b) ; i++){
			cout << a ;
		}
		return ;
	}
	if(a < b){
		for(int i = 0 ; i < b ; i++){
			cout << a ;
		}
	}
	else if( a> b){
		for(int i = 0 ; i < a ; i++){
			cout << b ;
		}
	}
	cout << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (300)
#define MOD (1000000007)

ll d[MAXN][MAXN];
ll d2[MAXN][MAXN];

int main(void)
{
    ll n,m,l;
    scanf("%ld %ld %ld",&n,&m,&l);

    for(int i=0;i<n;i++)for(int j=0;j<n;j++) d[i][j] = 1LL<<60;

    for(int i=0;i<m;i++)
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++)
    {
        if(d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
    }

    for(int i=0;i<n;i++) for(int j=0;j<n;j++)
    {
        if(d[i][j]<=l) d2[i][j] = 1;
        else d2[i][j] = 1LL<<60;
    }

    for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++)
    {
        if(d2[i][j] > d2[i][k] + d2[k][j]) d2[i][j] = d2[i][k] + d2[k][j];
    }

    ll q;
    scanf("%ld",&q);
    for(int i=0;i<q;i++)
    {
        ll s,t;
        scanf("%ld %ld",&s,&t);
        s--;t--;
        if(d2[s][t]==1LL<<60)
        {
            printf("-1\n");
        }
        else printf("%ld\n",d2[s][t]-1);
    }
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;


int main() {
	int a,c=0,d=0;
	string b;
	cin >> a >>b;

	for (int i = 0; i < a; i++) {
		if ("I" == b.substr(i, 1)) {
			c++;
		}
		else {
			c--;
		}
		if (d <= c) {
			d = c;
		}
	}

	cout << d << endl;


	//int abc;
	//cin >> abc ;
}

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

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<string, string> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t = s;
  reverse(ALL(t));
  map<P, ll> mp1, mp2;
  REP(bit, 1 << n) {
    string r1 = "", b1 = "";
    string r2 = "", b2 = "";
    REP(i, n) {
      (bit >> i & 1 ? r1 : b1) += s[i];
      (bit >> i & 1 ? r2 : b2) += t[i];
    }
    mp1[P(r1, b1)]++;
    mp2[P(r2, b2)]++;
  }
  ll ans = 0;
  for (auto a : mp1) {
    if (mp2.find(a.first) != mp2.end()) {
      ans += a.second * mp2[a.first];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 91904
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long t = sc.nextLong();
        long a = sc.nextLong();
        
        for (int i=1; i<n; i++){
            long tt = sc.nextLong();
            long aa = sc.nextLong();
            long c = Math.max(t/tt,a/aa);
            while (tt*c < t || aa*c < a)
                c++;
            t = tt*c;
            a = aa*c;
        }
        System.out.println(t+a);
        
    }

}


Measured memory_bytes: 25004
// JOI - Prelim  0521
// おつり
#include <bits/stdc++.h>

using namespace std;

using UInt = uint_fast64_t;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

const vec1<UInt> coins{500, 100, 50, 10, 5, 1};

bool sub()
{
    const auto price(cin2var<UInt>());

    if (!price) return false;

    UInt pay          = 1000 - price;
    UInt pay_out_coin = 0;
    for (const auto& coin : coins) {
        pay_out_coin += pay / coin;
        pay = pay % coin;
    }
    cout << pay_out_coin << endl;
    return true;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    while (sub());
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

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

	if (N % 2 == 0)
		result = N;
	else
		result = N * 2;

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
S=str(input())
l=len(S)
d=[0]*l

R,L=0,0
R_flag,L_flag=0,0
for i in range(l):
    if S[i]=='R':
        R_flag=1
        R+=1
        if R==1 and L>0:
            L-=1
            p=L//2
            d[i-L-2]+=L-p#R
            d[i-L-1]+=p#L
            L=0
    else:
        L_flag=1
        L+=1
        if R>0 and L==1:
            R-=1
            p=R//2
            d[i-1]+=p+1#R
            d[i]+=R-p+1#L
            R=0
if L>1 and R_flag==1:
    L-=1
    p=L//2
    d[-L-2]+=L-p
    d[-L-1]+=p
print(*d)

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

int main() {
  int n,d;
  scanf("%d%d", &n,&d);
  int x[n][d];
  for (int i = 0; i < n; ++i) {
    for(int j = 0; j < d; ++j){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  int ref = 0;
  for (int i = ref; i < n-1; ++i) {
    for(int j = ref+1; j < n; ++j){
      float dis = 0;
      for(int k = 0; k < d; ++k){
        float disa;
        disa = (float)abs(x[i][k] - x[j][k]);
        dis += pow(disa,2.0);
      }
      dis = sqrt(dis);
      if(ceil(dis)==floor(dis)) {
        ++ans;
        // cout << i << " " << j << endl;
        // cout << dis << endl;
      }

      // cout << i << " " << j << endl;
    }
    ref++;
  }

  cout << ans << endl;



}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string S;
int X[1000010];
int Y[1000010];
int now;
int main()
{
	cin >> S;
	if(S[0]=='J'){
		X[0]=1;Y[0]=0;
	}
	else if(S[0]=='O'){
		X[0]=1;Y[0]=1;
	}
	else{
		X[0]=1;Y[0]=2;
	}
	for(int i=1;i<S.length();i++){
		int k;
		if(S[i]=='J')k=0;
		else if(S[i]=='O')k=1;
		else k=2;
		if(Y[now]==k)X[now]++;
		else{
			now++;
			X[now]=1;Y[now]=k;
		}
	}
	int ans=0;
	for(int i=0;i<1000000;i++){
		if(Y[i]!=0)continue;
		if(Y[i+1]!=1)continue;
		if(Y[i+2]!=2)continue;
		if(X[i]<X[i+1])continue;
		if(X[i+1]>X[i+2])continue;
		ans=max(ans,X[i+1]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 10092
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    Vl b(n+1), ans;
    Rep(i, 1, n) cin >> b[i];
    bool f;
    rep(i, 0, n){
        bool f = true;
        for(int j = sz(b)-1; j >= 1; j--){
            if(j == b[j]){ 
                ans.push_back(j);
                b.erase(b.begin()+j);
                // ////
                // rep(i, 1, sz(b)) cout << b[i] << " ";
                // coel;
                f = false;
                break;
            }
        }
        if(f){
            co(-1);
            return 0;
        }
    }
    reverse(ALL(ans));
    rep(i, 0, n) co(ans[i]);

    return 0;
}


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

int main() {
        string s, t; cin >> s >> t;
        vector <vector <int> > nxt(s.size() + 1); vector <int> tmp(26, s.size() + 1);
        for(int i = s.size(); i >= 0; i--) {
                nxt[i] = tmp;
                if(i > 0) {
                        tmp[s[i - 1] - 'a'] = i;
                }
        }

        long long tot = 0, ptr = 0;
        for(int i = 0; i < t.size(); i++) {
                if(nxt[ptr][t[i] - 'a'] > s.size()) {
                        tot += s.size();
                        ptr = 0;
                        if(nxt[ptr][t[i] - 'a'] > s.size()) {
                                cout << -1 << endl;
                                return 0;
                        }
                }
                ptr = nxt[ptr][t[i] - 'a'];
        }
        cout << tot + ptr << endl;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, k;
ll a[111];
ll dp[111][256][111];
const ll MOD = 1000000000 + 7;

ll func(int a) {
  ll res = 1;
  for (int i = a; i >= 1; i--) {
    res = ((res % MOD) * (i % MOD)) % MOD;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  cin >> n >> k;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 256; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i + 1][j ^ a[i]][k + 1] = ((dp[i][j][k] % MOD) + (dp[i + 1][j ^ a[i]][k + 1] % MOD)) % MOD;
        dp[i + 1][j][k] = ((dp[i][j][k] % MOD) + (dp[i + 1][j][k] % MOD)) % MOD;
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll tmp = ((dp[n][k][i] % MOD) * (func(i) % MOD)) % MOD;
    ans = ((ans % MOD) + (tmp % MOD)) % MOD; 
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

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

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/60/60;
    m=S%3600/60;
    s=S%3600%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 3196
A, B = map(int, input().split())
#ｋを偶数として・・・
#ｋ　＾　（ｋ＋１）　＝　１
#１からメルセンヌ数までxorし続けると０になる
def xorsum(n):
  k = n // 2 + n % 2
  l = n % 2
  if l == 1:
    if k % 2 == 0:
      return 0
    else:
      return 1
  else:
    if k % 2 == 0:
      return n
    else:
      return 1 ^ n
#print(xorsum(A - 1), xorsum(B))
print(xorsum(max(A - 1, 0)) ^ xorsum(B)) if A != B else print(A)
"""
def ddddd(n):
  res = 0
  for i in range(1, n + 1):
    res = res ^ i
  return res
print(ddddd(A - 1) ^ ddddd(B), ddddd(A - 1), ddddd(B))
"""

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define MAX INT_MAX
#define MIN INT_MIN
#define ss second
#define ff first
#define vec(a) vector<a>
#define double long double
const int mod = 1e9+7;

double prob(vec(double) &v){
	int n = v.size();
	vec(double) dp(n+1, 0);
	
	dp[0] = 1.0-v[0];
	dp[1] = v[0];
	double p = 1;
	for(int i = 1; i < n; i++){

		//dp[i+1] = dp[i];
		//cout << dp[i+1] << " ";
		for(int j = i+1; j >= 0; j--){
			dp[j] = dp[j]*(1.0-v[i])+(j-1>=0?dp[j-1]:0)*(v[i]);
			//cout << "i->" << i << "& j->" << j << " || " << dp[j] << endl;
		}
		//dp[0] *= 
	}
	double ans = 0;
	for(int i = dp.size()-1; i >= 0; i--){
		int heads = i;
		int tails = n-heads;
		if(heads > tails){
			//cout << dp[i] << endl;
			ans += dp[i];
		}
	}
	return ans;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vec(double) v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	cout << fixed << setprecision(10) << prob(v) << endl;
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs  first
#define sc  second



int a[1000];

int main() {

	for (;;) {
		int n;


		cin >> n;
		if (n == 0) break;

		rep(i, n) cin >> a[i];

		int ret = 0x1fffffff;

		sort(a, a + n);
		rep(i, n - 1) ret = min(ret, a[i + 1] - a[i]);

		cout << ret << endl;
	}

}

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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    string s_ = "";bool flag = true;
    for(int i = 0;i < n;i++){
        s_ += '0';
    }
    if(m == 0 && n != 1){
        s_[0] = '1';
        cout << stoi(s_);
        return 0;
    }else if(m == 0 && n == 1){
        cout << 0;
        return 0;
    }
    int s[6] = {};char c[6] = {};
    for(int i = 0;i < m;i++){
        cin >> s[i] >> c[i];
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < m;j++){
            if(s[i] == s[j] && c[i] != c[j]){
                if(i != j){
                    flag = false;
                    break;
                }
            }
        }
    }
    for(int i = 0;i < m;i++){
        if(s[i] == 1 && c[i] == '0'){
            if(n != 1){
                flag = false;
                break;
            }
        }
    }
    for(int i = 0;i < m;i++){
        s_[s[i]-1] = c[i];
    }
    if(flag){
        if(s_[0] == '0' && n != 1){
            s_[0] = '1';
        }
        cout << stoi(s_);
    }else{
        cout << -1;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys

_BASE = 10**9 + 7

def factorial(N):
    total = 1
    for i in xrange(1, N + 1):
        total *= i
        total %= _BASE
    return total % _BASE

def main(argv):
    for line in sys.stdin:
        N, M = map(lambda x: int(x), line.split(" ", 2))

        arrangement = 0
        if M == N:
            arrangement = factorial(M)**2 * 2
        elif abs(M - N) == 1:
            minimum = min(M, N)
            arrangement = factorial(minimum)**2 * (minimum + 1)

        print(arrangement % _BASE)

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1619&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */

ll n,m;

string b[505];

// n <= 20 , 25 <= m <= 500
bool ok[501];

// 25 <= n <= 500, m <= 20
int bit[501];
int dp[2][1<<22];

int solve(){
    int res = 0;
    for(int i = 0; i < n;i++) cin >> b[i];
    if(n <= m){ // n <= 20 , 25 <= m <= 500
        for(int i = 0; i < (1<<n);i++){
            if(res >= __builtin_popcount(i)) continue;
            fill(ok,ok+501,false);
            for(int j = 0; j < n;j++){ // n <= 20
                if(!((i>>j)&1)) continue;
                for(int k = 0; k < m;k++){ // m <= 500
                    if(b[j][k] == '1') ok[k] = !ok[k];
                }
            }
            if(accumulate(ok,ok+m,0)) continue;
            res = max(res,__builtin_popcount(i));
        }
    }else{ // 25 <= n <= 500, m <= 20
        fill(bit,bit+n,0);
        for(int i = 0; i < n;i++){
            for(int j = 0; j < m;j++){
                if(b[i][j] == '1'){
                    bit[i] |= (1<<j);
                }
            }
        }
        for(int i = 0; i < 2;i++) for(int j = 0; j < (1<<m);j++) dp[i][j] = -1;
        dp[0][0] = 0;
        int cur = 0, next = 1;
        for(int i = 0; i < n;i++){
            for(int j = 0; j < (1<<m);j++){
                if(dp[cur][j] == -1) continue;
                dp[next][j] = max(dp[next][j],dp[cur][j]);
                dp[next][j^bit[i]] = max(dp[next][j^bit[i]],dp[cur][j]+1);
                
                dp[cur][j] = -1;
            }
            swap(cur,next);
        }
        res = dp[cur][0];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n >> m,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 19528
(defun size-of-burger (level)
  (if (<= level 0)
      1
      (+ 3 (* 2 (size-of-burger (1- level))))))

(defun patty-in-burger (level)
  (if (<= level 0)
      1
      (+ 1 (* 2 (patty-in-burger (1- level))))))

(defun main (n x)
  (cond
    ((<= x 0) 0)
    ((>= x (size-of-burger n)) (patty-in-burger n))
    (t (let ((halfsize (size-of-burger (1- n))))
         (+ (main (1- n) (1- x))
            (if (>= x (+ 2 halfsize)) 1 0)
            (main (1- n) (- x halfsize 2)))))))

(defun repl ()
  (format t "~a~%" (main (read) (read))))

(repl)


Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a,b,min,max;
  cin >> n >> a >> b;
  if(a > b) cout << 0 << endl;
  else{
    if(n == 1 && a != b) cout << 0 << endl;
  	else{
      min = (n-1)*a+b;
  	  max = a+(n-1)*b;
  	  cout << max - min +1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a<=5) cout<<0<<endl;
    else if(a<=12) cout<<b/2<<endl;
    else cout<<b<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	a := nextInt()

	fmt.Println(a + a*a + a*a*a)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1804