akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,k;cin>>n>>k;
    nckinit(n+1,mod);
    rep(i,1,k+1){
        if(n-k+1<i){
            cout<<0<<endl;
            continue;
        }
        ll ans=nck(n-k+1,i,mod)*nck(k-1,i-1,mod);
        cout<<ans%mod<<endl;
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const int shift=15;
long long p[50][50];
int main()
{
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		string s; cin>>s;
		int ind=s.size();
		for(int i=0;i<s.size();i++) if(s[i]=='.') {ind=i; break;}
		int st2=0,st5=0;
		long long br=0;
		for(int i=0;i<s.size();i++) if(i!=ind) br=br*10+(s[i]-'0');
		if(ind!=s.size()) st2=st5=ind+1-s.size();
		while(br%2==0) {st2++; br/=2;}
		while(br%5==0) {st5++; br/=5;}
		p[st2+shift][st5+shift]++;
	}
	long long sol=0;
	for(int i=0;i<50;i++) for(int j=0;j<50;j++) for(int k=0;k<50;k++) for(int t=0;t<50;t++) if(i+k>=2*shift && j+t>=2*shift)
	{
		if(i==k && j==t) sol+=p[i][j]*(p[k][t]-1);
		else sol+=p[i][j]*p[k][t];
	}
	sol/=2;
	printf("%lld",sol);
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n;
  cin>>n;
  int a[n];
  bool ok=1;
  for(i=0;i<n;i++){
    cin>>a[i];
    if(i>=1&&a[i-1]>=a[i]) ok=0;
  }
  if(ok){
    cout<<1<<endl;
    return 0;
  }
  
  int l=1,r=202020;
  while(r-l>1){
    int mid=(r+l)/2;
    map<int,int> m;
    bool ng=0;
    for(i=1;i<n;i++){
      if(ng==1) break;
      if(a[i-1]==a[i]){
        m[a[i]]++;
        int u=a[i];
        while(m[u]==mid){
          m.erase(u);
          u--;
          if(u<=0){
            ng=1;
            break;
          }
          m[u]++;
        }
      }
      else if(a[i-1]>a[i]){
        auto it=m.rbegin();
        while(it!=m.rend()&&it->first>a[i]){
          m.erase(it->first);
        }
        m[a[i]]++;
        int u=a[i];
        while(m[u]==mid){
          m.erase(u);
          u--;
          if(u<=0){
            ng=1;
            break;
          }
          m[u]++;
        }
      }
    }
    if(ng==1) l=mid;
    else r=mid; 
  }
  cout<<r<<endl;

  
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <cassert>
#include <chrono>
#include <fstream>
#include <array>
using ll = long long;

//LLONG_MAX
//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

#ifdef LOCAL
#define ASSERT_DEBUG
#endif
#ifdef ASSERT_DEBUG
#define ASSERT(cond) assert(cond)
#else
#define ASSERT(cond)
#endif

class Point
{
public:
	int x;
	int y;
	Point() { this->x = 0; this->y = 0; }
	Point(int x, int y) { this->x = x; this->y = y; }
};

//time_point<system_clock> _start_time = system_clock::now();
//ll time = duration_cast<milliseconds>(system_clock::now() - _start_time).count();


//const int R = 10000;
//const double START_TEMP = pow(50.0, 2);
//const double END_TEMP = 0;
//double temp = sqrt(START_TEMP + (END_TEMP - START_TEMP) * (ms / (double)1900));
//double probability = MIN(1.0, exp((score - new_score) / temp));
//bool force_next = probability > ((xorshift32() % R) / (double)R);
//if (force_next)

using namespace std;
using namespace chrono;

unsigned int xorshift32()
{
	static int s = 7;
	s ^= (s << 13);
	s ^= (s >> 17);
	s ^= (s << 15);
	return s;
}


const int D = 365;
const int N = 26;
int C[N];
int S[N][D];


int GetScore(int schedule[D])
{
	int score = 0;
	int last[N] = {};
	for (int d = 0; d < D; d++)
	{
		score += S[schedule[d]][d];
		last[schedule[d]] = d;
		for (int n = 0; n < 26; n++)
		{
			score -= C[n] * (d - last[n]);
		}
	}
	return score;
}




int main()
{
	int _;
	cin >> _;
	REP(n, N)
	{
		cin >> C[n];
	}
	REP(d, D)
	{
		REP(n, N)
		{
			cin >> S[n][d];
		}
	}

	int schedule[D] = {};

	int score = GetScore(schedule);

	REP(i, D)
	{
		cout << (schedule[i] + 1) << endl;
	}
}

Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	num := 2 * d + 1
	if n % num == 0 {
		fmt.Println(n / num)
	} else {
		fmt.Println(n / num + 1)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(){
    int a;
    cin >> a;
    cout << a * a * a + a * a + a << endl;
    return 0;
}

Measured memory_bytes: 3628
# coding: utf-8
from collections import Counter


def solve(*args: str) -> str:
    C = Counter(args[1:])
    ret = []
    for r in ('AC', 'WA', 'TLE', 'RE'):
        ret.append(r+' x '+str(C[r]))
    return '\n'.join(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 17644
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 55, maxd = 12;
int n;
int cnt[maxd + 1];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i <= maxd; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int d;
    scanf("%d", &d);
    cnt[d]++;
  }
  return true;
}

void solve() {
  for (int i = 0; i <= maxd; i++) {
    if (cnt[i] >= 3) {
      printf("0\n");
      return;
    }
  }
  int res = 0;
  for (int msk = 0; msk < (1 << (maxd + 1)); msk++) {
    vector<int> ds;
    ds.push_back(0);
    for (int i = 0; i <= maxd; i++) {
      if (cnt[i] == 2) {
        ds.push_back(i);
        ds.push_back((24 - i) % 24);
      } else if (cnt[i] == 1) {
        if (msk & (1 << i)) {
          ds.push_back(i);
        } else {
          ds.push_back((24 - i) % 24);
        }
      }
    }
    int cur = inf;
    for (int i = 0; i < sz(ds); i++) {
      for (int j = i + 1; j < sz(ds); j++) {
        int d = abs(ds[j] - ds[i]);
        cur = min(cur, min(d, 24 - d));
      }
    }
    res = max(res, cur);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cctype>
#define ll          long long int
#define PB          push_back
#define GO          ll t; cin>>t; while(t--)
#define G(t)        cin>>t; while(t--)
#define ALLR(x)     x.rbegin(), x.rend()
#define PII         pair<ll ,ll >
#define VI          vector<ll >
#define ALL(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define PI          3.141592653589793238
#define SZ(x)       (ll )x.size()
#define hell2        998244353
#define hell        1000000007
#define FO(i,a,b)    for(i=a;i<b;i++)
#define FOREV(i,a,b)    for(i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define BS          binary_search
#define MP          make_pair
#define ARR(n,i,a)    ll n,i;cin>>n;ll a[n];FO(i,0,n)cin>>a[i];
#define ARRK(k,n,i,a) int n,k,i;scanf("%d%d",&n,&k);ll a[n];FO(i,0,n)scanf("%lld",&a[i]);
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
int main()
{
    fio
   int a,b,c;cin>>a>>b>>c;
  if(c==1)cout<<b-a+1;
  else cout<<(b-a+1)/c+(a%c==0&&b%c==0);
return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    if(n<5)
    cout<<"0"<<endl;
    else if(n>=5 && n<500)
    {
        int x=n/5;
        cout<<x*5<<endl;
    } 
    else if(n>=500)
    {
        int x=n/500;
        int y=n-500*x;
        int ans1=x*1000;
        int y1=y/5;
        int ans2=y1*5;
        cout<<ans1+ans2<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;


int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d;
    long long int m,n,o,i,j,k=1,money;
    long long int a,a1=0,a2=0,a3=0,ar=1,as=1,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>n>>a1>>a2;
    if(a1+a2>=n)
    {
        if(a1>=n) cout<<n;
        else cout<<a1;
    }
    else
    {
        ar=n/(a1+a2);
        n-=ar*(a1+a2);
        ar*=a1;
        if(n>=a1) cout<<ar+a1;
        else cout<<ar+n;
    }
    return 0;
}





Measured memory_bytes: 256
N = int(input())
S = input()
rcnt = S.count('R')
gcnt = S.count('G')
bcnt = S.count('B')
ans = rcnt * gcnt * bcnt

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] == S[j]:
            continue
        if j + (j - i) >= N:
            break
        if S[i] != S[j] and S[j] != S[j + (j - i)] and S[i] != S[j + (j - i)]:
            ans -= 1
print(ans)

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


int n, m, a[51], b[51];
int ans = 0;

//union-find
int par[51], depth[51];
void init(/*int n*/){
	for(int i = 1; i <= n; i++){
		par[i] = i;
		depth[i] = 0;
	}
}
int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(depth[x] < depth[y]) par[x] = y;
	else{
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}
bool same(int x, int y){
	return find(x) == find(y);
}
//

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
	}
	
	for(int i = 0; i < m; i++){
		init();
		for(int j = 0; j < m; j++){
			if(i == j) continue;
			unite(a[j],b[j]);
		}
		if(!same(a[i],b[i])) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

l = []

for i in range(N):
    s , p = map(str, input().split())
    p = 100-int(p)
    if p == 100:
        l.append(s+str(999))
    elif p < 10:
        l.append(s+str(0)+str(p))
    else:
        l.append(s+str(p))
l_new = sorted(l)
# print(l)
# print(l_new)
for i in l_new:
    print(l.index(i)+1)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  char S[100000];
  scanf("%s",S);

  int cnt = 0;
  for(int i = 0;i < strlen(S);i++){
    if(S[i] == '1') cnt++;
  }
  
  printf("%d\n",min(cnt,strlen(S)-cnt)*2);
 
  return 0;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

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

	bool ok = true;
	rep(i, n){
		if(a[i] % 2 == 0){
			if(a[i] % 3 != 0 && a[i] % 5 != 0){
				ok = false;
			}
		}
	}

	if(ok){
		cout << "APPROVED" << endl;
	}else{
		cout << "DENIED" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int N,i,j,ans = 0;scanf("%d",&N);
  int L[N];
  for(i=0;i<N;i++) scanf("%d",&L[i]);
  sort(L,L+N);
  for(i=0;i<N-2;i++){
    for(j=i+1;j<N-1;j++){
      ans += lower_bound(L,L+N,L[i]+L[j])-L-j-1;
    }
  }
  printf("%d\n",ans);
}

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

int main(void)
{
    int c, A, B, C, x, y;
    long long answer=5000000000;
    cin >> A >> B >> C >> x >> y;

    for (c=0; c <= 100000; ++c) {
        long long money = c*2*C+max(0, x-c)*A+max(0, y-c)*B;
        answer = min(answer, money);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
	set<int>s;
	int q;
	cin>>q;
	while(q--){
		int c,x;
		cin>>c>>x;
		if(c==0){
			s.insert(x);
			cout<<s.size()<<endl;
		}
		else if(c==1){
			cout<<s.count(x)<<endl;
		}
		else if(c==2){
			s.erase(x);
		}
		else if(c==3){
			int y;
			cin>>y;
			for(set<int>::iterator i=s.lower_bound(x); i!=s.upper_bound(y); i++)
				cout<<*i<<endl;
		}
	}
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    ll a, b ;
    ll v, w;
    ll t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    ll vel = v - w;
    ll dis = abs(a - b);
    if(dis <= vel * t){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int QUA = 1e9 + 7;

int n;
vector<bool> A;
string s;

void prnt(){
  for(int i = 0; i < n;i++){
    printf("%c", (A[i] ? 'S' : 'W'));
  }
  puts("");
}

bool prgct(bool a, bool b){
  A[0] = a; A[1] = b;
  for(int i = 1; i < n - 1;i++){
    A[i + 1] = ((s[i] == 'o') == A[i]) == A[i - 1];
  }
  bool tmp = ((s[n - 1] == 'o') == A[n-1]) == A[n - 2];
  if(A[0] == tmp){
    if(A[1] == (((s[0] == 'o') == A[0]) == A[n - 1])){
      prnt();
      return false;
    }
  }
  return true;
}

int main(){

  cin >> n >> s;
  A.resize(n);

  bool flag = true;
  if(flag){
    flag = prgct(true, true);
  }
  if(flag){
    flag = prgct(true, false);
  }
  if(flag){
    flag = prgct(false, true);
  }
  if(flag){
    flag = prgct(false, false);
  }
  if(flag){
    puts("-1");
  }
  return 0;
}

Measured memory_bytes: 512
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
mod2(x)=mod(x,2)

function multiplier2(x)
    ret = 0
    while mod(x, 2) == 0
        x /= 2
        ret += 1
    end
    return(ret)
end

function main()
    n = parseInt(readline())
    a = parseMap(split(readline()))

    ans = 0
    for i in 1:n
        ans += multiplier2(a[i])
    end

    println(ans)
end

main()


Measured memory_bytes: 172316
/**
* Copyright(c)
* All rights reserved.
* Author : Mingzhe
* Description : sample
*/
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <memory.h>
#define MAXN 10005
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min( min(a+b,a+c),b+c)<<endl;;
    return 0;
}


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

long long gcd(long long, long long);
long long lcm(long long, long long );

int main(){
  long long a,b;
  cin >> a >> b;
  
  cout << lcm(a,b) << endl;
}

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

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n);
  map<int, int> mp;
  rep(i, n) {
    cin >> A[i];
    mp[A[i]]++;
  }
  if(mp.size() > 2) {
    cout << "No" << endk;
  } else if(mp.size() == 2) {
    int m = mp.begin()->first;
    int M = mp.rbegin()->first;
    if(M-m>1) cout << "No" << endk;
    else {
      if(mp[m] >= M) cout << "No" << endk;
      else if(mp[M] < (M-mp[m])*2) cout << "No" << endk;
      else cout << "Yes" << endk;
    }
  } else {
    int m = mp.begin()->first;
    if(mp[m] >= m*2 || mp[m]-1 == m) cout << "Yes" << endk;
    else cout << "No" << endk;
  }
  return 0;
}


Measured memory_bytes: 8176
#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())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#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;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

ll dp[101][21];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> num(N);
    REP(i,N) cin>>num[i];

    dp[0][num[0]] = 1;
    for(int i=1;i<N-1;i++){
        for(int k=0;k<=20;k++){
            if(0 <= k-num[i] && k-num[i]<=20) dp[i][k] += dp[i-1][k-num[i]];
            if(0 <= k+num[i] && k+num[i]<=20) dp[i][k] += dp[i-1][k+num[i]];
        }
    }
    cout<<dp[N-2][num[N-1]]<<endl;
}


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

int main(){
	string s;
	int n,a,b;
	int kokunai;
	cin >> n >> a >> b;
	cin >> s;
	kokunai = a + b;
	for (int i = 0; i < n; i++){
		
		if (s[i] == 'c'){
			cout << "No" << endl;
		}
		else if (s[i] == 'a'){
			if (kokunai>0){
				cout << "Yes" << endl;
				kokunai--;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			if (kokunai > 0 && b > 0){
				cout << "Yes" << endl;
				kokunai--;
				b--;
			}
			else{
				cout << "No" << endl;
			}
		}

	}
	
	return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      int count = 0;
      int n,x;
      String[] lines;

      while(true){

        lines = br.readLine().split(" ");
        n = Integer.parseInt( lines[0] );
        x = Integer.parseInt( lines[1] );
        if( n == 0 && x == 0) break;

        for( int i = 1; i < n-1; i++ ){
          for( int j = i+1; j < n; j++ ) {
            for( int k = j+1; k <= n; k++ ){
              if ( (i + j + k)  > x ) break;
              if ( (i + j + k) == x ){
                count++;
                // System.out.println( i + " " + j + " " + k);
              }
            }
          }
        }
        System.out.println(count);
        count = 0;
      }
    }
  }
}


Measured memory_bytes: 24832
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

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

  sort(a, a + 3 * n);
  ll sum = 0;
  int j = 3 * n - 2;
  for(int i = 0; i < n; i++){
    sum += (ll)a[j];
    j -= 2;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	vector<P>p(n);
	int task, deadline;
	for (int i = 0; i < n; i++) {
		cin >> task >> deadline;
		p[i].first = deadline;
		p[i].second = task;
	}
	sort(p.begin(), p.end());
	ll worksum = 0;
	for (int i = 0; i < n; i++) {
		worksum += p[i].second;
		if (worksum > p[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3328
S = input()
T = input()

ls = len(S)
lt = len(T)

ans = 10**10

for i in range(ls-lt+1):
    cnt = 0
    for j in range(lt):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(cnt, ans)

print(ans)

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

		String s = sc.next();

			if (s.charAt(0)==s.charAt(1)&&s.charAt(0)==s.charAt(2)) {
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>
	
int main() {
	string s;
	cin >> s;
	REP(i, s.size())cout << "x";
	cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int MAXN=200005,MAXM=30000000;
int P;
#define L 1048576
#define real long double
#define eps 1e-9
char _buf[L],*S,*T,_buf1[L],*S1=_buf1;
inline char gc()
{
	if(S==T)
	{
		T=(S=_buf)+fread(_buf,1,L,stdin);
		if(S==T)return 0;
	}
	return *S++;
}
template<class T> void get(T &x)
{
	char c;
	for(c=gc();(c<'0'||c>'9')&&c!='-';c=gc());
	bool b=0;
	if(c=='-')
	{
		b=1;
		c=gc();
	}
	for(x=c^'0',c=gc();c>='0'&&c<='9';c=gc())x=(x<<3)+(x<<1)+(c^'0');
	if(b)x=-x;
}
inline void pc(char c)
{
	if(S1==_buf1+L)
	{
		fwrite(_buf1,1,L,stdout);
		S1=_buf1;
	}
	*S1++=c;
}
void out(ll x)
{
	if(x>9)out(x/10);
	pc(x%10^'0');
}
int Pow(int x,int y)
{
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%P)if(y&1)s=(ll)s*x%P;
	return s;
}
int A(int x)
{
	return x<0?-x:x;
}
int n,m,i,j,a[MAXN],b[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	while(m--)
	{
		fill(b,b+n+1,0);
		for(i=1;i<=n;i++)
		{
			b[max(i-a[i],1)]++;
			b[min(i+a[i],n)+1]--;
		}
		for(i=1;i<=n;i++)a[i]=a[i-1]+b[i];
		for(i=j=1;i<=n;i++)if(a[i]<a[j])j=i;
		if(a[j]==n)break;
	}
	for(i=1;i<=n;i++)cout<<a[i]<<' ';
	fwrite(_buf1,1,S1-_buf1,stdout);
	return 0;
}

Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define INF (1ll<<60)
#define mod 1000000007
#define P pair<ll,ll>
#define Graph vector<vector<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; }

int main(){
    ll l,r,d;cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<endl;
    return 0;
}

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

int main(){
    long long int n,k,q;
    cin>>n>>k>>q;
    vector<long long int>a(n,k-q);
    
    for(long long int i=0;i<q;i++){
        long long int b;
        cin>>b;
        a.at(b-1)+=1;
    }
    for(long long int i=0;i<n;i++){
        if(a.at(i)<=0)puts("No");
        else puts("Yes");
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MIN = -1e18;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  int32_t N,M;
  cin >> N >> M;
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    uf.unite(a,b);
  }
  unordered_map<int,int> um;
  int res = 0;
  for (int i = 0; i < N; i++) {
    int root = uf.root(i);
    um[root]++;
    res = max(res, um[root]);
  }
  cout << res << endl;
    

  return 0;
}


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

int main(){
  int n;
  while(cin>>n,n){
    int len;
    cin>>len;
    string str;
    cin>>str;
    int cnt=0,ans=0;
    for(int i=0;i<len-1;i++){
      if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I') cnt++,i++;
      else{
	if(cnt>=n) ans+=(cnt-n)+1;
	cnt=0;
      }
    }
    if(cnt>=n) ans+=(cnt-n)+1;
    cout <<ans<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 3884
import sys
input = sys.stdin.readline


def read():
    H, W = map(int, input().strip().split())
    N = 10
    C = []
    for i in range(N):
        c = list(map(int, input().strip().split()))
        C.append(c)
    A = []
    for i in range(H):
        a = list(map(int, input().strip().split()))
        A.append(a)
    return H, W, N, C, A


def warshall_floyd(N, G, INF=10**7):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                G[i][j] = min(G[i][j], G[i][k] + G[k][j])
    return G


def solve(H, W, N, C, A):
    D = warshall_floyd(N, C)
    ans = 0
    for i in range(H):
        for j in range(W):
            a = A[i][j]
            if a >= 0:
                ans += D[a][1]
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int p = 1;
	int ans = n;
	for(int i = 0; i < n; ++i) {
		if(a[i] == p) {
			--ans;
			++p;
		}
	}
	if(p == 1) {
		cout << -1 << '\n';
	} else {
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	ll m[5];
 	ll n,ans=0;
 	cin >> n;
 	for (int i = 0; i < 5; i++){
 		cin >> m[i];
 	}
 	sort(m,m+5);
 	ans=n/m[0]+1;
 	if(n%m[0]==0){
 		ans--;
 	}
 	cout << ans+4 << endl;
 }

Measured memory_bytes: 256
import itertools
n,m,x=map(int,input().split())
books=[list(map(int,input().split())) for i in range(n)]
ans=10**10
for status in itertools.product(range(2),repeat = n):
    cnt=0
    skill=[0]*m
    for j in range(n):
        if status[j]:
            cnt+=books[j][0]
            for k in range(m):
                skill[k]+=books[j][k+1]
    if min(skill)>=x:
        ans=min(ans,cnt)
if ans==10**10:print(-1)
else:print(ans)

Measured memory_bytes: 9220
#include<iostream>

 
using namespace std;


int main(){
    long long N;
    cin >> N;
    bool isOK=true;
    long long H[N];
    
    for(long long i=0;i<N;i++){
        cin >> H[i];
    }
    for(long long i=N-1;i>0;i--){
        long long d = H[i]-H[i-1];
        if (d>=0)continue;
        if(d<-1){
            isOK=false;
            break;
        }
        if(d==-1){
            H[i-1]-=1;
        }
    }
    if(isOK){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 1024
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {
  int n,m;

  cin >> n >> m;

  int a = 0;

  int nn,mm;

  nn = (n - 1) > 0 ? (n - 1) : 0;
  mm = (m - 1) > 0 ? (m - 1) : 0;
  
  a = n * nn / 2 + mm * m / 2;

  cout << a << endl;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  //2^Nの全探索
  //2^15 ~= 10^5 * 15 各証言を調べる
  invar(int, N);
  
  vector<vpii> sho(N, vpii());
  
  rep(i, N) {
    invar(int, A);
    rep(j, A) {
      invar(int, x); invar(int, y);
      sho[i].push_back(make_pair(x, y));
    }
  }
  
  //bit全探索
  bitset<15> bs;
  ll maxv = 0;
  for(int b = 0; b < (1<<N); b++) {
    ll ct = 0;  //正直のカウント
    bool ng = false;
    for(int i = 0; i < N; ++i) {
      if(b & (1<<i)) {  //trueなら，正直とみなす
        ct++;
        for(auto p : sho[i]) {
          if(p.second == 1)  {
            //正直者である
            if((b & (1<<(p.first-1))) != 0) {
              //実際に正直
            } else ng = true;
          } else {
            if((b & (1<<(p.first-1))) != 0) {
              ng = true;
            } else {}

          }
        }
      } 
    }
    if(!ng) chmax(maxv, ct);
  }
  
  fin(maxv);
  
}

Measured memory_bytes: 256
require 'pp'

N,d=gets.chomp.split(' ').map{|n| n.to_i}
x_0 = 0
y_0 = 0
t_0 = 0
noflg = false
i=1
while(i<=N)
	t,x_t,y_t=gets.chomp.split(' ').map{|n| n.to_i}
	x_d = x_t - x_0
	y_d = y_t - y_0
	t_d = t   - t_0
	sum_d = x_d + y_d
	if(sum_d > t_d || ((t_d)-(sum_d)) % 2 != 0)
		noflg = true
		break
	end
	x_0 = x_t
	y_0 = y_t
	t_0 = t
	i+=1
end
if(noflg)
	puts "No"
else
	puts "Yes"
end


Measured memory_bytes: 2300
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


X = INT()

ans = 1

for b in range(1, X+1):
	for p in range(2, 10):
		if b**p <= X:
			ans = max(ans, b**p)

print(ans)

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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,n) for(int i=1; i<=(n); ++i)
const long long mod = 1000000007;
const long long mmd = 10007;

int h,w,dp[1010][1010];
string str[3010];
signed main(){

    cin>>h>>w;
    dp[0][0] = 1;

    rep(i,h){
        cin>>str[i];
    }

    rep(i,h){
        rep(j,w){
            if(str[i+1][j] != '#') dp[i+1][j] += (dp[i][j]) % mod;
            else dp[i+1][j] = 0;

            if(str[i][j+1] != '#') dp[i][j+1] += (dp[i][j]) % mod;
            else dp[i][j+1] = 0;
        }
    }

    cout<<dp[h-1][w-1] % mod<<'\n';
}

Measured memory_bytes: 9216
# https://atcoder.jp/contests/abc105/tasks/abc105_c
# -2進数
# 前に考えたときはわからなかったけど、数式イジイジしたら解けた


N = int(input())

if N == 0:
    print(0)
    exit()

ans = ''
while N != 0:
    if N & 1:  # 奇数ならbitが立つのは共通する性質
        ans += '1'
        N /= -2  # -0.5ずれるのを吸収する処理
        N = int(N + 0.5)

    else:
        ans += '0'
        N //= -2


print(ans[::-1])


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 28 12:53:41 2020

@author: reira
"""

S = input()
Q = int(input())
flag = 0
l = ""
r = ""
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        flag = (flag+1)%2
    else:
        if (int(q[1]) + flag)%2:
            l += q[2]
        else:
            r += q[2]
if flag:
    print(r[::-1]+S[::-1]+l)
else:
    print(l[::-1]+S+r)
            

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

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

  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());

  long long ans = A.at(N - 1);
  long long cnt = 1;
  long long index = N - 2;

  while (index > 0) {
    ans += A.at(index);
    cnt ++;
    if (cnt == N - 1) break;
    ans += A.at(index);
    cnt ++;
    if (cnt == N - 1) break;
    index--;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4836
// AOJ 0561 Books
// 2018.1.27 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int price[11][2001], psz[11];
int sell[11][2001], ssz[11];
int dp[11][2001];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, k, i, j, m, c, g;

	n = in(), k = in();
	for (i = 0; i < n; i++) c = in(), g = in()-1, price[g][psz[g]++] = c;
	for (i = 0; i < 10; i++) qsort(price[i], psz[i], sizeof(int), cmp);
	
	for (i = 0; i < 10; i++) {
		ssz[i] = 1;
		c = k; if (c > psz[i]) c = psz[i];
		for (j = 0; j < c; j++)	sell[i][ssz[i]++] = price[i][j] + sell[i][j] + (j << 1);
	}
	
	for (i = 0; i < 10; i++) {
		c = ssz[i];
		for (j = 0; j <= c; j++) for (m = 0; m <= k; m++) {
			int t = dp[i+1][m]; if (t < dp[i][m]) t = dp[i][m];
			if (j <= m && j < c) {
				g = dp[i][m-j] + sell[i][j];
				if (g > t) t = g;
			}
			dp[i+1][m] = t;
		}
	}
	printf("%d\n", dp[10][k]);
	return 0;
}


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

using namespace std;


int main()
{
  int t;cin>>t;
  int arra[t];
  for(int i=0;i<t;i++)
  {
      cin>>arra[i];
  }
  int cnt=0;
  for(int j=1;j<t-1;j++)
  {
     if((arra[j-1]<arra[j] && arra[j]<arra[j+1])||(arra[j-1]>arra[j] && arra[j]>arra[j+1])) cnt++;
  }
    cout<<cnt<<endl;
}

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

int main() 
{
	int n;
	cin >> n;
	int x[n + 1], y[n + 1], mx = 0;
	map <pi, int> mp;
	for (int i = 1; i <= n; i++)
		cin >> x[i] >> y[i];
		
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (i != j) mp[{x[i] - x[j], y[i] - y[j]}]++;
	
	for (auto i: mp) mx = max(mx, i.second);
	cout << n - mx;
}

Measured memory_bytes: 384
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m],
    }
    let x = a.iter().sum::<i32>();
    if x <= n {
        println!("{}", n - x);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2232
n = int(input())
f = []
for _ in range(n):
    s = 0
    l = list(map(int, input().split()))
    for i in range(10):
        s += l[i]<<i
    f.append(s)
p = [list(map(int, input().split())) for _ in range(n)]
b = []
for i in range(1,1024):
    w = 0
    for j in range(n):
        idx = format(i & f[j], 'b').count('1')
        w += p[j][idx]
    b.append(w)
print(max(b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) ll x;cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll m,n,a;
	cin>>m>>n;
	a=m*n;
	cout<<a;
}  

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

/* inputs */
llui_t N;
vector<string> S;

int main() {
    cin >> N;

    vector<char> march = {'M', 'A', 'R', 'C', 'H'};
    vector<llui_t> march_n(5, 0);

	for(llui_t i=0; i<N; i++) {
		string s;
		cin >> s;
		S.push_back(s);
        for(int j=0; j<march.size(); j++) {
            if(s[0] == march[j]) {
                march_n[j] ++;
            }
        }
	}

    llui_t ans = 0;

    for(int i=0; i<march.size(); i++) {
        for(int j=i+1; j<march.size(); j++) {
            for(int k=j+1; k<march.size(); k++) {
                ans += march_n[i] * march_n[j] * march_n[k];
            }
        }
    }
	cout << ans << endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;
typedef pair<int, int> pii;
#define hashset unordered_set
#define hashmap unordered_map
#define unify(arr) arr.resize(unique(arr.begin(), arr.end()) - arr.begin())
#define getbit(x, i) (((x) >> (i)) & 1)

template <typename T>
vector<T> readvector(size_t size) {
    vector<T> res(size);
    for (size_t i = 0; i < size; ++i) {
        cin >> res[i];
    }
    return res;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
    return out;
}

int mylog(int n) {
    return 63 - __builtin_clzll(n);
}

inline int binPow(int x, int deg, int mod) {
    int ans = 1;
    for (int i = sizeof(deg) * CHAR_BIT - 1; i >= 0; i--) {
        ans *= ans;
        ans %= mod;
        if (getbit(deg, i)) ans *= x;
        ans %= mod;
    }
    return ans;
}

// ====================== END ======================
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e18;

int L[MAXN];
int W[MAXN];
int H[MAXN];

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    auto arr = readvector<int>(n);
    sort(arr.begin(), arr.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                ans += (arr[k] < arr[i] + arr[j] && arr[i] < arr[j] && arr[j] < arr[k]);
            }
        }
    }
    cout << ans << endl;
}

signed main() {
    // ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if (a < 10 && b < 10) {
			System.out.println(a * b);
		} else {
			System.out.println(-1);
		}
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 23124