akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    ll K;
    cin>>K;
    vector<ll> a(50,49);
    FOR(i,50){
        a[i]+=K/50;
        if(i<K%50){
            a[i]+=51-K%50;
        }else{
            a[i]-=K%50;
        }
    }
    print(50);
    FOR(i,49)cout<<a[i]<<" ";
    cout<<a[49]<<endl;
    return 0;
}


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

struct tree {
  int left;
  int right;
};

int main() {
  int n, k;
  cin >> n >> k;
  if ( (n-1)*(n-2)/2 < k ) { cout << -1 << endl; return 0; }
  vector<tree> tr;
  bool ch[n][n];
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      if ( i == j ) {
        ch[i][j] = true;
      } else {
        ch[i][j] = false;
      }
    }
  }
  int m = n-1;
  int now = (n-1)*(n-2)/2;
  for ( int i = 1; i < n; i++ ) {
    tree tmp;
    tmp.left = 0;
    tmp.right = i;
    tr.push_back(tmp);
    ch[0][i] = true;
    ch[i][0] = true;
  }
  
  for ( int i = 1; i < n; i++ ) {
    for ( int j = 1; j < n; j++ ) {
      if ( now == k ) { break; }
      if ( ! ch[i][j] ) {
        ch[i][j] = true;
        ch[j][i] = true;
        tree tmp;
        tmp.left = i;
        tmp.right = j;
        tr.push_back(tmp);
        m++;
        now--;
      }
    }
  }

  if ( now != k ) { m = -1; }
  cout << m << endl;
  for ( int i = 0; i < m; i++ ) {
    cout << tr[i].left+1 << ' ' << tr[i].right+1 << endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int h, w;
  cin >> h >> w;

  vector<vector<char>> vv(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> vv[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (vv[i][j] == '.') {
        int res = 0;
        for (int dir = 0; dir < 8; dir++) {
          int nh = i + dy[dir];
          int nw = j + dx[dir];

          if (nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
          if (vv[nh][nw] == '.') continue;
          if (vv[nh][nw] == '#') res++;
        }
        cout << res;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
P = [list(map(int, input().split())) for i in range(q)]

C = list(itertools.combinations_with_replacement([i+1 for i in range(m)], n))

ans = 0

for c in C:
    tmp = 0
    for p in P:
        if c[p[1]-1] - c[p[0]-1] == p[2]:
            tmp += p[3]
    ans = max(ans, tmp)

print(ans)


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

#define int unsigned long long int

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int a,b,c,x;
	cin>>a>>b>>c;
	x = min(b-1,c);
	cout<<(a*x)/b - a*(x/b);

	return 0;
}

Measured memory_bytes: 3636
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int t,n;
    static int s[1 << 20];
    fi>>t>>n;
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    vi ans;
    int h = max_element(s + 1,s + 1 + n) - s;
    ans.push_back(h);
    --s[h];
    while (-- t)
    {
        const int was = s[h];
        s[h] = -1;
        int nxt = max_element(s + 1,s + 1 + n) - s;
        if (s[nxt] <= 0)
            nxt = h;
        s[h] = was;
        --s[nxt];
        h = nxt;
        ans.push_back(h);
    }
    int fuck_rudi = 0;
    for (int i = 0;i < ans.size() - 1;++i)
        fuck_rudi += ans[i] == ans[i+1];
    fo << fuck_rudi << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3536
N, T = map(int, input().split())
t = list(map(int,input().split()))
total = 0
i=0
while i<N-1:
  if t[i+1]-t[i]<T:
    total+=t[i+1]-t[i]
  else:
    total+=T
  i+=1
total+=T
print(total)

Measured memory_bytes: 26836
import fractions

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

ans = abs(x - cities[0])
for i in range(1, n):
    d = abs(x - cities[i])
    ans = fractions.gcd(ans, d)

print(ans)


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int A[51];
signed main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    A[a]++;
    A[b]++;
  }
  rep(i,n){
    cout<<A[i]<<endl;
  }
}


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

using namespace std;

const int N=3e5+5;

long long n;
long long a;
long long b;
long long k;

const int mod=998244353;

inline int modexp(int a,int x) {
	int res=1;
	while (x) {
		if (x&1) {
			res=(long long)res*a%mod;
		}
		a=(long long)a*a%mod;
		x>>=1;
	}
	return res;
}

int fac[N];
int inv[N];

inline int c(int n,int m) {
	if (m>n) {
		return 0;
	}
	if (m<0) {
		return 0;
	}
	return fac[n]*(long long)inv[m]%mod*inv[n-m]%mod;
}

int main() {
	scanf("%lld %lld %lld %lld",&n,&a,&b,&k);
	fac[0]=1;
	for (int i=1;i<=n;++i) {
		fac[i]=(long long)fac[i-1]*i%mod;
	}
	inv[n]=modexp(fac[n],mod-2);
	for (int i=n-1;i>=0;--i) {
		inv[i]=(long long)inv[i+1]*(i+1)%mod;
	}
	int ans=0;
	for (int i=0;i<=n;++i) {
		if ((k-i*a)%b==0) {
			ans=(ans+c(n,i)*(long long)c(n,(k-i*a)/b)%mod)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N)
            cin >>
        A[i];

    int color[9] = {0};
    for (int i = 0; i < N; i++) {
        if (A[i] >= 3200)
            color[8]++;
        else
            for (int j = 0; j < 8; j++) {
                if (A[i] < 400 * (j + 1)) {
                    color[j]++;
                    break;
                }
            }
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if (color[i] != 0)
            ans++;
    }

    cout << max(1, ans) << " " << ans + color[8] << endl;

    return 0;
}

Measured memory_bytes: 256
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N,M = map(int,input().split())

A = [[] for i in range(N)]

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

B = [[0]*1 for i in range(M)]

for i in range(M):
    B[i] = int(input())


for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))



Measured memory_bytes: 6032
import numpy as np
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))
INF = float('inf')

N,K = inpl()

hlist = np.array(inpl())

dp = np.full(N,INF)

dp[0]=0

for i in range(1,N):
    s = max(0,i-K)
    dp[i] = np.min(dp[s:i]+abs(hlist[i]-hlist[s:i]))

print(int(dp[N-1]))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

struct UnionFind{
	vi par;
	vi rank;

	UnionFind(int n=1){
		init(n);
	}

	// n要素で初期化
	void init(int n=1){
		par.resize(n);
		rank.resize(n);
		REP(i, n){
			par[i]=i;
			rank[i]=0;
		}
	}

	// xの根を求める
	int find(int x){
		if(par[x]==x){
			return x;
		}
		else{
			return par[x]=find(par[x]);
		}
	}

	// xとyが属する集合を併合
	bool unite(int x, int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}
		if(rank[x]<rank[y]){
			par[x]=y;
		}
		else{
			par[y]=x;
			if(rank[x]==rank[y]){
				++rank[x];
			}
		}
		return true;
	}

	// xとyが同じ集合に属するか判定
	bool issame(int x, int y){
		return find(x)==find(y);
	}
};

ll INF=1e18;
bool used[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, m, x, y;
	ll a[114514];
	cin>>n>>m;
	REP(i, n){
		cin>>a[i];
	}
	UnionFind uf(n);
	REP(i, m){
		cin>>x>>y;
		uf.unite(x, y);
	}
	pair<ll, int> mi[114514];
	REP(i, n){
		mi[i]=make_pair(INF, i);
	}
	int cnt=0;
	REP(i, n){
		int par=uf.find(i);
		if(i==par){
			++cnt;
		}
		if(mi[par].first>a[i]){
			mi[par]=make_pair(a[i], i);
		}
	}
	if(cnt==1){
		cout<<0<<'\n';
		return 0;
	}
	ll ans=0;
	REP(i, n){
		int par=uf.find(i);
		if(i!=par){
			continue;
		}
		ans+=mi[par].first;
		a[mi[par].second]=INF;
	}
	sort(a, a+n);
	REP(i, cnt-2){
		if(a[i]==INF){
			cout<<"Impossible"<<'\n';
			return 0;
		}
		ans+=a[i];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
ll dp[100010], v[100010], n;
ll f(int pos){
    if(pos >= n) return 2e9;
    if(pos == n - 1) return 0;
    ll &ans = dp[pos];
    if(ans != -1) return ans;
    ans = 2e9;
    ans = min(ans, f(pos + 1) + abs(v[pos + 1] - v[pos]));
    ans = min(ans, f(pos + 2) + abs(v[pos + 2] - v[pos]));
    return ans;
}
int main(){
    fast;
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    cout << f(0) << "\n";
	return 0;
}


Measured memory_bytes: 9864
//ABC112B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int ans = n*(n-1)/2;
	cout << ans << endl;
}

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

int main(){
	string s;
	cin>>s;
	int n=s.size();
	if(n%2!=0){
		n-=1;
	}else{
		n-=2;
	}
	
	for(int i=n;i>=0;i=i-2){
		int ans=1;
		for(int j=0;j<i/2;j++){
			if(s[j]!=s[j+i/2])ans=0;
		}
		if(ans==1){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  long long N,X; cin>>N>>X;
  vector<long long> x(N); REP(i,N) cin>>x[i];
  x.push_back(X);
  
  SORT(x);
  vector<long long> mods(N);
  REP(i,N) {
    mods[i] = x[i+1] - x[i];
  }

  SORT(mods);
  bool isOK = true;
  long long ans;
  REP1(i,1000000000) {
    if(mods[0] % i == 0) {
      REP(j,N) {
        if(mods[j] % (mods[0] / i) != 0) {
          isOK = false;
          break;
        }
      }
      if(isOK) {
        ans = (mods[0] / i);
        break;
      }
      else isOK = true;
    }
  }

  cout<<ans<<endl;
}

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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((r * 100 + g * 10 + b) % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

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


int main(){
    const int N = 200000;
    char S[N];
    scanf("%s", S);

    int a_count = 0;
    long int sum = 0;
    int flag = 0;

    for (int i=0; i<N; i++){
        if (S[i] == 'A'){
            switch(flag){
                case 0:
                    flag = 1;
                    a_count++;
                    break;
                case 1:
                    a_count++;
                    break;
                case 2:
                    a_count = 1;
                    flag = 1;
                    break;
                case 3:
                    flag = 1;
                    a_count++;
                    break;
            }
        }
        else if (S[i] == 'B'){
            switch(flag){
                case 0:
                    break;
                case 1:
                    flag = 2;
                    break;
                case 2:  
                    a_count = 0;
                    flag=0;
                    break;
                case 3:
                    flag = 2;
                    break;
            }
        }
        else if (S[i] == 'C'){
            switch(flag){
                case 0:
                    break;
                case 1:
                    a_count = 0;
                    flag = 0;
                    break;
                case 2:
                    sum += a_count;
                    flag = 3;  
                    break;
                case 3:
                    a_count = 0;
                    flag = 0;
                    break;
            }
        }
        else{
            a_count = 0;
            flag = 0;
        };
    }
    printf("%ld", sum);
    return 0;
}

Measured memory_bytes: 384
// Problem : A - Pay to Win
// Contest : AtCoder - AtCoder Grand Contest 044
// URL : https://atcoder.jp/contests/agc044/tasks/agc044_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

unsigned long long a, b, c, d;
map<unsigned long long, unsigned long long> memo;


unsigned long long cost(unsigned long long n) {
    if (n == 0) return 0;
    if (n == 1) return d;
    if (memo.find(n) != memo.end()) return memo[n];
    unsigned long long score = cost(n / 5) + c * (n >= 5) + d * (n % 5);
    if (n % 5 != 0) score = min(score, cost((n + 5) / 5) + c + d * (5 - n % 5));
    score = min(score, cost(n / 3) + b * (n >= 3) + d * (n % 3));
    if (n % 3 != 0) score = min(score, cost((n + 3) / 3) + b + d * (3 - n % 3));
    score = min(score, cost(n / 2) + a * (n >= 2) + d * (n % 2));
    if (n % 2 != 0) score = min(score, cost((n + 2) / 2) + a + d * (2 - n % 2));
    if (score / d > n) score = d * n;
    memo[n] = score;
    return score; 
}

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

    long t;
    cin >> t;
    while (t--) {
        memo.clear();
        unsigned long long n;
        cin >> n >> a >> b >> c >> d;
        cout << cost(n) << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a;
	cin>>a;
	long long b=a;
	a=1;
	for(int i=1;i<b+1;i++){
		a*=i;
		a%=1000000007;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int x, int y) {
    if (y == 0)
        return x;
    else    
        return gcd(y, x%y);
}

int main() {
    int k;  cin >> k;
    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                int g = gcd(i, j);
                g = gcd(g, l);
                ans += g;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include<cmath>
using namespace std;
#define ll long long
#define ld long double

int main(void){
  int a,b;
  string s;
  
  cin>>a>>b;
  cin>>s;
  if(s[a]!='-'){
      cout<<"No";
      return 0;
  }

  for(int i=0;i<s.length();i++){
      if(i!=a && (s[i]>'9' || s[i]<'0')){
          cout<<"No";
          return 0;
      }
  }
  
  cout<<"Yes";
    
}


Measured memory_bytes: 3096
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long K;
        Scanner sc = new Scanner(System.in);
        K = sc.nextLong();
        Long bank = 100L;
        int toshi = 0;
        while( bank < K )
        {
            bank = (long)(bank * 1.01);
            toshi++;
        }
        System.out.println(toshi);
    }
}


Measured memory_bytes: 35856
import collections
A,B=map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a%b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(list(collections.Counter(prime_factorize(gcd(A,B))).keys()))+1)


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

int main() {
  int N,a,k,c;
  a=0,k=0,c=0;
  cin >>N;
  vector<int> h(N),hh(N);
  for(int i=0;i<N;i++){
    cin >>h[i];
    hh[i]=h[i];
  }
  sort(hh.begin(),hh.end());
  for(int i=1;i<=hh[N-1];i++){
    for(int j=0;j<N;j++){
      if(h[j]<=(i-1)){
        a=1;
      }
      else if(a==1){
        k++;
        a=0;
      }
    }
    if(h[0]<=(i-1)){
      c+=k;
    }
    else{
      c=c+k+1;
    }
    a=0;
    k=0;
  }
  cout <<c<<endl;

}

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

int main(){
  ll n;
  while(cin>>n&&n){
    ll ans=0;
    for(ans=100000;;ans--){
      // (a+(a+ans-1) )/ 2 * ans == n
      // ( a*2+ans-1 ) * ans == n*2
      // a*2*ans + ans*ans - ans == n*2
      // a*2*ans = (n*2 - ans*ans + ans)
      ll a=(n*2-ans*ans+ans)/2/ans;

      if(0<a&& (a*2+ans-1)*ans==n*2 ){
        cout<<a<<' '<<ans<<endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int sum1[100009];
int sum2[100009];
main(){
	int n,a,b;
	cin>>n>>a>>b;
	int A[n];
	r(i,n)cin>>A[i];
	int sum=0;
	for(int i=1;i<n;i++){
		int t=A[i]-A[i-1];
		if(t*a<b)sum+=t*a;
		else sum+=b;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<string> W(N); REP(i, N) cin >> W[i];
	map<string, int> mp;
	REP(i, N) {
		if (mp[W[i]] == 0){
			mp[W[i]] = 1;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	REP(i,N-1){
		if(W[i][W[i].size()-1]!=W[i+1][0]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
//============================================================================
// Name        : aaaa.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i;
  cin >> i;
  
  cout << N - (i - 1) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b == c){
		cout << "Yes" << endl;
	}
	else if(b + c == a){
		cout << "Yes" << endl;
	}
	else if(a + c == b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

const int maxn = 1e5 + 5;

int a[3*maxn];

int main()
{
    int n;

    scanf("%d",&n);

    for (int i = 0;i < 3*n;i++)
        scanf("%d",&a[i]);

    sort(a,a+3*n);

    long long sum = 0;
    int cnt = 0;

    for (int i = 3*n - 2;i >= 0;i -= 2)
    {

        cnt++;

        sum += a[i];

        if (cnt == n) break;
    }

    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if(X == 1) {
        ans += 300000;
    } else if (X == 2) {
        ans += 200000;
    } else if (X == 3) {
        ans += 100000;
    }
    if(Y == 1) {
        ans += 300000;
        if(X == 1) {
            ans += 400000;
        }
    } else if(Y == 2) {
        ans += 200000;
    } else if(Y == 3) {
        ans += 100000;
    }
    cout << ans << endl;
}

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int d, w, h;
  while (cin >> d >> w >> h, d) {
    if (d < w) swap(d, w);
    if (w < h) swap(w, h);
    if (d < w) swap(d, w);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int r;
      cin >> r;
      cout << (w * w + h * h < 4 * r * r ? "OK" : "NA") << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>

int main(void){
	int i,n,x;
	n=0;
	scanf("%d",&n);
	x=100000;
	for(i=0;i<n;i++){
	x=x*1.05;
	if(x%1000 != 0){
	x=x-x%1000+1000;
	}
	}
	printf("%d\n",x);
return 0;
}

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

int main(void){
  int d, sum;
  
  while(cin >> d){
    sum = 0;
    for(int i = 0 ; i < 600 ; i+=d){
      sum += i*i*d;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int x,y,z=1;
    x=b;
    z=x;
    for (y=1;y<a;y++)
    {
      z*=(x-1);
    }
    printf("%d",z);
}


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

using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
    int n, d1, d2, count = 0;
    bool ans = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d1 >> d2;
        if (d1 == d2) {
            count++;
            if (count == 3) {
                ans = true;
            }
        }
        else {
            count = 0;
        }

    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

size_t sub2(string const& xy, size_t i, string const& z, size_t m) {
  size_t newm = max(xy.size(), i + z.size());
  if (newm >= m) {
    return m;
  }
//  cerr << "sub2(" << xy << ",i=" << i << ",z=" << z << ",m=" << m << endl;
  for (size_t j = i; j < min(xy.size(), i + z.size()); j++) {
    if (xy[j] != z[j - i] && xy[j] != '?' && z[j - i] != '?') {
      return m;
    }
  }
  return newm;
}

size_t sub1(string const& x, string const& y, size_t i, string const& z, size_t m) {
  if (max(x.size(), i + max(y.size(), z.size())) >= m) {
    return m;
  }
//  cerr << "sub1(" << x << "," << y << ",i=" << i << ",z=" << z << ",m=" << m << endl;
  string xy = (i + y.size() > x.size() ? x + y.substr(x.size() - i) : x);
//  cerr << "xy=" << xy << endl;
  for (size_t j = i; j < min(x.size(), i + y.size()); j++) {
    if (x[j] != y[j - i]) {
      if (x[j] == '?') {
        if (y[j - i] != '?') {
          xy[j] = y[j - i];
        }
      } else if (y[j - i] != '?') {
        return m;
      }
    }
  }
//  cerr << "xy=" << xy << endl;
  for (size_t k = i; k < xy.size(); k++) {
    m = sub2(xy, k, z, m);
  }
  return m;
}

size_t sub(string const& x, string const& y, string const& z, size_t m) {
  for (size_t i = 0; i < x.size() + 1; i++) {
    m = sub1(x, y, i, z, m);
  }
  return m;
}

int main() {
  string a, b, c; cin >> a >> b >> c;
  size_t m = a.size() + b.size() + c.size();
  m = sub(a, b, c, m);
  m = sub(a, c, b, m);
  m = sub(b, a, c, m);
  m = sub(b, c, a, m);
  m = sub(c, a, b, m);
  m = sub(c, b, a, m);
  cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 640
import numpy as np
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n,wmax=IL()
dp=np.full(n*pow(10,3)+1,wmax+1,dtype=int)
dp[0]=0
for i in range(n):
    w,v=IL()
    dp[v:]=np.minimum(dp[v:],dp[:-v]+w)
for i in range(n*pow(10,3)+1):
    if dp[i]<=wmax:
        ans=i
print(ans)

Measured memory_bytes: 14916
#include <stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int point[N];
	int rank[N];
	int i,j;
	int a=0,b=0,c=0,d=0;
	for(i=0;i<N;i++){
		point[i]=0;
		rank[i]=0;
	}
	int play=(N*N-N)/2;
	for(i=0;i<play;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d){
			point[a-1]=point[a-1]+3;
		}
		else if(c==d){
			point[a-1]=point[a-1]+1;
			point[b-1]=point[b-1]+1;
		}
		else{
			point[b-1]=point[b-1]+3;
		}
	}
	int max,count;
	for(i=1;i<=N;i++){
		max=0;
		count=0;
		for(j=0;j<N;j++){
			if(max<point[j]){
				max=point[j];
			}
		}
		for(j=0;j<N;j++){
			if(max==point[j]){
				rank[j]=i;
				count=count+1;
				point[j]=-1;
			}
		}
		i=i+count-1;
	}
	for(i=0;i<N;i++){
		printf("%d\n",rank[i]);
	}
	return 0;
}
				

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, Y);

  REP(i, N + 1) {
    REP(j, N + 1 - i) {
      int zi = N - i - j;
      if (i * 10000 + j * 5000 + zi * 1000 == Y) {
	printf("%d %d %d\n", i , j, zi);
	return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}



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

#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";
#define L_MAX 1e16


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

/*
#ifndef ONLINE_JUDGE
freopen("inpute.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
*/

int t=1, x = 0;
//cin>>t;
while(t--)
{ 
  int a, b, c;cin>>a>>b>>c;
  int k;cin>>k;
  while(a>=b && k>0)
  {
    b*=2;k--;
  }
  while(b>=c && k>0)
  {
    c*=2;k--;
  }
  if(c>b && b>a)
  {
    cout<<"Yes";
  }
  else cout<<"No";
} 


return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
bool dp[1001][1001];


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","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  int n;
  while(cin>>n,n){
    vector<pair<int,int> > v;
    int sum=0,maxe=0;
    int sumw=0;
    int maxw=0;
    vector<int> vv;
    for(int i=0;i<n;i++){
      int a,b;cin>>a>>b;
      v.push_back({a,b});
      vv.push_back(b);
      sum+=a;
      if(maxe<a){
        maxe=a;
        maxw=i;
      }
      sumw+=b;
    }
    if(maxe<=sum-maxe){
      cout<<sum+sumw<<endl;
    }else{
      int ans=maxe*2+v[maxw].se;
      int nokori=maxe-(sum-maxe);
      vv.erase(vv.begin()+maxw);
      sort(vv.begin(),vv.end());
      int vvsum=0;
      for(int i=0;i<(int)vv.size();i++)vvsum+=vv[i];
      for(int i=0;i<=(int)vv.size();i++)for(int j=0;j<=nokori;j++)dp[i][j]=0;
      dp[0][0]=1;
      for(int i=0;i<(int)vv.size();i++){
        for(int j=0;j<=nokori;j++){
          if(dp[i][j]==0)continue;
          if(j+vv[i]<=nokori){
            dp[i+1][j+vv[i]]=1;
          }
          dp[i+1][j]=1;
        }
      }
      for(int i=nokori;i>=0;i--){
        if(dp[vv.size()][i]){
          cout<<ans+vvsum-i<<endl;
          break;
        }
      }
    }
  }  
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}








Measured memory_bytes: 4156
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] N = sc.next().toCharArray();
    boolean ans = (N[0] == N[1] && N[1] == N[2])
      || (N[1] == N[2] && N[2] == N[3]);
    System.out.println(ans ? "Yes" : " No");
  }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()

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

ll n;
map<ll,ll> mp;

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

	cin>>n;
	REP(i,n) {
		ll a; cin>>a; a--;
		mp[a]++;
	}
	ll sum=0;
	for(auto x:mp) {
		if(x.second%2==1) sum++;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 6528
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

        if (in % 2 == 0 && in % 4 != 0) {
            a++;
        } else if (in % 4 == 0) {
            b++;
        } else {
            c++;
        }
    }

    bool ans = false;
    if (a == 0) {
        if (c <= b + 1) {
            ans = true;
        }
    } else {
        if (c <= b) {
            ans = true;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    E = [[0]*H for i in range(W)]
    for i in range(N):
        (x, y) = map(int, raw_input().split())
        E[x-1][y-1] = 1
    (S, T) = map(int, raw_input().split())

    Max = 0
    for i in range(W-S+1):
        for j in range(H-T+1):
            Sum = 0
            for k in range(S):
                for l in range(T):
                    Sum += E[i+k][j+l]
            if Sum > Max:
                Max = Sum
    print Max
    N = int(raw_input())

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

int main(void) {
  int x;
  cin >> x;
  
  int hap = 0;
  hap = (x / 500) * 1000 + ((x % 500) / 5) * 5;
  
  cout << hap << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
(A, B) = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

set_1 = P.select do |p|
  p <= A
end
set_2 = P.select do |p|
  p > A && p <= B
end
set_3 = P.select do |p|
  p > B
end

puts [set_1.size, set_2.size, set_3.size].min

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

ll poww(ll a,ll b){
  ll ans=1;
  while(b>0){
    if(b%2==1) ans=(ans*a);
    a=(a*a);
    b=b/2;
  }
  return ans;
}

/*-----------------------------------------------------------------------*/

ll dp[401][401];

int main(){
   fastt;

   ll n;
   cin>>n;

   vector <ll> a(n);
   vector <ll> b(n);

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

   b[0]=a[0];

   for(ll i=1;i<n;i++)
   	  b[i]=b[i-1]+a[i];

   for(ll siz=2;siz<=n;siz++)
   	   for(ll start=0;start+siz-1<n;start++){
   	   	   dp[start][start+siz-1]=1e18;
   	   	     for(ll pointr=start;pointr<start+siz-1;pointr++)
   	   	     	dp[start][start+siz-1]=min(dp[start][pointr]+dp[pointr+1][start+siz-1]+(start>0?b[start+siz-1]-b[start-1]:b[start+siz-1]),dp[start][start+siz-1]);
   	   }

   cout<<dp[0][n-1]<<endl;

   return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,k;
  int ans=1;
  cin>>n>>k;
  rep(i,n){
    ans+=min(ans,k);
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
	ll n,k,s;
	cin>>n>>k>>s;

	if(s==1e9){
		forn(i,k) cout<<(1000000000)<<" ";
		for(ll i=k;i<n;i++) cout<<(1000000000-1)<<" ";
	}
	else{
		forn(i,k) cout<<s<<" ";
		for(ll i=k;i<n;i++) cout<<(1000000000)<<" ";
	}
}

Measured memory_bytes: 1280
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long ll;
using namespace std;
int N,A,B;
int main() {
	cin>>N>>A>>B;
	if(N*A<B){
		cout<<N*A;
	}else{
		cout<<B;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        int K = Int ();
        char[] S = Chars ();

        int ret = 0;
        int num = 1;
        int tmp = 1;
        for (int i = 0; i < N - 1; i++) {
            if (S[i] == S[i + 1]) {
                tmp++;
            } else {
                ret += tmp - 1;
                tmp = 1;
                num++;
            }
        }
        ret += tmp - 1;

        Console.WriteLine (Math.Min ((ret + K * 2), N - 1));
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 14164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int N, M;
vector<vector<int>>G;
int dp[100100];
int rec(int v) {
	if (dp[v] != -1)return dp[v];//既に更新済み
	int res = 0;
	for (int i = 0; i < G[v].size();++i) {
		res = max(res, rec(G[v][i]) + 1);
	}
	return dp[v] = res;
}
int main() {
	cin >> N >> M;
	G.assign(N, vector<int>());//N個のvector<int>()を代入
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
	}
	for (int v = 0; v < N; ++v) {
		dp[v] = -1;
	}
	int res = 0;
	for (int v = 0; v < N; ++v) {
		res = max(res, rec(v));
	}
	cout << res << endl;
	return 0;
}

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

int x,k,y,n;

signed main()
{
	cin>>n>>k>>x>>y;
	if (n>=k)  cout<<k*x+(n-k)*y<<endl;
	else cout<<n*x<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int x=0,y=0;
    int flag=1;
    int n,a,b;
    scanf("%d",&n);
    int T=0,t;
    while(n--)
    {
        scanf("%d%d%d",&t,&a,&b);
        if(flag)
        {
            int dx=abs(a-x);
            int dy=abs(b-y);
            int dt=(t-T)-(dx+dy);
            if(dt>=0&&dt%2==0)
            {
                T=t;
                x=a;
                y=b;
                continue;
            }
            else
            {
                flag=0;
            }
        }

    }
    if(flag)
       printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long N,numA=1,numB=1,numC=1;
    long long ans = 0;
    
    cin >> N;
    
    if(N!=1){
        for(int n=0;n<N;n++){
            numA = numA*8;
            numB = numB*9;
            numC = numC*10;
            if(numA>1000000007) numA = numA%1000000007;
            if(numB>1000000007) numB = numB%1000000007;
            if(numC>1000000007) numC = numC%1000000007;
        }
        ans = numC+2*1000000007 -2*numB + numA;
        if(ans>1000000007) ans = ans % 1000000007;
        
        cout << ans;
        
    }else{
        cout << 0;
    }
    
    cout << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int dp[100][100];
int main(void){
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            dp[i][j]=(i==j?0:1<<29);
        }
    }
    int n,m;
    cin>>n>>m;
    int s[m],t[m],u[m];
    for(int i=0;i<m;i++){
        cin>>s[i]>>t[i]>>u[i];
        s[i]--,t[i]--;
        dp[s[i]][t[i]]=u[i];
        dp[t[i]][s[i]]=u[i];
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<m;i++){
        if(dp[s[i]][t[i]]<u[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);
    unsigned long int A[n][m], B[m][l], C[n][l];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%lu", &A[i][j]);
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            scanf("%lu", &B[i][j]);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            C[i][j] = 0;
            for (int k = 0; k < m; k++) {
                C[i][j] = C[i][j] + A[i][k] * B[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            printf("%lu", C[i][j]);
            if (j + 1 < l) {
                printf(" ");
            }
        }
        printf("\n");
    }
    
}


Measured memory_bytes: 2112