akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

ll s;
ll pow(ll a,ll n) {
    if(n==0) return a;
    if(n&1) a*=a;
    return pow(a,n>>1);
}

ll f(ll x) {
    return (x+1) * ((ll)(log10(10*x)))-(pow(10,(ll)(log10(10*x)))-1)/9;
}

ll C(ll x) {
    ll res=0;
    ll a=1;
    ll keta=1;
    while(a<=x) {
        ll t=min(a*10-1,x);
        ll t1=(t)/3-(a-1)/3;
        ll t2=(t)/5-(a-1)/5;
        ll t3=(t)/15-(a-1)/15;
        res+=((t)-a+1-t1-t2+t3)*keta;
        res+=(t1+t2)*4;

        a*=10;
        keta++;
    }
    return res;
}

string to_s(ll x) {
    stringstream ss;
    ss<<x;
    string res;
    ss>>res;
    return res;
}

int main() {
    cin>>s;
    ll lb=0,ub=1e18+7;
    while(ub-lb>1) {
        ll mid = (ub+lb)/2;
        if(C(mid)>=s) ub=mid;
        else lb=mid;
    }
    string ans="";
    for(ll i=ub;i<ub+10;i++) {
        string tmp=to_s(i);
        if(i%3==0) ans+="Fizz";
        if(i%5==0) ans+="Buzz";
        if(i%3!=0&&i%5!=0) ans+=tmp;
        if(ans.size()>30) break;
    }
    ll a=s-C(lb)-1;
    for(ll i=a;i<a+20;i++) cout<<ans[i];
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

map<string, int> memo;
int main() {
	//sort(a.begin(),a.end());
	int n, k;
	cin >> n >> k;
	int ans = 0 ;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans;
	return 0;
}









Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_A() {}
#else

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    string N; cin >> N;

    string ans;
    if (N[0]==N[1] && N[1]==N[2]) ans = "Yes";
    else if (N[1]==N[2] && N[2]==N[3]) ans = "Yes";
    else ans = "No";

    cout << ans << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef pair<int ,int > pii;
typedef long long LL;
const long long oo = 1e9 + 7;

int n,m;
map<int , int > ma;


int main(){
   // freopen("test.txt","r",stdin);
    cin >> n ;
    for (int i =1 ; i <= n ;i++) {
        int x;
        cin >> x;
        ma[x]++;
    }
    cin >> m ;
    for (int i = 1;i <= m ; i++) {
        int x;
        cin >> x;
        ma[x]--;
        if (ma[x] < 0) {
            cout << "NO" ;
            return 0;
        }
    }
    cout << "YES";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define re(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
int c7[10][10],h,w,s,t;
int visit[10][10];
int ax[]={1,0,-1,0},ay[]={0,1,0,-1};
int bx[]={1,0,-1,0},by[]={0,1,0,-1};
inline int dfs(int y1,int x1,int y2,int x2){
  s-=2;
  if(s==0)return 1;
  visit[y1][x1]=visit[y2][x2]=1;
  r(i,4){
    int y3=ay[i]+y1,x3=ax[i]+x1;
    int y4=by[i]+y2,x4=bx[i]+x2;
    if(y3<0||x3<0||y4<0||x4<0)continue;
    if(y3>=h||x3>=w||y4>=h||x4>=w)continue;
    if(y3==y4&&x3==x4)continue;
    if(c7[y3][x3]&&c7[y4][x4]&&(!visit[y3][x3])&&(!visit[y4][x4]))
      if(dfs(y3,x3,y4,x4)){return 1;}
  }
  return 0;
}
inline int solve(){
  if(s%2)return 0;t=s;
  r(i,h)r(j,w)if(c7[i][j])
    re(k,h)re(l,w)if(c7[k][l])
      r(n,2){if(i==k&&j==l)break;
        r(m,4){
          r(p,10)r(pp,10)visit[p][pp]=0;
          if(dfs(i,j,k,l))return 1;s=t;
          rotate(by,by+1,by+4);
          rotate(bx,bx+1,bx+4);
        }
        swap(by[1],by[3]);
      }
  return 0;
}
int main(){
  while(cin>>w>>h,w){
    s=0;
    r(i,4)ax[i]=ay[i]=bx[i]=by[i]=0;
    ax[0]=ay[1]=bx[0]=by[1]=1;
    ax[2]=ay[3]=bx[2]=by[3]=-1;
    r(i,h)r(j,w)cin>>c7[i][j];
    r(i,h)r(j,w)if(c7[i][j])s++;
    if(solve())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> stops(1,n);
    int where=n;
    while(where){
        bool next=false;
        for(int i=max(0,where-m); i<where; i++){
            if(s.at(i)=='0'){
                where=i;
                stops.push_back(i);
                next=true;
                break;
            }
        }
        if(!next){
            cout << -1 << endl;
            return 0;
        }
    }
    //int s=stops.size()-1;
    vector<int> ans(stops.size()-1);
    for(int i=0; i<stops.size()-1; i++){
        ans.at(i)=stops.at(i)-stops.at(i+1);
    }
    reverse(ans.begin(),ans.end());
    for(int i=0; i<stops.size()-1; i++){
        cout << ans.at(i) << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#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.1415926535897932384626433832795028L;
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 T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
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;

signed main() {
    int K = 38;
    int N = K * K - K + 1;
    cout << N << " " << K << endl;
    reps(i, K) { cout << i << " "; }
    cout << endl;
    vvint cur(K - 1, vint(K - 1));
    rep(i, K - 1) {
        rep(j, K - 1) {
            cur[i][j] = i * (K - 1) + j + K + 1;
        }
    }
    reps(i, K - 1) {
        rep(j, K - 1) {
            cout << i << " ";
            rep(k, K - 1) {
                cout << cur[j][k] << " ";
            }
            cout << endl;
        }
        vvint tmp(K - 1, vint(K - 1));
        rep(j, K - 1) {
            rep(k, K - 1) {
                tmp[j][k] = cur[(j + k) % (K - 1)][k];
            }
        }
        cur = tmp;
    }
    rep(i, K - 1) {
        cout << K << " ";
        rep(j, K - 1) {
            cout << cur[j][i] << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 512
import math

A, B = map(int, input().split())
ans = -1

for i in range(int(min(A * 12.5, B * 10)), 10001):
  if math.floor(i * 0.08) == A and math.floor(i * 0.10) == B:
    ans = i
    break
    
print(ans)
  

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<string> S;
    S.resize(n);
    int cnttmp[26] = {};
    int cnt[26];
    fill(cnt, cnt + 26, INT_MAX);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
        for (char c : S[i])
        {
            cnttmp[c - 'a']++;
        }
        for (int i = 0; i < 26; i++)
        {
            if (cnt[i] > cnttmp[i]) cnt[i] = cnttmp[i];
        }
        fill(cnttmp, cnttmp + 26, 0);
        
    }

    char c = 'a';
    for (int m : cnt)
    {
        while (m > 0)
        {
            cout << c;
            m--;
        }
        c++;
        
    }
    
    cout << endl;
    
    return 0;
}

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

n=len(s)

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

def p(n,r,mod):
    return fact[n]*factinv[n-r] % mod
mod = 10 ** 9 + 7
maxi = 2*10 ** 6 + 1  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, maxi + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

array_5=[1]
array_6=[1]
for i in range(k):
    array_5.append(25*array_5[-1]%mod)
    array_6.append(26*array_6[-1]%mod)

ans=0
for i in range(n,n+k+1): #iはS_Nの固定した位置を表す。
    x=cmb(i-1,n-1,mod)
    y=array_5[i-n]*array_6[n+k-i]
    ans += x*y%mod
    ans %=mod
print(ans)

Measured memory_bytes: 330560
#include <bits/stdc++.h>
using namespace std;
struct SegTree{
	vector<int> val;
	void build(){
		val.resize((1<<18)*2);
		for(int i=0;i<(1<<18)*2;++i){
			val[i]=INT_MIN;
		}
	}
	void modify(int x,int v){
		x+=(1<<18)-1;
		val[x]=v;
		while(x>0){
			x=(x-1)/2;
			val[x]=max(val[x*2+1],val[x*2+2]);
		}
	}
	int query(int lc,int rc,int x=0,int l=0,int r=(1<<18)){
		if(rc<=l||r<=lc){
			return INT_MIN;
		}
		if(lc<=l&&r<=rc){
			return val[x];
		}
		int mid=(l+r)/2;
		return max(query(lc,rc,x*2+1,l,mid),query(lc,rc,x*2+2,mid,r));
	}
}seg,seg2;
int n;
int b[210000];
int sum[210000];
int ans;
int main(){
	seg.build(),seg2.build();
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>b[i];
		sum[i+1]=sum[i]+!b[i];
	}
	int q;
	cin>>q;
	vector<pair<int,int> > qs(q);
	for(int i=0;i<q;++i){
		cin>>qs[i].first>>qs[i].second;
	}
	sort(qs.begin(),qs.end());
	for(auto op:qs){
		int l=op.first,r=op.second;
		int v=r-l+1-2*(sum[r]-sum[l-1]);
		int res=max(0,seg.query(0,l));
		res+=v;
		int res2=seg2.query(l,r+1);
		if(res2!=INT_MIN){
			res2+=r-2*sum[r];
		}
		int ret=max(res,res2);
		ans=max(ret,ans);
		seg.modify(r,ret);
		seg2.modify(r,ret-r+2*sum[r]);
	}
	cout<<n-sum[n]-ans<<'\n';
	return 0;
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    int n;
    cin>>n;
    vll h(n+1);
    int i=0;
    h[0]=0;
    fwd(i,1,n)cin>>h[i];
    vll dp(n+1);
    dp[0]=0;
    dp[1]=0;
    fwd(i,2,n){
       if(i>2){
       dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
       }
       else{
        dp[2]=dp[i-1]+abs(h[i]-h[i-1]);
       }
    }
    cout<<dp[n]<<endl;
}





Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool flag = false;
	while(1)
	{
		string t = s.substr(0, s.size() / 2);
		string r = s.substr(s.size() / 2);
		if(t == r && flag == true)
		{
			cout << s.size() << endl;
			return 0;
		}
		s.pop_back();
		flag = true;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  //ll min = 0;
  //min = pow(10,18);
  //ll mini = 0;
  for(int i = 0;i < 26;i++){
    cin >> c[i];
    //if(min > c[i])min = c[i],mini = i;
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  for(int i = 0;i < d;i++){
    ll now = 0;
    ll nowi = 0;
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
      s[i][j] += c[j];
      if(now < s[i][j]){
        now = s[i][j];
        nowi = j;
      }
    }
    cout << nowi + 1 << endl;
  }
  //for(int i = 0;i < 365;i++)cout << mini + 1 << endl;
}

Measured memory_bytes: 3716
n,k = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(j) for j in input().split()])
ab.sort()
cnt = 0
for x in ab:
    if x[1]+cnt < k:
        cnt += x[1]
    elif x[1]+cnt >= k:
        print(x[0])
        break

Measured memory_bytes: 21648
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------

int t[100002];




signed main(){
	string s;
	cin>>s;
	
	int ans=0,t=0;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='S'){
			t++;
		}
		else{
			if(t==0) continue;
			else{
				t--;
				ans += 2;
			}
		}
	}
	cout<<s.length()-ans<<endl;
	
	return 0;
}

//printf("%.10f\n",ans);


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int compare_long(long *a, long *b) {
    long buf = *a - *b;
    if (buf < 0) return -1;
    else if (buf > 0) return 1;
    return 0;
}
 
int compare_pointer(long **a, long **b) {
    long buf = a[0][1] - b[0][1];
    if (buf < 0) return 1;
    if (buf > 0) return -1;
    return 0;
}

int main() {
    int n = 0, m = 0;
    scanf("%d %d\n", &n, &m);
    long int lis[n];
    for (int i=0; i<n; i++) {
        scanf("%ld", &lis[i]);
    }
    long int change[m][2];
    long int *changing[m];
    for (int i=0; i<m; i++) {
        scanf("%ld %ld", &change[i][0], &change[i][1]);
        changing[i] = change[i];
    }
    qsort(lis, n, sizeof(long int), compare_long);
    qsort(changing, m, sizeof(long int *), compare_pointer);
    long int a = 0, b = 0;
    int count_lis = 0, count_cha = 0;
    while (lis[count_lis] < changing[count_cha][1]) {
        a += lis[count_lis];
        b += changing[count_cha][1];
        count_lis++;
        changing[count_cha][0]--;
        if (changing[count_cha][0] <= 0) {
            count_cha++;
        }
        if (count_lis >= n) break;
        if (count_cha >= m) break;
    }
    for (int i=count_lis; i<n; i++) {
        b += lis[i];
    }
    printf("%ld\n", b);
    return 0;
}


Measured memory_bytes: 4092
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
using namespace std;

int main(void){
    int r, w, cnt=0;
    cin >> w;
    string s;
    cin >> s;
    w -= 1;
    while(r<w){
        if(s[r]=='R'){ r++; continue; }
        if(s[w]=='W'){ w--; continue; }
        cnt++;
        r++; w--;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = (N+1)/2;
  cout << ans << endl;
}

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

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

    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    a1 -= b1;
    a2 -= b2;

    a1 *= t1;
    a2 *= t2;

    if (a1 + a2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    if (a1 < 0 && a2 < 0 || a1 > 0 && a2 > 0) {
        cout << 0 << endl;
        return 0;
    }

    if (a1 > 0) {
        a1 = -a1, a2 = -a2;
    }

    if (a1 + a2 < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll aa = a1 + a2;
    ll t  = -a1 / aa;
    t     = 2 * t + 1;
    if (a1 % aa == 0)
        t--;
    cout << t << endl;
}

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

int main() {

	int h,n,a,total=0;
	cin>>h>>n;

	for (int i=0;i<n;i++) {
		cin>>a;
		total+=a;
		if (h-total <= 0) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";

    return 0;
}


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

int main(){
  int n , a;
  long double x = 0 ;
  cin >> n ;
  for(int i=0; i<n; i++){
    cin >> a ;
    x += (long double)1/a ;
  }  
  cout << 1/x << endl ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void){
	vector<int> count(26,0);
	char tmp;
	while(cin >> tmp){
		if('a' <= tmp && tmp <= 'z'){
			++count[(int)(tmp - 'a')];
		} else if('A' <= tmp && tmp <= 'Z'){
			++count[(int)(tmp - 'A')];
		}
	}
	for(int i = 0;i < 26; ++i){
		cout << ((char)(i+'a')) << " : " << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1176
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;


int main(){
    int n, m , a, b;
    cin >> n >> m;
    int amount[n+1];
    rep( i , n) amount[i] = 1;
    bool red[n+1];
    red[1] = true;
    rep(i , m){
        cin >> a >> b;
        amount[a]--;
        amount[b]++;
        if ( red[a]) red[b] = true;
        if ( amount[a] == 0) red[a] = false;
        
        
    }
    int ans = 0;
    rep( i , n){
        if ( red[i] ) ans++;
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 4064
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<bool> flag(81 + 1, false);

  for (size_t i = 1; i < 10; i++) {
    for (size_t j = 1; j < 10; j++) flag[i * j] = true;
  }
  std::cout << (N < flag.size() && flag[N] ? "Yes" : "No") << std::endl;

  return 0;
}

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


int main() {
	int x;
	cin >> x;
	int value = 400;
	for(int i=8; i>=1; i--) {
		if(x >= value && x<=value+199) {
			cout << i << endl;
			break;
		}
		value += 200;
	}
}

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

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

    long long x[n];

    for(long long i = 0; i < n; i++) cin >> x[i];

    long long ans = 0;
    for(long long i = 0; i < n; i++){
        ans += min(abs(x[i]), abs(x[i]-k));
    }
    cout << 2 * ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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

    int Count = 0;
    queue<int> qPos;
    queue<int> qNum;
    char prv = 'R';
    for(int i=0; i<s.size(); i++){
        if(prv=='R' && s.at(i)=='L'){
            qPos.push(i-1);
            qPos.push(i);
            qNum.push(Count);
            Count = 1;
            prv = s.at(i);

            if(i==s.size() - 1)
                qNum.push(Count);
        }
        else if(prv=='L' && s.at(i)=='R'){
            qNum.push(Count);
            Count = 1;
            prv = s.at(i);
        }
        else{
            Count++;

            if(i==s.size() - 1)
                qNum.push(Count);
        }
    }

    queue<int> qAns;
    while(!qNum.empty()){
        int a = qNum.front();
        qNum.pop();
        int b = qNum.front();
        qNum.pop();

        int rightA = a/2;
        int leftA = a - rightA;

        int leftB = b/2;
        int rightB = b - leftB;

        qAns.push(leftA+leftB);
        qAns.push(rightA+rightB);
    }

    vector<int> vecAns(s.size(), 0);
    for(int i=0; i<s.size(); i++){
        if(i==qPos.front()){
            vecAns[i] = qAns.front();
            qPos.pop();
            qAns.pop();
        }
    }

    for(int i=0; i<vecAns.size(); i++)  cout << vecAns[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    int a[4];
    for(i=0;i<4;i++)
        scanf("%1d",&a[i]);
    if(a[0]+a[1]+a[2]+a[3]==7)
    {printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]+a[2]-a[3]==7)
    {printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]-a[2]+a[3]==7)
    {printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]+a[1]-a[2]-a[3]==7)
    {printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]+a[2]+a[3]==7)
    {printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]+a[2]-a[3]==7)
    {printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]-a[2]+a[3]==7)
    {printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    if(a[0]-a[1]-a[2]-a[3]==7)
    {printf("%d-%d-%d-%d=7",a[0],a[1],a[2],a[3]);
    return 0;
    }
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n; cin >> n;
    vector<int> a(n), b(n);

    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	b[i] = a[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
    	if (a[i] - b[i] >= 2) {
    		cout << "No" << "\n";
    		return 0;
    	}
    }
    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int pai[100];
bool cmp(int a,int b)
{
    return a > b;
}
int main()
{
    int asum = 0,bsum = 0,n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> pai[i];
    }
    sort(pai,pai + n,cmp);
    for(int i = 0;i < n;i += 2)
    {
        asum += pai[i];
        if(i + 1 < n)
        {
            bsum += pai[i+1];
        }
    }
    cout << asum - bsum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) x.begin(), x.end()
bool isPowerOfTwo(int n)
{
    return (ceil(log2(n)) == floor(log2(n)));
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(i%2!=0&&x%2!=0){
            ans++;
        }

    }
    cout<<ans<<endl;



    return 0;

}


Measured memory_bytes: 3660
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        s: [chars; n],
    }
    let mut a = vec![];
    for s in s {
        let mut cnt = [0; 26];
        for c in s {
            let k = (c.to_digit(36).unwrap() - 10) as usize;
            cnt[k] += 1;
        }
        a.push(cnt);
    }
    a.sort();
    let mut ans = 0;
    let mut i = 0;
    while i < n {
        let mut j = i + 1;
        while j < n && a[i] == a[j] {
            ans += j - i;
            j += 1;
        }
        i = j;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 29964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long double ld;
const ld eps = 1e-9;

vector<ld> quadraticEquation(ld a, ld b, ld c){
    ld d = b*b - 4*a*c;
    if(abs(a) < eps) return { -c/b };
    if(d < -eps) return {};
    if(d < eps) return { (-b + sqrt(d)) / (2*a) };
    int sign = (b >= 0) ? 1 : -1;
    ld x1 = (-b - sign * sqrt(d))/(2.0 * a), x2 = c / (a * x1);
    return { x1, x2 };
}

ld simpson(ld x0, ld x1, function<ld(ld)> f){
    const int n = 1e5;
    const ld dx = (x1 - x0) / n;
    ld a = f(x0) + f(x0 + dx * n);
    for(int i = 1; i < n; i += 2) a += 4.0 * f(x0 + dx * i);
    for(int i = 2; i < n; i += 2) a += 2.0 * f(x0 + dx * i);
    return a*dx/3.0;
}

ld W,H,N;
ld a[55], p[55], q[55];

ld f(int i, ld x){
    return a[i]*(x-p[i])*(x-p[i]) + q[i];
}

bool inside(ld x, ld y){
    if (x < -eps || W < x-eps) return false;
    if (y < -eps || H < y-eps) return false;
    return true;
}

ld solve(){
    vector<ld> es = { 0, W };
    rep(i,N){
        auto xs = quadraticEquation(a[i], -a[i]*2*p[i], q[i] + a[i]*p[i]*p[i]); // on x axis
        for(ld x : xs) if(inside(x,f(i,x))) es.push_back(x);
        rep(j,i){
            ld aa = a[i] - a[j];
            ld bb = -a[i]*2*p[i] - (-a[j]*2*p[j]);
            ld cc = (q[i] + a[i]*p[i]*p[i]) - (q[j] + a[j]*p[j]*p[j]);
            auto cs = quadraticEquation(aa, bb, cc);
            for(ld x : cs) {
                if(inside(x,f(i,x))){
                    es.push_back(x);
                }
            }
        }
    }
    sort(es.begin(), es.end());
    ld ans = 0;
    rep(i,es.size()-1){
        ld x1 = es[i], x2 = es[i+1];
        ld m = (x1+x2) / 2;
        int idx = -1;
        ld maxy = -1e9;
        rep(j,N){
            if(maxy < f(j,m)){
                maxy = f(j,m);
                idx = j;
            }
        }
        if(maxy > -eps){
            ans += simpson(x1, x2, [&](ld x){
                    ld dy = a[idx] * 2 * (x - p[idx]);
                    return sqrt(1 + dy*dy);
                });
        }
    }
    return ans;
}

int main(){
    while(cin >> W >> H >> N){
        rep(i,N) cin >> a[i] >> p[i] >> q[i];
        printf("%.10lf\n", (double)solve());
    }
}

Measured memory_bytes: 3364
#include <iostream>

using namespace std;

int main(){
	string str;
	int g=0, p=0;
	cin>>str;
	int l=str.length();
	for(int i=0; i<l; i++){
		if(str[i]=='g')g++;
		else if(str[i]=='p')p++;
	}
	cout<<(g-p)/2<<endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC\n" : "ABC\n");
}


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

int n,a[101];
int ret;
main()
{
 cin>>n;
  for(int i=1;i<=n;++i) cin>>a[i];
  for(int i=1;i<=n-1;++i)
  for(int j=i+1;j<=n;++j)
  {
    ret+=a[i]*a[j];
  }
  cout<<ret;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	string S;
	cin >> S;
	rep(i, S.size() - 8) {

		cout <<S.at(i) ;

	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, m) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << max(-1, n - sum) << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int a = Integer.parseInt(std.next());
	    int b = Integer.parseInt(std.next());
	    int s = a * b;
	    int r = 2*a+2*b;
	    System.out.println(s+" "+r);
	}
}

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

// Optimization

//#pragma GCC optimize("O3")
// #define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int ans, cnt, tmp, idx, sum, mx = -inf, mn = inf;
int x, y, z;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    ForE(i, 1, n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a + 1, a + 1 + n); reverse(a + 1, a + 1 + n);
    ForE(i, 1, m){
        if (a[i] * 4 * m < sum) Ptest("No");
    }
    cout << "Yes";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define f first
#define s second 
using namespace std;
typedef long long LL;
const int MAXN = 1e5+15;
int pre[MAXN],num[MAXN];
pii e[MAXN];
int n,m;
int Find(int x)
{
    return pre[x] == x ? x : pre[x] = Find(pre[x]);
}
int main()
{
    cin>>n>>m;
    for(int i = 1;i <= m; ++i) cin>>e[i].f>>e[i].s;
    std::vector<LL> v;
    LL sum = 1LL * (n-1 ) * n / 2;
    v.push_back(sum);
    for(int i = 1;i <= n; ++i){
        num[i] = 1;
        pre[i] = i;
    }
    for(int i = m; i ; --i){
        int fx = Find(e[i].f);
        int fy = Find(e[i].s);
        if(fx != fy){
            sum -= 1LL * num[fx] * num[fy];
            pre[fx] = fy;
            num[fy] += num[fx];
        }
        v.push_back(sum); 
    }
    for(int i = v.size() - 2; i >= 0 ; --i){
        cout<<v[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>

void SelectionSort(int a[],int n){
  int i,min,j,temp,cnt=0;

  for(i=0;i<n;i++){
    min=i;
    for(j=i+1;j<n;j++){
      if(a[j]<a[min]){
        min=j;
      }
    }
    temp=a[i];
    a[i]=a[min];
    a[min]=temp;

    if(i!=min){
      cnt++;
    }
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

}

int main(void){
  int n,a[100],i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  SelectionSort(a,n);

  return 0;
}

Measured memory_bytes: 1848
N=int(input())
T=[0 for i in range(N)]
A=[0 for i in range(N)]
for i in range(N):
    T[i],A[i]=map(int,input().split())
TT=T[0]
AA=A[0]
for i in range(1,N):
    g=max([-((-AA)//A[i]),-((-TT)//T[i])])
    AA=g*A[i]
    TT=g*T[i]
    #print(g,TT,AA)
print(AA+TT)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n, x, t; cin >> n >> x >> t;
	cout << ((n-1)/x+1)*t << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0, size=s.size(); i<size-2;++i){
        if(s[i]=='A' & s[i+1]=='B' & s[i+2]=='C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

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

  rep(i,s.size()) {
    s[i] = (s[i] - 'A' + n)%26 + 'A';
  }

  cout << s << endl;
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  for (int i = A; i <= B; ++i) {
    int tmp = i;
    int x1, x2, x3, x4, x5;
    
    x5 = tmp % 10;
    tmp = tmp / 10;
    
    x4 = tmp % 10;
    tmp = tmp / 10;
    
    x3 = tmp % 10;
    tmp = tmp / 10;
    
    x2 = tmp % 10;
    tmp = tmp / 10;
    
    x1 = tmp % 10;
    tmp = tmp / 10;
    
    if (x1 == x5 && x2 == x4) {
      ans++;
      // cout << x1 << x2 << x3 << x4 << x5 << endl;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  map<ll, ll> same;
  REP(i,N) {
    cin >> A[i];
    if (same.find(A[i]) == same.end()){
      same[A[i]] = 1;
    } else {
      same[A[i]]++;
    }
  }

  ll sum = 0;
  REP(i,same.size()){
    ll n = same[i];
    sum += n*(n-1)/2;
  }

  REP(k,N){
    ll val = same[A[k]];
    ll ans = sum - val*(val-1)/2 + (val-1)*(val-2)/2;
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 16384
#include <stdio.h>
int main() {
	char f[101][101];
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", f[i]);
	}
	for (int i = 0; i < w + 2; i++) {
		printf("#");
	}
	printf("\n");
	for (int i = 0; i < h; i++) {
		printf("#%s#\n", f[i]);
	}
	for (int i = 0; i < w + 2; i++) {
		printf("#");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (h : a : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . succ $ (pred h) `div` a

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m;
vector<pii > v[20];
int vis[20];
bool check(int s){
	for(int i = 0;i < n;i++) vis[i] = -1;
	for(int i = 0;i < n;i++){
		if(s & (1 << i)){ //honest
			for(int j = 0;j < v[i].size();j++){
				int x = v[i][j].fi,y = v[i][j].se;
				if(y){
					if(vis[x] == 0) return 0;
					if(!(s & (1 << x))) return 0;
					vis[x] = 1;
				} 
				else{
					if(vis[x] == 1) return 0;
					if(s & (1 << x)) return 0;
					vis[x] = 0;
				}
			}
		}
	}
	return 1;
}
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> m;
		int x,y;
		while(m--){
			cin >> x >> y;
			x--;
			v[i].pb(mp(x,y));
		}
	}
	int ans = 0;
	for(int i = 0;i < (1 << n);i++){
		if(check(i)){
			ans = max(ans,__builtin_popcount(i));
		}
	}
//	cout << check(1) << endl;
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n=int(input())
a = list(map(int,input().split()))

D={0:0}
s=0
for i in range(n):
    s = s+a[i]
    if s in D:
        D[s] = D[s]+1
    else:
        D[s] = 0

l=list(D.values())
p=0
for i in l:
    p=p+i*(i+1)//2
print(p)
    
    






Measured memory_bytes: 38644
#include<stdio.h>
int main(){
  int a,b,c,d,n,t;
  while(scanf("%d",&n)!=EOF){
    t=0;
    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    if(a+b+d+c==n){
	      t++;
	    }
	  }
	}
      }
    }
    printf("%d\n",t);
  }
  return (0);
}

Measured memory_bytes: 596
[n,t]=list(map(int,input().split()))
alist=list(map(int,input().split()))
salist=[alist[1]-alist[0]]
saisho=min(alist[0],alist[1])
for i in range(1,n-1):
	saisho=min(saisho,alist[i])
	salist.append(alist[i+1]-saisho)
saidai=max(salist)
kaisu=salist.count(saidai)
print(kaisu)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,k;cin >> a >> b >> c >> k;
	cout << a+b+c-max({a,b,c})+max({a,b,c})*pow(2,k) << endl;
}

Measured memory_bytes: 892
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

for i in [a, b, c]:
    if x in i and y in i:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 2940
from functools import reduce
from fractions import gcd

POSSIBLE = "POSSIBLE"
IMPOSSIBLE = "IMPOSSIBLE"
n, k = map(int, input().split())
a = list(map(int, input().split()))

# max(a) < k → だめ
# N == 1 ぴったじゃなきゃだめ
# N > 1
## 互いに素な数が含まれている → ○
## 含まれてないが、kがその倍数 → ○
if max(a) < k:
    print(IMPOSSIBLE)
    exit()
if n == 1:
    if k == a[0]:
        print(POSSIBLE)
    else:
        print(IMPOSSIBLE)
else:
    g = reduce(lambda a, b: gcd(a, b), a)
    if g == 1:
        print(POSSIBLE)
    else:
        if k % g == 0:
            print(POSSIBLE)
        else:
            print(IMPOSSIBLE)



Measured memory_bytes: 16308
K, N = map(int,input().split())
A = list(map(int,input().split()))
list = []
x = K-A[len(A)-1] + A[0]
list.append(x)
for i in range(1,len(A)):
    list.append(A[i] - A[i-1])
print(K - max(list))

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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b;
	cout << max(a+b,max(a-b,a*b));
	return 0;
}

Measured memory_bytes: 256