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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct cumulative_sum {
    int n;
    T ZERO;
    std::vector<T> data;
    template<typename I> cumulative_sum(I begin, I end, T ZERO = T())
        : n(end - begin), ZERO(ZERO), data(n + 1) {
        std::copy(begin, end, data.begin() + 1);
        for (int i = 0; i < n; i++) { data[i + 1] += data[i]; }
    }
    T get_sum(int l, int r) const {
        if (l >= r || l > n || r < 0) { return ZERO; }
        if (l < 0) { l = 0; }
        if (r > n) { r = n; }
        return data[r] - data[l];
    }
};

int N, Q;
string S;
int D[1100000], M[1100000], C[1100000];
signed main() {
    cin >> N >> S;
    rep(i, N) {
        D[i] = S[i] == 'D';
        C[i] = S[i] == 'C';
        M[i] = S[i] == 'M';
    }
    cumulative_sum<int> Dcs(D, D + N), Mcs(M, M + N), Ccs(C, C + N);
    //oppaimankomankochinpo
    cin >> Q;
    rep(i, Q) {
        int k, ans = 0;
        cin >> k;
        rep(j, N) {
            if (S[j] == 'D') { ans -= Ccs.get_sum(j, j + k) * Mcs.get_sum(0, j); }
            if (S[j] == 'C') { ans += Dcs.get_sum(j - k + 1, j + 1) * Mcs.get_sum(0, j); }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 49796
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[400005][2];
int s[100005];
int main(){
	int i,j,k;
	int n,r,l;
	int d=0;
	int t=0;
	int x=0;
	int nn=0;
	int f=0;
	memset(a,0,sizeof(a));
	memset(s,0,sizeof(s));
	cin>>n>>r>>l;
	nn=1;
	while(nn<n){
		nn*=2;
	}
	nn--;
	for(i=0;i<n;i++){
		a[nn+i][1]=i;
	}
	d=nn;
	while(d!=0){
		d--;
		if(a[d*2+1][0]<a[d*2+2][0]){
			a[d][0]=a[d*2+2][0];
			a[d][1]=a[d*2+2][1];
		}else{
			a[d][0]=a[d*2+1][0];
			a[d][1]=a[d*2+1][1];
		}
	}
	for(i=0;i<r;i++){
		cin>>d>>t>>x;  
		s[f]+=t;
		d--;
		d+=nn;
		a[d][0]+=x;
		while(d!=0){
			d=(d-1)/2;
			if(a[d*2+1][0]<a[d*2+2][0]){
				a[d][0]=a[d*2+2][0];
				a[d][1]=a[d*2+2][1];
			}else{
				a[d][0]=a[d*2+1][0];
				a[d][1]=a[d*2+1][1];
			}
		}
		f=a[0][1];
		s[f]-=t;
	}
	s[f]+=l;
	nn=0;
	for(i=0;i<n;i++){
		if(s[nn]<s[i])nn=i;
	}
	nn++;
	cout<<nn<<endl;
}
		

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int ans = 0;
  int diff = INF;
  int a = 0;
  rep (i, N) a += i + L;

  rep (i, N) {
    int b = 0;
    rep (j, N) if (i != j) b += j + L;
    if (diff > abs(a - b)) {
      diff = abs(a - b);
      ans = b;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in(), c = in(), d = in();
	cout << (
		a + b > c + d ? "Left"
		: a + b == c + d ? "Balanced"
		: "Right") << endl;
}

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

typedef pair< int, int > Pi;
const int S = 100000;
const int64 INF = 1LL << 55;
 

int Dijkstra(int s, int g, vector< int64 >& d, vector< int64 >& c) { //s??????g???????????????
  typedef pair< int, int > Pi;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  vector< int > min_cost;
  min_cost.resize(300001, -1);
  que.push( Pi( 0, s));
  min_cost[s] = 0;
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.second == g) return p.first;
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < d.size(); i++){
      int to = p.second + d[i];
      if(to <= 300000 && (min_cost[to] == -1 || p.first + c[i] < min_cost[to])){
        min_cost[to] = p.first + c[i];
        que.push( Pi( min_cost[to], to));
      }
      to = p.second - d[i];
      if(to >= 0 && (min_cost[to] == -1 || p.first + c[i] < min_cost[to])){
        min_cost[to] = p.first + c[i];
        que.push( Pi( min_cost[to], to));
      }
    }
  }
  return -1;
}

int main() {
  int N, x;
  cin >> N >> x;
  vector< int64 > d(N), c(N);
  for(int i = 0; i < N; i++){
    cin >> d[i] >> c[i];
  }
  cout << Dijkstra(S, S + x, d, c) << endl;
}


Measured memory_bytes: 7096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll fa[2 * MAX + 2];
ll modex(ll a, ll b)
{
    ll ans = 1;
    for(; b > 0; b >>= 1, a = (a * a) % mod)
        if(b & 1)
            ans = (ans * a) % mod;
    return ans;
}
ll ncr(ll n, ll r)
{
    if(n < r || r < 0)
        return 0;
    ll ans = (fa[n] * modex(fa[r], mod - 2)) % mod;
    ans = (ans * modex(fa[n - r], mod - 2)) % mod;
    return ans;
}
ll f(ll r, ll c)
{
    ll ans = (mod - r) % mod;
    for(ll i = 1; i <= r; i++)
        ans = (ans + ncr(i + c + 1, c)) % mod;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll r1, r2, c1, c2, i;
    fa[0] = 1;
    for(i = 1; i <= 2 * MAX + 1; i++)
        fa[i] = (fa[i - 1] * i) % mod;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = (f(r2, c2) - f(r1 - 1, c2) + mod) % mod;
    ans = (ans - f(r2, c1 - 1) + mod) % mod;
    ans = (ans + f(r1 - 1, c1 - 1)) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
N = int(input())
A = list(map(int, input().split()))

s = 0
for i in range(N):
    s += A[i]

ans = 0
for i in range(N-1):
    s -= A[i]
    p = A[i] * s
    p %= (10 ** 9 + 7)
    ans += p
print(ans%(10 ** 9 + 7))

Measured memory_bytes: 31436
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

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

int main(){
    int n,m;cin>>n>>m;
    vector<int>e[n];
    rep(i,1,m){
        int a,b;cin>>a>>b;
        a--;b--;
        e[a].pb(b);e[b].pb(a);
    }
    int q;cin>>q;
    int query[q][3];
    rep(i,0,q-1){
        rep(j,0,2)cin>>query[i][j];
        query[i][0]--;
    }
    int color[n];memset(color,0,sizeof(color));
    int neg[n];rep(i,0,n-1)neg[i]=-1;
    for(int i=q-1;i>=0;i--){
        int v=query[i][0];
        int d=query[i][1];
        int c=query[i][2];
        queue<i_i>q;
        q.push(i_i(v,d));
        
        while(!q.empty()){
            i_i t=q.front();
            q.pop();
            int nowv=t.first,nowd=t.second;
            if(color[nowv]==0)color[nowv]=c;
            if(nowd<=0)continue;
            for(auto x:e[nowv]){
                if(neg[x]<nowd-1){
                    q.push(i_i(x,nowd-1));
                    neg[x]=nowd-1;
                }
            }
        }
    }
    rep(i,0,n-1){
        cout<<color[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 9472
S = input()

ans = ''
L, R = int(S[:2]), int(S[2:])
if L >0 and L < 13:
    if R > 0 and R < 13:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if R > 0 and R < 13:
        ans = 'YYMM'
    else:
        ans = 'NA'
        
print("{}".format(ans))  

Measured memory_bytes: 3060
'use strict'

const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0].split(' ')[0])
    const M = parseInt(input[0].split(' ')[1])
    let arr = input.slice(1, N + 1)
    let points = input.slice(N + 1, M + N + 1)

    const parse = (v) => {
        let temp = v.split(' ').map(vv => parseInt(vv))
        return {
            x: temp[0],
            y: temp[1]
        }
    }
    arr = arr.map(parse)
    points = points.map(parse)


    let indexArr = []
    arr.forEach((v, i) => {
        let minDist = 1000000000
        let index = 0
        points.forEach((w, j) => {
            let dist = Math.abs(v.x - w.x) + Math.abs(v.y - w.y)
            if(dist < minDist){
                minDist = dist
                index = j
            }
        })
        indexArr.push(index)
    })

    indexArr.forEach(v => console.log(v + 1))
}

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

Measured memory_bytes: 7500
x,k,d=map(int,input().split())
x=abs(x)
res=10**18
if k*d<=x:
    res=x-k*d
else:
    k-=x//d
    x=x%d
    if k%2==0:
        res=x
    else:
        res=d-x
print(res)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll n;
ll t[]={0,2,5,5,4,5,6,3,7,6};
map<ll,ll> my;
string dp[10005];

string max_str(string a,string b){
    if(a.length()>b.length())return a;
    if(a.length()<b.length()) return b;

    for(ll i=0;a[i];i++){
        if(a[i]>b[i])return a;
        if(a[i]<b[i]) return b;
    }
    return a;

}

string solve(ll i){
    // Largest number that can be formed using i matchsticks
    if(i<0) return "";
    if(i==0) return "0";

    if(dp[i]!="-1"){
        return dp[i];
    }
    string ans="";
    ll cnt1=0;
    for(ll j=1;j<=9;j++){
        if(my.count(j)){
            string tt=solve(i-t[j]);
            if(tt=="") continue;
            cnt1++;
            if(tt=="0"){
                string x;
                x.push_back('0'+j);
                ans=max_str(ans,x);
                continue;
            }
            string tt1=tt;tt1.push_back('0'+j);
            string s1=tt1;
            ans=max_str(ans,s1);
            string temp;
            temp.push_back('0'+j);
            for(char c:tt) temp.push_back(c);
            ans=max_str(ans,temp);
        }
    }
    if(cnt1==0){
        return dp[i]="";
    }
    return dp[i]=ans;
}

int main() {
    
    
    cin>>n;
    for(ll i=0;i<=10000;i++){
        dp[i]="-1";
    }
    ll m;
    cin>>m;
    ll a[m];
    for(ll i=0;i<m;i++){
        cin>>a[i];
        my[a[i]]++;
    }

    cout<<solve(n)<<endl;



}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);
  int minDiff = INT_MAX;
  int res = 0;
  for (int i = -5; i <= 105; i++) {
    if (find(p.begin(), p.end(), i) != p.end()) {
      continue;
    }
    int diff = abs(i - x);
    if (diff < minDiff) {
      res = i;
      minDiff = diff;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
signed main(){
    int n;cin>>n;
    vector<P>V(n);
    rep(i,n){
        int x,y;cin>>x>>y;
        V[i]=make_pair(x,y);
    }
    sort(all(V));
    long double sum=0;
    do{
        rep(i,n-1){
            int x0=V[i].F,x1=V[i+1].F,y0=V[i].S,y1=V[i+1].S;
            sum+=sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
        }
    }while(next_permutation(all(V)));
    rep(i,n)sum/=(i+1);
    cout<<fixed<<setprecision(10);
    cout<<sum<<endl;
    
}
        

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;

int n;
string s;
void solve(){
    cin >> n >> s;
    int w=0;
    for(char i:s)w+=i=='W';
    int i=n-1,cn=0,reds=0;
	while(cn<w) {
		reds+=s[i]=='R';
		cn++ , i--;
	}
	cout << reds << "\n";
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    bool can=false;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if((n-i)*j+(m-j)*i==k)can=true; 
        }
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N;
	cin >> N;
	vi A(N);
	vi B(N);
	for(int i=0; i<N; i++){
		cin >> A[i];
		B[A[i]-1]=i+1;
	}

	for(int i=0; i<N; i++){
		cout << B[i] << " ";
	}
	cout << endl;

	return 0;
}

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

#define int long long int
#define endl "\n"

int32_t main(){
	int n, w;
	cin >> n >> w;

	vector<int> wt(n), val(n);

	for(int i = 0 ; i< n ; i++){
		cin >> wt[i] >> val[i];
	}

	vector<int> dp(w+1);

	for(int i = 0 ; i < n ; i++){
		for(int j = w; j >=wt[i] ;j--){
			dp[j] = max(dp[j], val[i] + dp[j-wt[i]]);
		}
	}

	cout <<dp[w] << endl;

}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  long long K;
  cin>>N>>K;

  vector< pair<int,int> > V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i).first>>V.at(i).second;
  }
  sort(V.begin(),V.end());

  long long count=0;
  for(int i=0;i<N;i++){
    count += V.at(i).second;
    if (count>=K){
      cout<<V.at(i).first<<endl;;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 100;
typedef long long ll;


void solve(ll x){
    ll money = 100;
    int n=0;
    double money_tmp;
    money_tmp = money;
    while (x>money){
        money_tmp = money;
        money_tmp = money_tmp *1.01;
        money = money_tmp;
        n = n+1;
    }
    cout << n << endl;
}


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


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll w, l, d, n;
  string name;
  bool ch = false;
  while(cin >> n, n) {
    vector<pair<int, string> > result;
    if(ch) cout << endl;
    rep(i, n) {
      cin >> name >> w >> l >> d;
      ll pt = (3 * w + d) * 100 + 99 - i;
      result.pb(make_pair(pt, name));
    }
    sort(result.begin(), result.end());
    reverse(result.begin(), result.end());
    rep(i, n) {
      cout << result[i].second << "," << result[i].first / 100 << endl;
    }
    ch = true;
  }
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j=0,k;
    string a;
cin>>a;
string ::iterator it=a.begin();
    for(i=0;i<a.size()-1;i++)
    {
        if(a[i]==a[i+1])
        {
            j++;
            cout<<"Bad\n";
            return 0;
        }
    }
    cout<<"Good\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll x,l;
        cin>>x>>l;
        v.push_back({x+l,x-l});
    }

    ll ans=0,s=-1LL<<60;
    sort(all(v));
    rep(i,n){
        if(s<=v[i].second){
            ans++;
            s=v[i].first;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 5348
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;

		while(true) {
			H = sc.nextInt();
			W = sc.nextInt();

			if(H == 0 && W == 0) {
				sc.close();
				break;
			}

			for(int hight_count = 0; hight_count < H; hight_count++) {
				for(int witdh_count = 0; witdh_count < W; witdh_count++) {
					if(hight_count % 2 == 0 && witdh_count % 2 == 0) {
						System.out.printf("#");
					} else if(hight_count % 2 == 0 && witdh_count % 2 == 1) {
						System.out.printf(".");
					} else if(hight_count % 2 == 1 && witdh_count % 2 == 0) {
						System.out.printf(".");
					} else if(hight_count % 2 == 1 && witdh_count % 2 == 1) {
						System.out.printf("#");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



Measured memory_bytes: 63184
A = list(map(int,input().split()))
B = []

for i in range(0,3):
    for j in range(0,3):
        if j>i:
            temp = A[i] + A[j]
            B.append(temp)
            
if B[0] == A[2] or B[1] == A[1] or B[2] == A[0]:
    print('Yes')
else:
    print('No')

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

int main() {
	string s; cin >> s;
	reverse(s.begin(), s.end());
	bool flag;

	while (true) {
		if (s.compare(0, 7, "remaerd", 0, 7) == 0)s.erase(0, 7);
		else if (s.compare(0, 6, "resare", 0, 6) == 0)s.erase(0, 6);
		else if (s.compare(0, 5, "maerd", 0, 5) == 0)s.erase(0, 5);
		else if (s.compare(0, 5, "esare", 0, 5) == 0)s.erase(0, 5);
		else if (s.empty()) { flag = true; break; }
		else { flag = false; break; }
	}
	puts(flag ? "YES" : "NO");
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll v[50];
ll eval(ll a, ll b) {
	bool neg = a < 0;
	neg ^= b < 0;
	a = abs(a);
	b = abs(b);
	if (neg)
		return 0;
	return (a + b - 1) / b;
}
bool check(ll m) {
	ll to = m;
	for (ll it = max(0ll, m - 50); it <= to; ++it) {
		m = it;
		ll total = 0;
		for (int i = 0; i < n; ++i) {
			ll need = eval(n - 1 - v[i] - m, -n - 1);
			total += need;
		}
		if (total <= m)
			return true;
	}
	return false;
}
int calc() {
	vector<int> v(::v, ::v + n);
	int res = 0;
	while (true) {
		sort(v.begin(), v.end());
		if (v.back() < n)
			break;
		++res;
		for (int i = 0; i + 1 < v.size(); ++i)
			++v[i];
		v.back() -= n;
	}
	return res;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", v + i);
	if (0) {
		for (int i = 0; i < pow(10, n); ++i) {
			if (i%n != 1)
				continue;
			int x = i;
			for (int j = 0; j < n; ++j) {
				v[j] = x % 10;
				x /= 10;
				cout << v[j] << " ";
			}
			cout << "= ";
			cout << calc() << endl;
		}
		return 0;
	}
	//cout << calc() << endl;
	ll l = 0, r = 1e18 + 1, m, res = -1;
	while (l <= r) {
		m = (l + r) / 2;
		if (check(m)) {
			res = m;
			r = m - 1;
		}else
			l = m + 1;
	}
	assert(res != -1);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>

long long read() {
	long long x=0; char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0', c=getchar();
	return x;
}
int buf[30];
void write(long long n) {
	if(!n) { putchar('0'); return; }
	memset(buf, 0, sizeof(buf));
	int index=0;
	while(n) buf[++index]=n%10, n/=10;
	while(index>=1) putchar(buf[index--]+'0');
	return;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a%b); }

int main() {
	long long a=read(), b=read();
	long long d=gcd(a, b);
	int cnt=0;
	for(int i=2; i<=d/i; i++) {
		if(d%i==0) {
			cnt++;
			while(d%i==0) d/=i;
		}
	}
	cnt+=d>1;
	write(cnt+1);
	return 0;
} 

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;

	vector<char> ans(n*2);
	rep(i,n)
	{
		ans[i*2] = static_cast<char>(s[i]);
		ans[i*2+1] = static_cast<char>(t[i]);
	}

	rep(i,2*n)cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int unsigned long long
#define endl "\n"
using namespace std;

int32_t main() {
  ios;
  int t = 1;
  // cin>>t;
  while(t--) {
    int n;
    cin>>n;
    int a[n];
    int s = 0;
    unordered_map<int,int> freq;
    for(int i = 0;i < n;i++) cin>>a[i],s+=a[i],freq[a[i]]++;
    int q;
    cin>>q;
    while(q--) {
      int b,c;
      cin>>b>>c;
      s -= freq[b]*b;
      s += freq[b]*c;
      freq[c] += freq[b];
      freq[b] = 0;
      cout<<s<<endl;
    }
    // cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 7908
# 初期入力 readlineだけで1950ms⇒1234ms
#                           PyPy   ⇒867ms
from collections import defaultdict
from collections import deque
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())

connection ={i:set() for i in range(1,N+1)}
for i in range(1,N):
    a,b = (int(i) for i in input().split())
    connection[a].add(b)
    connection[b].add(a)
nord_point = defaultdict(lambda: 0)
for i in range(1,Q+1):
    a,b = (int(i) for i in input().split())
    nord_point[a] +=b

#BSF

dq =deque()
start =1
dq.append(start)
passed =set()
counter_dic ={i:0 for i in range(1,N+1)}
counter_dic[start] =nord_point[start]
while len(dq) >0:
    now =dq.popleft()
    passed.add(now)
    for next in connection[now]:
        if next not in passed:
            counter_dic[next] =counter_dic[now] +nord_point[next]
            dq.append(next)
#出力
print(*counter_dic.values())

Measured memory_bytes: 151008
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N, M;

    cin >> N >> M;

    vector<bool> f(N, false);
    vector<long long> num(N, 1);
    f[0] = true;
    for (long long i = 0; i < M; i++)
    {
        long long x, y;
        cin >> x >> y;
        if (f[x - 1])
            f[y - 1] = true;
        num[y - 1]++;
        num[x - 1]--;
        if (num[x - 1] == 0)
            f[x - 1] = false;
    }

    long long c = 0;
    for (long long i = 0; i < N; i++)
        c += f[i];

    cout << c << endl;
}

Measured memory_bytes: 1024
n,X,m=map(int,input().split())
if m==1:
    print(0)
else:
    x=[0]*m
    y=[0]*m
    y[0]=X
    z=[0]*(m+1)
    z[X]+=1
    for i in range(1,m):
        x[i]=(i**2)%m
    for i in range(1,m):
        y[i]=x[y[i-1]]
        z[y[i]]+=1
        if z[y[i]]==2:
            e=i
            q=y[i]
            break
    for i in range(len(y)):
        if y[i]==q:
            b=i
            break
    l=y[b:e]
    L=len(l)
    s=sum(l)
    #print(x)
    #print(y)
    #print(z)
    #print(b,e)
    #print(l)
    #print(sum(y[:b]))
    #print(((n-b)//L)*s)
    #print(sum(l[:(n-b)%L]))
    if n>=b:
        ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
    else:
        ans=sum(y[:n])
    print(ans)

Measured memory_bytes: 68428
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    long w = sc.nextLong();
    int n = sc.nextInt();
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      long b = sc.nextLong();
      for(int j = 0; j < 3; j++) {
        for(int k = 0; k < 3; k++) {
          long s = a - j;
          long t = b - k;
          if((s > 0) && (t > 0)) {
            if(((s + 2) <= h) && ((t + 2) <= w)) {
              long p = (s - 1) * w + t;
              if(map.containsKey(p)) {
                map.put(p, map.get(p) + 1);
              } else {
                map.put(p, 1);
              }
            }
          }
        }
      }
    }
    long[] ans = new long[10];
    long sum = 0;
    for(long key : map.keySet()) {
      sum++;
      ans[map.get(key)]++;
    }
    ans[0] = ((h - 2) * (w - 2)) - sum;
    for(int i = 0; i < 10; i++) {
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 171120
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int f1(int n) {
	return n % 10;
}
int f10(int n) {
	int a = n % 100;
	return a / 10;
}
int f100(int n) {
	int a = n % 1000;
	return a / 100;
}
int f1000(int n) {
	int a = n % 10000;
	return a / 1000;
}
int f10000(int n) {
	int a = n % 100000;
	return a / 10000;
}
int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; i++) {
		if (f10000(i) == f1(i) && f1000(i) == f10(i)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = [1, A[i]]

B = [[] for _ in range(M)]

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

C = A + B
C = sorted(C, key=lambda x:x[1], reverse=True)

#print(C)

ans = 0
count = 0

for i in range(len(C)):
    count += C[i][0]
    #print(count, ans)
    if count <= N :
        ans += C[i][1] * C[i][0]
    else:
        ans += (C[i][0] - (count - N)) * C[i][1]
        break

print(ans)

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

int main(){
	int n, time = 0;
	cin >> n;
	vector<pair<int, int>> t(n);
	for(int i = 0; i < n; i++) cin >> t[i].second >> t[i].first;//B:A
	sort(t.begin(), t.end());
	for(int i = 0; i < n; i++){
		time += t[i].second;
		if(time > t[i].first){
			time = -1;
			break;
		}
	}
	if(time == -1) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(" ");
		
		int max_lenght = 0;
		String max_length_str = null;
		Map<String,Integer> map = new HashMap<String,Integer>();
		
		while(sc.hasNext()){
			String str = sc.next();
			
			if(map.containsKey(str)){
				map.put(str,map.get(str).intValue() + 1);
			}else{
				map.put(str, 1);
			}
			
			if(max_lenght < str.length()){
				max_lenght = str.length();
				max_length_str = str;
			}
		}
		
		int max = 0;
		String max_str = null;
		for(String s:map.keySet()){
			if(map.get(s) > max){
				max = map.get(s);
				max_str = s;
			}
		}
		
		System.out.println(max_str + " " + max_length_str);
	}
}

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

ans = 0

kk = 1
for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(999):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)

Measured memory_bytes: 9256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	as <- sort <$> readIntegers
	print $ fromMaybe (-1) $ foldM f 1 as

f a b
	| a * b <= 10 ^ 18 = Just $ a * b
	| otherwise = Nothing
f _ _ = Nothing

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


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void solve(long long N, long long K){
    COMinit();
    
    for(int i = 1;i <= K;i++){
        ll red = N - K;
        ll blue = K;
        if(red < i-1){
            cout<<0<<endl;
            continue;
        }else if(red == i-1 && red == 0){
            cout<<1<<endl;
            continue;
        }
        cout<<1LL*(((red < i+1? 0 : COM(red-1, i))%MOD + (red < i ? 0:2 * COM(red-1, i-1))%MOD + COM(red-1, i-2))%MOD * COM(blue-1, i-1)%MOD)%MOD<<endl;;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 30)

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

int n;
int ball[11] = {0};

bool solve(int a, int b, int c) {
	if(c == 10) return true;
	if(a < ball[c]) 
		if(solve(ball[c], b, c + 1)) return true;
	if(b < ball[c])	
		if(solve(a, ball[c], c + 1)) return true;
	return false;

}

int main() {
	scanf("%d", &n);
	rep(i, n) {
		rep(j, 10) scanf("%d", &ball[j]);
		printf("%s\n", (solve(0, 0, 0)) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  cin >> n >> k;
  vector<double> p(n);
  rep(i, n) {
    cin >> p[i];
  }

  double ans = 0;
  double sum = 0;
  rep(i, n) {
    if (i-k >= 0) sum -= (p[i-k]+1)/2;
    sum += (p[i]+1)/2;
    if (i >= k-1) cmax(ans, sum);
  }
  printf("%.10lf\n", ans);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=1e5+5;
int n,a[N];

int main()
{
	int i,ans=0;
	scanf("%d",&n);
	for(i=1;i<=2*n;++i) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(i=1;i<=2*n;i+=2) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

res = [0] * N

for a in A:
    res[a - 1] += 1
    
for i in range(N):
    if K - Q + res[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 13820
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

using ull_t = unsigned long long;

int main()
{
    string s;
    cin >> s;

    const size_t N = s.size();
    constexpr ull_t K = 1e9 + 7;
    ull_t n_abc(0), n_bc(0), n_c(0), var(1);

    auto add = [&K](ull_t &x, ull_t y) { x = (x + y) % K; };
    
    for (int i = 1; i <= N; ++i)
    {
        char ch = s.at(N - i);

        switch (ch)
        {
        case '?':
            add(n_abc, (n_abc * 2 + n_bc));
            add(n_bc, (n_bc * 2 + n_c));
            add(n_c, (n_c * 2 + var));
            var = (var * 3) % K;
            break;
        case 'A':
            add(n_abc, n_bc);
            break;
        case 'B':
            add(n_bc, n_c);
            break;
        case 'C':
            add(n_c, var);
            break;
        }
#ifdef DEBUG        
        Print("ch = ", ch, ", ABC = ", n_abc, ", BC = ", n_bc, ", C = ", n_c);
#endif
    }

    cout << n_abc << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s; cin >> s; 
    ll cur = 0, cnt = 0, ans = 0;
    while(cur < s.size()){
        if(s[cur] == 'A' || s[cur] == 'C' || s[cur] == 'G' || s[cur] == 'T'){
            cnt++; cur++;
            chmax(ans, cnt);
        }
        else{
            cnt = 0; cur++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*
a[i]: i番目を踏むときの最善

漸化式は
a[i + 1] = min(a[i - 1] + abs(h[i + 1] - h[i - 1]), a[i] + abs(h[i + 1] - h[i]))

*/

void main(){
	long n = read.to!long;
	long[] hs = readln.chomp.split.map!(to!long).array;
	
	long[] as = [0, abs(hs[1] - hs[0])];
	foreach(i; 2 .. n){
		as ~= min(as[i - 2] + abs(hs[i] - hs[i - 2]), as[i - 1] + abs(hs[i] - hs[i - 1]));
	}
	
	as[n - 1].writeln;
}


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

using namespace std;

const int INF = numeric_limits<int>::max();
const int MAXN = 1e6 + 100;
const int MOD = 1e9 + 7;
const double eps = 1e-6;
const double PI = acos(-1);
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    int n, k, q;
    cin >> n >> k >> q;
    vector <int> a(n, k - q);
    while(q--) {
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    for (auto u : a) {
        if(u > 0) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> Int -> Int
solve a b t = b * (t `div` a)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (a, b, t) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  print $ solve a b t


Measured memory_bytes: 380
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;
int cnt[maxn+1]={0};

int main(){
    
    int ans = 0;
    int c=0;
    int n;
    cin >> n;
    rep(i,n){
        int t;cin >> t;
        cnt[t]++;
    }
    ans = n;
    rep(i,maxn+1){
        c+=max(0,cnt[i]-1);
    }
    if(c%2==1)c++;
    ans-=c;
    cout <<ans<< endl;
    
    
    
    return 0;
}


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

int n, S, t[22];
int dp[22][1 << 14];

int solve(int idx, int rem){
  int &res = dp[idx][rem];
  if(res != -1) return res;
  if(rem == 1) return res = 0;

  for(int i = 1; i <= t[idx]; i++){
    if(rem - i < 1) break;
    int flg = solve((idx + 1) % n, rem - i);

    if(flg == 0){
      return res = 1;
    }
  }

  return res = 0;
}

int main(){
  while(cin >> n, n){
    cin >> S;
    for(int i = 0; i < 2 * n; i++){
      cin >> t[i];
    }
    n += n;
    memset(dp, -1, sizeof(dp));
    cout << solve(0, S) << endl;
  }
}

Measured memory_bytes: 2832
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/27/20 20:37:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> ds(n+1, 1);
  for (int m = 2; m <= n; m++) {
    for (int j = m; j <= n; j += m)
      ds[j]++;
//    cerr<<ds[m]<<" ";
  }
//  cerr<<endl;
  ll ans = 0;
  for (int m = 1; m <= n; m++) {
    ans += (ll)m * ds[m];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 42268
#include <stdio.h>

int main(void) {
	int w1 = 0,w2 = 0,w3 = 0,wn,k1 = 0,k2= 0,k3 = 0,kn,i;
	for (i = 1;i <= 10;i++){
		scanf("%d" , &wn);
		if (w1 <= wn){
			w3 = w2;
			w2 = w1;
			w1 = wn;
		}
		else if (w2 <= wn){
			w3 = w2;
			w2 = wn;
		}
		else if (w3 <= wn){
			w3 = wn;
		}
	}
	for (i = 1;i <= 10;i++){
		scanf("%d" , &kn);
		if (k1 <= kn){
			k3 = k2;
			k2 = k1;
			k1 = kn;
		}
		else if (k2 <= kn){
			k3 = k2;
			k2 = kn;
		}
		else if (k3 <= kn){
			k3 = kn;
		}
	}
	printf("%d %d\n",w1 + w2 + w3 , k1 + k2 + k3);
	return 0;
}
//aoj 0533

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int size = s.size();
    rep (i, size/2) {
        if (s[i] != s[size-1 - i]) cnt++;
    }

    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>

int main(void){
	
	int X,A,B;
	int sum;
	int calc;
	
	scanf("%d" ,&X);
	scanf("%d" ,&A);
	scanf("%d" ,&B);
	
	sum = X-A;
	calc = sum/B;
	
	printf("%d\n" ,sum - (calc * B));
}
	
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool can(int a,int b,int d){
    return abs(a-b)<=d;
}

int main()
{
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
        if(can(a,c,d)|| (can(a,b,d) && can(b,c,d))){
            puts("Yes");
        }else{
            puts("No");
        }

    }
    return 0;
}


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

import sys

stack = []

for line in sys.stdin:
	#print "input = " + line.strip()

	num = int(line)
	if num == 0:
		pop = stack.pop()
		#print "pop " + str(pop)
		print(str(pop))
	else:
		stack.append(num)
		#print "pushed " + str(num)

Measured memory_bytes: 4200
n=int(input())
card=[]
symb=['S','H','C','D']
num = [i+1 for i in range(13)]
for s in symb:
    for j in num:
        card.append(s+ ' ' +str(j))
for i in range(n):
    card.remove(input())

if card!=[]:
    print(*card,sep='\n')



Measured memory_bytes: 5608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
ll ss(string s){
  ll cnt = 0,res = 0;
  rep(i,s.size()){
    cnt++;
    if(i == (int)s.size() - 1 || s[i] != s[i + 1]){
      res += cnt / 2;
      cnt = 0;
    }
  }
  return res;
}
int solve(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  bool f = true;
  rep(i,s.size() - 1)if(s[i] != s[i + 1])f = false;
  if(f){
    ll size = (ll)s.size() * k;
    cout << size / 2 << endl;
  }
  else{
    string V1 = s;
    string V2 = s + s;
    ll R1 = ss(V1),R2 = ss(V2);
    cout << R1 + (R2 - R1) * (k - 1) << endl;
  }
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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

    int m = 1;
    for (int i = 0; i < n; ++i) {
        if(m < k) m*=2;
        else m+= k;
    }

    cout << m << endl;


    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int N, K, score;
    int i, j;
    double prob=0;
    
    cin >> N >> K;
    
    for(i=1; i<=N; i++){
        score = i;
        for(j=0; score < K; j++){
            score *= 2;
        }
        
        prob += pow(2.0, (double)(-j))/N;
    }
    
    cout << setprecision(12) << prob;
    
    return 0;
}




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

int main() {
    vector<string> vs = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;
    vector<int> dp(s.size() + 1);

    dp[0] = 1;
    for (int i = 0; i < s.size(); i++) {
        if (dp[i]) {
            for (int j = 0; j < 4; j++) {
                if (i + vs[j].size() < dp.size() &&
                    string(s.begin() + i, s.begin() + i + vs[j].size()) == vs[j]) {
                    dp[i + vs[j].size()] = 1;
                }
            }
        }
    }

    if (dp[s.size()]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	LL N;
	cin>>  N;
	LL ret = 1;
	for (LL b = 1; b <= N; b = b * 2 + 1) {
		ret++;
	}
	cout << ret - 1 << endl;

	return 0;
}



Measured memory_bytes: 3220