akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 


int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll r=Pow(2,n);
  r=(r-1+MOD)%MOD;
  ll p=1,e=1;
  rep(i,a){
      (p*=(n-i))%=MOD;
  }
  rep(i,a){
      (p*=Pow(i+1,MOD-2))%=MOD;
  }
  rep(i,b){
      (e*=(n-i))%=MOD;
  }
  rep(i,b){
      (e*=Pow(i+1,MOD-2))%=MOD;
  }
  r=(r+MOD-p)%MOD;
  r=(r+MOD-e)%MOD;
  cout << r << endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;

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

bool cheak(int h, int w, vector<vector<char>> cambus) {

  if(cambus[h][w] == '.') return true;

  else {
    REP(i,4) {
      int a = h + dx[i];
      int b = w + dy[i];

      if(a < 0) continue;
      if(b < 0) continue;
      if(a >= (int)cambus.size()) continue;
      if(b >= (int)cambus[0].size()) continue;

      if(cambus[a][b] == '#') return true;
      if(cambus[a][b] == '.') continue;
    }
  }

  return false;
  }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<vector<char>> cambus(h, vector<char>(w));
  REP(i,h) {
    REP(j,w) {
      char c;
      cin >> c;
      cambus[i][j] = c;
    }
  }

  bool flag = true;
  REP(i,h) {
    REP(j,w) {
      if(!cheak(i,j,cambus)) flag = false;
    }
  }
  YesorNo(flag);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <climits>
using namespace std;
#define ll long long int


int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll n;
    cin >> n;
    ll N = 1 << n;
    vector<pair<ll, ll> > d(N);
    for(int i = 0; i < N; ++i) cin >> d[i].first;
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < N; ++j){
            if(j&(1<<i)){
                int s = j^(1<<i);
                if(d[j].first < d[s].first){
                    d[j].second = max(d[j].first, d[s].second);
                    d[j].first = d[s].first;
                }
                else d[j].second = max(d[j].second, d[s].first);
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i < N; ++i){
        ans = max(ans, d[i].first + d[i].second);
        cout << ans << endl;
    }
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
int N; int64_t K;
  cin>>N>>K;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int64_t T=0;
  for(int i=1;i<=N-1;i++){
  for(int j=N-1;i<=j;j--){
  int64_t a=A.at(j);
    int64_t b=A.at(j-1);
 if(a<b){A.at(j)=b; A.at(j-1)=a; T++;}
 }
  }map<int64_t,int64_t>M;
  for(int i=0;i<N;i++){
  if(M.count(A.at(i)))
    M.at(A.at(i))++;
    else
      M[A.at(i)]=1;
  }int64_t c=(N*(N-1))/2;
  for(auto p:M){
  auto k=p.first;
    auto v=p.second;
    c-=(v*(v-1))/2;
 }  int64_t ans=((K*T)%mod+((((K*(K-1))/2)%mod)*c)%mod)%mod;
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 384
/*input
3 2
0 0
2 0
0 1
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
#define pb push_back 

int main() {
	int n,m;
	cin>>n>>m;
	int a[n][m];
	for(int i=0;i<n;i++)
	{

		for(int j=0;j<m;j++)
		{

			cin>>a[i][j];
			a[i][j]%=2;

		}
	}
	vector<int> v[4];
	for(int i=0;i<n;i++)
	{

		for(int j=0;j<m-1;j++)
		{

			if(a[i][j]==0)
			{
				continue;
			}
			else
			{	
				a[i][j+1]++;
				a[i][j+1]%=2;
				v[0].pb(i);
				v[1].pb(j);
				v[2].pb(i);
				v[3].pb(j+1);
			}
		}
	}

	for(int i=0;i<n-1;i++)
	{
		if(a[i][m-1]==0)
			{
				continue;
			}
			else
			{	
				a[i+1][m-1]++;
				a[i+1][m-1]%=2;
				v[0].pb(i);
				v[1].pb(m-1);
				v[2].pb(i+1);
				v[3].pb(m-1);
			}

	}

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

		cout<<v[0][i]+1<<" "<<v[1][i]+1<<" "<<v[2][i]+1<<" "<<v[3][i]+1<<endl;

	}


return 0;
} 

Measured memory_bytes: 5220
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;
int_fast32_t nn, n, sqrtN;
int_fast64_t ans, d;
main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> nn;
    const int_least32_t n = nn;
    if(n == 1) {
        putc_unlocked(49, stdout);
    } else {
        const int_fast32_t sqrtN = sqrt(n);
        ans = -(int_fast64_t)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int_fast32_t a = n / i;
            ans += ((int_fast64_t)i * (i + a) * (a + 1 - i));
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <vector>

/*
N枚の皿に1からNまでの番号が振られている。最初、皿iにはa_i個の寿司が
置かれている。(1個以上3個以下)
すべての寿司がなくなるまで以下の操作を繰り返す。

等確率で1からNまでの目が出るサイコロを振り、出た目をiとする。
皿iに寿司があるならその皿の寿司を1個食べ、ないならなにもしない。

すべての寿司がなくなるまでの操作回数の期待値を求めよ。
参考: https://qiita.com/drken/items/03c7db44ccd27820ea0d
*/

int N;
// dp[i][j][k]: 寿司が残り1枚の皿がi枚、2枚の皿がj枚、3枚の皿がk枚ある状態から
// 寿司をすべてなくすのに必要な操作回数の期待値
std::vector<std::vector<std::vector<double>>> dp;

double memorized_recursion(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0; // もうサイコロを振らなくていい

    /*
    次に引く皿 |  引く確率   | 遷移先
    残0枚の皿  | (N-i-j-k)/N | dp[i][j][k]
    残1枚の皿  |     i/N     | dp[i-1][j][k]
    残1枚の皿  |     j/N     | dp[i+1][j-1][k]
    残1枚の皿  |     k/N     | dp[i][j+1][k-1]
    この表より、漸化式は
    dp[i][j][k] = (上の表から得られる期待値) + 1(←1回サイコロを振るので)
    この式を変形したのが下の式
    */
    double ret = 0.0;
    if (i > 0) ret += memorized_recursion(i - 1, j, k) * i;
    if (j > 0) ret += memorized_recursion(i + 1, j - 1, k) * j;
    if (k > 0) ret += memorized_recursion(i, j + 1, k - 1) * k;
    ret += N;
    ret *= 1.0 / (i + j + k);
    dp[i][j][k] = ret;
    return ret;
}

int main() {
    std::cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        std::cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }

    dp = std::vector<std::vector<std::vector<double>>>(one + two + three + 1, std::vector<std::vector<double>>(two + three + 1, std::vector<double>(three + 1, -1)));
	double ans = memorized_recursion(one, two, three);
    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;
}

Measured memory_bytes: 216960
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a1=[0]*3
b1=[0]*3 
c1=[0]*3
n=int(input())
flag=0
for j in range(n):
  x=int(input())
  for i in range(3):
    if(a[i]==x):
      a1[i]=1
    elif(b[i]==x):
      b1[i]=1
    elif(c[i]==x):
      c1[i]=1 
  if(n>=3):
    s1,s2,s3=0,0,0
    cl1,cl2,cl3=0,0,0
    d1,d2=0,0
    d1=a1[0]+b1[1]+c1[2]
    d2=a1[2]+b1[1]+c1[0]
    for i in range(3):
      s1=s1+a1[i] 
      s2=s2+b1[i]
      s3=s3+c1[i]
      cl1=a1[i]+b1[i]+c1[i]
      if(cl1==3 or s1==3 or s2==3 or s3==3 or d1==3 or d2==3):
        flag=1 
        break
if(flag==0):
  print("No")
else:
  print("Yes")
    

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

using namespace std;
#define ll long long int

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

	ll hash[200005]={0};
	ll N;
	cin>>N;
	ll a[N+5];
	for (int i = 1; i <= N; ++i)
	{
		cin>>a[i];
		hash[a[i]]++;
	}
	ll sum=0;
	for (int i = 0; i < 200005; ++i)
	{
		sum+=(hash[i]*(hash[i]-1))/2;
	}
	ll temp;
	for (int i = 1; i <= N; ++i)
	{
		temp=sum;
		temp-=(hash[a[i]]*(hash[a[i]]-1))/2;
		temp+=((hash[a[i]]-1)*(hash[a[i]]-2))/2;
		cout<<temp<<endl;
	}

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N;
    string S;
    cin >> N >> S;
    map<char, ll> cnt;

    for (int i = 0; i < N; i++)
    {
        cnt[S[i]]++;
    }

    ll ans = cnt['R'] * cnt['G'] * cnt['B'];
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int k = 2 * j - i;
            if (k < N and S[i] != S[j] and S[i] != S[k] and S[j] != S[k])
            {
                ans--;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf 1000000007
int weight_ara[105], profit[105], n, weight_cap;
long long dp[100001];
int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d %d", &n, &weight_cap);
    long long max_profit = 0;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%d %d", &weight_ara[i], &profit[i]);
        max_profit+=profit[i];
    }
    for(int i = 0; i <= 100000; i++)dp[i] = inf;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = max_profit; j >= profit[i]; j--)dp[j] = min(dp[j], dp[j-profit[i]] + weight_ara[i]);}
    for(int i = 1; i <= max_profit; i++)if(dp[i] <= weight_cap)ans = i;
    printf("%d", ans);
    //printf("\nTime: %lf", ((double)(clock() - z) / CLOCKS_PER_SEC)*1e-6);
    return 0;
}


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

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
signed main(){

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r", stdin);
#endif

    fastIO
    int a, b;
    cin >> a >> b;
    cout << (a == b ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int x, ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> x;

	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;

	cout << ans << endl;
}

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

int main(){
	int n;scanf("%d",&n);
	int Max;
	for(int i=1;i*i<=n;i++)Max=i*i;
	cout<<Max<<endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
signed main(){
	int r,g,b;
	cin>>r>>g>>b;
	if((10*g+b)%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) { 
    ll A, B, C, X, Y;
    ll MAX = 400000;
    ll ans = INF;
    cin >> A >> B >> C >> X >> Y;
    for(ll i = 0; i <= MAX; i++) {
        int x = max(0LL, X - i / 2);
        int y = max(0LL, Y - i / 2);
        ans = min(ans, A * x + B * y + C * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def f(n):
    if int(n)%2 == 0:
        return int(int(n)/2)
    else:
        return int(n)*3+1

s = int(input())
a = [s]
i = 1
while f(a[i-1]) not in a:
    a.append(f(a[i-1]))
    i += 1
print(i+1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<math.h>
#include<map>

using namespace std;

long power_mn(long m, long n){
	
	long number = 1;
	for(int i = 0; i < n; i++){
		number *= m;
	}
	
	return number;
}

string small[26] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};	


int main()
{
	long N;
	cin >> N;
	
	long number = 1;
	long length = 0;
	
	while(number <= N){
		number += power_mn(26, length + 1);
		length++;
	}
	number -= power_mn(26, length);
	//cout << number << endl;
	
	long letter[length];
	for(int i = 0; i < length; i++){
		letter[i] = 0;
	}
	//cout << "phase2" << endl;
	for(int i = 0; i < length; i++){
			while(number <= N){
				number += power_mn(26, length - i - 1) ;
				letter[i]++;
			} 
			letter[i]--;
			number -= power_mn(26, length - i - 1);
			if(letter[i] == -1) letter[i]++;
	}
	//cout << number << endl;
	//cout << "phase3" << endl;
	string ans;
	
	for(int i = 0; i < length; i++){
		ans += small[letter[i]];
		//cout << "phase4" << endl;
	}		

	cout << ans << endl;
	return 0;



	
	
	
	
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long
using namespace std;
int i,j,k;
int x,y;
int p[100005];
int l,r;
int M,N;
int a[100010];
int b[100010];
int c[100010];
int cnt[100010];
signed main()
{
  ios_base::sync_with_stdio(0);
  cin>>M>>N;
 for(i=1;i<=N;i++)
    {cin>>p[i];
    }
  for(i=1;i<M;i++)
  {
      cin>>a[i]>>b[i]>>c[i];
  }
     for(i=1;i<N;i++)
    {
        int x=max(p[i],p[i+1]);
        int y=min(p[i],p[i+1]);
        cnt[x]--;
        cnt[y]++;
    }
    for(i=2;i<=M;i++)
    {
        cnt[i]+=cnt[i-1];
    }
int kq=0;
  for(i=1;i<M;i++)
  {

      kq+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]);
  }
  cout<<kq<<endl;
}

Measured memory_bytes: 7096
from collections import defaultdict


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [list(map(int, input().split())) for _ in range(Q)]

    d = defaultdict(int)
    for a in A:
        d[a] += 1
    ans = sum(A)

    for bc in BC:
        tmp = d[bc[0]]
        ans -= tmp * bc[0]
        d[bc[0]] = 0
        ans -= d[bc[1]] * bc[1]
        tmp += d[bc[1]]
        ans += tmp * bc[1]
        d[bc[1]] = tmp
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	vector <ll> vec(n);
 	cin >> n;
 	ll a, b;
 	for (ll i = 0; i < n; i++) {
 		cin >> a >> b;
 		if (a == b) vec[i] = 1;
 		else vec[i] = 0;
 	}
 	ll f2 = 0;
 	for (ll i = 2; i < n; i++) {
 		if (vec[i] == vec[i - 1] && vec[i - 1] == vec[i - 2] && vec[i] == 1) f2 = 1;
 	}
 	if (f2 == 1) cout << "Yes" << endl;
 	else cout << "No" << endl;
	return 0;
}

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

int main() {
    int N, A, B, k, sum, Ans=0;
    cin >> N >> A >> B;
    for (int i=1; i<=N; i++){
        sum = 0;
        k = i;
        while (true){
          	  sum += k%10;
              if (k-(k%10)==0){
              	 break;
              }
              k = (k-(k%10))/10;
        }
        if ((A<=sum)&&(sum<=B)){
            Ans += i;
        }
    }
    cout << Ans << endl;
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);

	int x, a;
	scanf("%d %d", &x, &a);
	if (x < a)
	{
		printf("0\n");
	}
	else
	{
		printf("10\n");
	}
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int n = scan.nextInt();
		int a[]=new int[n],ans=Integer.MAX_VALUE;
		for(int i=0;i<n;i++){a[i]=scan.nextInt();}
		scan.close();

		for(int i=0;i<n;i++) {
			int right = a[n-1]-a[i];
			if(i!=0)right+=a[i-1]+k-a[n-1];
			int left = a[i];
			if(i!=n-1)left+=k-a[i+1];

			if(ans>right)ans=right;
			if(ans>left)ans=left;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60560
#include <iostream>

using namespace std;
typedef long long lint;

lint solve(const int N, const int K) {
    if (K == 0) {
        return (lint)N * N;
    }
    lint ans = 0;
    for (int b = K+1; b <= N; b++) {
        const int n = (N-K) / b;
        const lint piece = b - K;
        ans += piece * n;
        const lint tmp = n * b + K;
        if (N >= tmp) {
            const lint upper = (n+1) * b;
            ans += min<lint>(N+1, upper) - tmp;
        }
    }
    return ans;
}

int main() {
    int N, K;
    cin >> N >> K;
    cout << solve(N, K) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    a, b, c, d = MI()

    while a > 0 and c > 0:
        c = c - b
        if c <= 0:
            print("Yes")
            exit()
        a = a - d
        if a <= 0:
            print("No")
            exit()


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    string s;
    cin >> s;
    vector<string> v = {"Sunny", "Cloudy", "Rainy"};
    for(int i=0; i<3; i++) if(v[i] == s) cout << v[(i+1)%3];
}

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

const int C = 26;
const int D = 365;

int d;
int c[C];
int s[D][C];

int t[D];

void read() {
  scanf("%d", &d);
  for (int i = 0; i < C; ++i) scanf("%d", &c[i]);
  for (int i = 0; i < d; ++i) {
    for (int j = 0; j < C; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
}

void solve() {
  for (int i = 0; i < d; ++i) {
    t[i] = 0;
    for (int j = 1; j < C; ++j) {
      if (s[i][j] > s[i][t[i]]) {
        t[i] = j;
      }
    }
  }
}

void print() {
  for (int i = 0; i < d; ++i) printf("%d\n", t[i] + 1);
}

int main() {
  read();
  solve();
  print();
  return 0;
}


Measured memory_bytes: 3860
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int a,b,c;
    
    a = N / 100;
    b = (N - a*100) / 10;
    c = N - a*100 - b*10;
    
    if(a == 7 || b == 7 || c == 7){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
  
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int n=0;
    string s;
    cin >> s;
    for(int i=0;i<4;++i) {
        if(s[i]=='+') ++n;
        else --n;
    }
    cout << n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

int main(){
    vector<int> era(10000000,0);
    for (int i=1; i<era.size(); i++) {
        era[i]=1;
    }
    for (int i=2; i<era.size(); i++) {
        if (era[i]!=0) {
            int q = i + i;
            while (q<era.size()) {
                era[q]=0;
                q += i;
            }
        }
    }
    int n;
    while (cin >> n) {
        int ans=-1;
        for (int i=1; i<=n; i++) {
            if (era[i]) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

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

	for (int i=1;i<=k;i++) printf("%d ",s);
	for (int i=k+1;i<=n;i++) printf("%d ",(s==1e9)?s-1:s+1);
  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a) < abs(x-b))
    puts("A");
  else
    puts("B");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(){
    int n,m; cin >> n >> m;
    priority_queue<long long> a;

    for(int i = 0; i < n; i++){
        long long num;
        cin >> num;
        a.push(num);
    }

    for(int i = 0; i < m; i++){
        long long num = a.top() / 2;
        a.pop();
        a.push(num);
    }

    long long sum = 0;
    for(int i = 0; i < n; i++){
        sum += a.top();
        a.pop();
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1400
// <A.cpp> - Sat Apr  1 19:59:54 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=300010;
const int INF=1e9;
int a[MAXN];
int main(){
    int n=gi();
    for(int i=1;i<=3*n;i++)a[i]=gi();
    sort(a+1,a+3*n+1);
    lol ans=0;
    for(int i=1;i<=n;i++)ans+=a[3*n-i*2+1];
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int function(long long x,long long y)
{
	long long s=1;
	for(long i=1;i<=y;i++)
	s*=x;
	return s;
}
int main()
{
	long a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible\n";
	return function(0,2147);
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

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

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

main = readInt >>= print . minimum . uncurry ( zipWith (+) ) . ( map digitSum &&& map digitSum . reverse ) . flip take [ 1 .. ] . pred

digitSum = sum . map digitToInt . show

Measured memory_bytes: 12156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vl a(N);
  vl count(1000010,0);
  ll ma=0;
  rep(i,N){
    cin>>a[i];
    ma=max(a[i],ma);
    count[a[i]]++;
  }
  sort(all(a));
  ll ans=0;
  vector<bool> judge(1000010,true);
  for(int i=0;i<N;i++){
    if(judge[a[i]]&&count[a[i]]==1){
      ans++;
    }
      for(int j=a[i];j<=ma;j+=a[i]){
        judge[j]=false;
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12776
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;


int main() {
	int n, x;
	int count;
	while (1) {
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <=n; j++) {
				for (int k = j+1; k <=n; k++) {
					if (i != j&&j != k&&k != i&&i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
import Data.Maybe
import Data.List
import Control.Monad

main = do
  _  <- getLine
  an <- map read . words <$> getLine :: IO [Integer]
  let ans = fromMaybe (-1) $ foldM solve 1 $ sort an
  print ans;
  
solve :: Integer -> Integer -> Maybe Integer
solve a b
 | a * b <= 10 ^ 18 = Just (a * b)
 | otherwise = Nothing

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

int N, M, K;
map<int, int> food;

int main() {
    cin >> N >> M;
    REP(i, N) {
        cin >> K;
        REP(i, K) { food[IN()]++; }
    }
    int ans = 0;
    FOREACH(f, food) {
        if(f.second == N) ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

vector<i64> factor(i64 x){
    vector<i64> res={x};
    for(i64 i=2; i*i<=x; ++i){
        if(x%i==0){
            res.push_back(i);
            if(i*i!=x) res.push_back(x/i);
        }
    }
    sort(begin(res),end(res));
    return res;
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

i64 mod_comb(i64 n, i64 k, i64 p) {
    if (n < 0 or k < 0 or n < k) return 0;
    //i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    i64 num = 1, den = 1;
    for (i64 i = 0; i < k; ++i) {
        num = num * ((n - i) % p) % p;
        den = den * (i + 1) % p;
    }
    return num * mod_inverse(den, p) % p;
}

void solve(){
    i64 N,M,mod=1'000'000'007;
    cin >> N >> M;

    if(M==1){
        cout << 1 << endl;
        return;
    }

    auto fs=factor(M);

    vector<map<i64,i64>> dp(32);
    ++dp[0][1];
    rep(i,0,31){
        for(auto& p:dp[i]){
            i64 x=p.first,cnt=p.second;
            for(i64 f:fs){
                i64 y=x*f;
                if(y>M) break;
                if(M%y!=0) continue;
                dp[i+1][y]+=cnt;
                dp[i+1][y]%=mod;
            }
        }
    }

    i64 ans=0;
    rep(i,0,32){
        ans+=dp[i][M]*mod_comb(N,i,mod);
        ans%=mod;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
	int N,M;
	cin>>N>>M;
	
	vector<int>oks(N+1,true);
	for(int i=0;i<M;++i){
		int a;cin>>a;
		oks[a]=false;
	}
	
	vector<long long int>dp(N+1);
	dp[0]=1;
	for(int now=0;now<N;++now){
		for(int next=now+1;next<=min(N,now+2);++next){
			if(oks[next]){
				dp[next]+=dp[now];
				dp[next]%=mod;
			}
		}
	}
	
	cout<<dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>

#define N 101
using namespace std;

int main(){

	int r , c;
	int ary[N][N];
	int ans_L[N] = {0} , ans_H[N] = {0};
	int sum = 0;

	cin >> r >> c; 

	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			cin >> ary[i][j];
			ans_L[i] += ary[i][j];
		}
	}for(int j = 1; j <= r; j++){
		for (int i = 1; i <= c; i++)
		{
			ans_H[i] += ary[j][i];
		}
	}

	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			cout << ary[i][j] << " ";
		}
		cout << ans_L[i] << endl;
		sum += ans_L[i];
	}for(int i = 1; i <= c; i++){
		cout << ans_H[i] << " ";
	}cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        for(int i = 1 ; i <= x ; i *= 2)
            ans = i;
        System.out.println(ans);
    }
}


Measured memory_bytes: 26196
#include<iostream>
#include<string>
#include<vector>
#include <math.h>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int main(){

    int K,A,B;
    cin >> K >> A >> B;
    bool flag = false;

    rep(i,1000){
        if(A <= K*i && K*i <= B)
            flag = true;
    }


    if(flag)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;

}

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

int bubblesort(vector<int> &A,int N){
  bool flag=true;
  int count=0;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>i;j--){
      if(A.at(j)<A.at(j-1)){
        swap(A.at(j),A.at(j-1));
        flag=true;
        count++;
      }
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int B=bubblesort(A,N);
  for(int i=0;i<N;i++){
    cout << A.at(i);
    if(i!=N-1){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
  cout << B << endl;
}
  


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< #X <<": "<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};

const int INF=100000000;
int mode=1;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
	int A, B, C, D;
	cin>>A>>B>>C>>D;
	long long x=A*B;
	long long y=C*D;
	if(x>y)
	cout<<x;
	else if(x<y)
	cout<<y;
	else
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
const int N=100005;
const int inf=1e18;
const double eps=1e-9;

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

int power(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
            res=res*a;
            res%=mod;
        }
        a=a*a;
        a%=mod;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,x,t;
    cin>>n>>x>>t;
    int c=0;
    c=n/x;
    if(n%x!=0){
        c++;
    }
    cout<<c*t;









	
return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
#define N 1000001
int p[N];
int dp[N];
int main() {
	int i, j;
	for (i = 2; i <= sqrt(N)+1; i++)if (!p[i])for (j = i*i; j < N;j+=i)p[j] = 1;
	int n, x, a;
	while (S(d, n), S(d, x), n) {
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (i = 0; i < n; i++) {
			S(d, a);
			for (j = a; j <= x; j++)
				if (dp[j - a])dp[j] = 1;
		}
		for (i = x; i; i--)
			if (!p[i] && dp[i]) { P(d, i); break; }
		if (!i)puts("NA");
	}
	return 0;
}

Measured memory_bytes: 8436
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double pi = acos(-1.0);
	int n;
	while(scanf("%d", &n), n){
		if(n % 3 == 0) n /= 3;
		double B = pi / 3.0 / n;
		printf("%f\n", sin(B) / sin(B + pi / 6.0) * 0.5 * n);
	}
}

Measured memory_bytes: 1088
n = int(input())
s = input()
cum = [0]*(n+1)
for i in range(1,n+1):
    cum[i] = cum[i-1]
    if s[i-1] == 'E':
        cum[i] += 1
cnt = n
for i in range(1,n+1):
    cnt = min(cnt, (i-1)-cum[i-1]+cum[n]-cum[i])
print(cnt)

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

int main(){
	int mx,mi;
	int a,b,c,d,e;
	int n;

	
	while(cin >> n && n){
		mx = 0;
		mi = (1<<21);
		while(n--){
			cin >> a >> b >> c >> d >> e;
			mi = min(a+b+c+d+e,mi); 	
			mx = max(a+b+c+d+e,mx);
		}
		cout << mx << " "<< mi << endl;
	}
}

Measured memory_bytes: 0
q,h,s,d=map(int,input().split())
n=int(input())
h=min(2*q,h)
s=min(2*h,s)
d=min(2*s,d)
ans=0
data=[[2,d],[1,s],[float(0.5),h],[float(0.25),q]]
for i in range(4):
  ans+=(int(n/data[i][0]))*data[i][1]
  n-=(int(n/data[i][0]))*data[i][0]
print(int(ans))

Measured memory_bytes: 9152
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

const int BLACK = 0;
const int WHITE = 1;

int dp[123456][2];
bool visited[123456]{false};
vector<vector<int>> g;

void dfs(int s){
	// 葉のとき
	if (s!=0 && g[s].size() == 1){
		dp[s][BLACK] = 1;
		dp[s][WHITE] = 1;
		return;
	}

	dp[s][BLACK] = 1;
	dp[s][WHITE] = 1;
	for (auto v : g[s]){
		if (visited[v]) continue;
		visited[v] = true;
		dfs(v);
		(dp[s][BLACK] *= dp[v][WHITE])%=mod;
		(dp[s][WHITE] *= (dp[v][WHITE] + dp[v][BLACK]))%=mod;
	}
}

signed main(){

	int N;
	cin >> N;
	g.assign(N, vector<int>());
	rep(i, N - 1){
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	visited[0] = true;
	dfs(0);

	cout << (dp[0][BLACK] + dp[0][WHITE])%mod << endl;



	return 0;
}


Measured memory_bytes: 11520
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int n, a, b, c, ans;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	vector<int> v(n);
	for(int i = 0; i < n; i++) scanf("%d", &v[i]);
	sort(v.begin(),v.end(),greater<int>());
	for(int i = 1; i < n; i++) v[i] += v[i-1];
	ans = c/a;
	for(int i = 0; i < n; i++) ans = max(ans,(c+v[i])/(a+b*(i+1)));
	printf("%d\n", ans);
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= b + 2) cout << 2 * a - 1 << endl;
    else if (b >= a + 2) cout << 2 * b - 1 << endl;
    else cout << a + b << endl;
}

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

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

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

  int mx = 0;
  rep(i, N) mx = max(mx, a[i]);

  sort(b.rbegin(), b.rend());
  int cnt = 1e9;
  int sum = 0;
  rep(i, N) {
    sum += b[i];
    if (H - sum > 0)
      cnt = min(cnt, (H - sum + mx - 1) / mx + i + 1);
    else
      cnt = min(cnt, i + 1);
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 998244353;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[3300];
int main(){
  ll n,k,ans=0;
  cin>>n;
  ll a1=n/500;
  ll a2=n%500;
  ll a3=a2/5;
  cout<<a1*1000+a3*5;
}



Measured memory_bytes: 256
import math
import sys
import collections

def main():
    N=int(input())
    Tr=list(input())
    R=[]
    G=[]
    B=[]
    for i in range(N):
       if Tr[i]=="R":
           R.append(i)
           continue
       if Tr[i]=="G":
           G.append(i)
           continue
       if Tr[i]=="B":
           B.append(i)
           continue
    cnt=len(R)*len(G)*len(B)
    for j in range(N):
        for i in range(j):
            if 2*j-i<=N-1:
                if Tr[2*j-i]!=Tr[i] and Tr[2*j-i]!=Tr[j] and Tr[j]!=Tr[i]:
                    cnt-=1
    print(cnt)
if __name__ == '__main__':
    main()

Measured memory_bytes: 68900
a=[]
for i in range(3):
	a.append(list(map(int,input().split())))
n = int(input())
for _ in range(n):
	b = int(input())
	for i in range(3):
		for j in range(3):
			if a[i][j]==b:
				a[i][j]=0
for i in range(3):
	flag = True
	for j in range(3):
		if a[i][j] != 0:
			flag = False
			break
	if flag:
		print("Yes")
		exit(0)

for i in range(3):
	flag = True
	for j in range(3):
		if a[j][i] != 0:
			flag = False
			break
	if flag:
		print("Yes")
		exit(0)

flag = True
for i in range(3):
	if a[i][i] != 0:
		flag = False
		break
if flag:
	print("Yes")
	exit(0)

if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<queue<LL>> battle;
LL numof_empty_of_battle = 0;//battleのうち、emptyなキューの数
 
LL ans = 0;

void solve(){
	//対戦そのものを型として持つキュー
	queue<pair<LL,LL>> battle_day;
	//選手iが対戦可能かを返す 可能なら対戦相手を返す
	auto is_ready = [&](LL i){
		LL enemy = battle[i].front();
		if(battle[enemy].empty()) return -1LL;
		if(battle[enemy].front()==i) return enemy;
		return -1LL;
	};
	//まず1日目にどんな試合があるかについて見ていく
	vector<int> reserved(N+1,0);
	for(int i=1;i<=N;i++){
		//選手iがもうすでに試合決定しているかどうかをreserved[i]とする
		if(reserved[i]) continue;
		LL enemy = is_ready(i);
		if(enemy>0 && !reserved[enemy]){
			battle_day.push(pair<LL,LL>(i,enemy));
			reserved[i] = 1;
			reserved[enemy] = 1;
		}
	}
	//day日目について見ていき、
	//キューにある今日の試合の処理ー＞翌日の試合をキューへ
	//といったことをする
	for(int day=1;;day++){
		//前日にひとつも試合を用意できていない時
		if(battle_day.empty()){
			if(numof_empty_of_battle==battle.size()-1){
				ans = day-1;
				if(!ans) ans = -1;
				return;
			}
			else{
				ans = -1;
				return;
			}
		}
		//キューにある試合を全部見にいく
		queue<pair<LL,LL>> prev_battle_day;//今回処理した試合を格納
		//cout << "\nbattle_day:" << endl;
		while(!battle_day.empty()){
			pair<LL,LL> fight = battle_day.front();battle_day.pop();
			prev_battle_day.push(fight);
			//printf("%lld vs %lld\n",fight.first,fight.second);

			battle[fight.first].pop();
			if(battle[fight.first].empty()) numof_empty_of_battle++;

			battle[fight.second].pop();
			if(battle[fight.second].empty()) numof_empty_of_battle++;
		}
		// for(int a=0;a<battle.size();a++){
		// 	printf("battle[%d].size()=%d\n",a,(int)battle[a].size());
		// }
		//翌日の試合のペアをそれぞれ1つづつ見た時、どれも必ず今日の試合に出た人を含む
		//よって今日の試合に出た人をprev_battle_dayから調べていく

		//選手iがもうすでに試合決定しているかどうかをreserved[i]とする
		vector<int> reserved(N+1,0);
		while(!prev_battle_day.empty()){
			pair<LL,LL> fight = prev_battle_day.front();prev_battle_day.pop();

			LL first_enemy = is_ready(fight.first);
			if(first_enemy>0 && !reserved[first_enemy] && !reserved[fight.first]){
				reserved[fight.first] = 1;
				reserved[first_enemy] = 1;
				battle_day.push(pair<LL,LL>(fight.first,first_enemy));
			}

			LL second_enemy = is_ready(fight.second);
			if(second_enemy>0 && !reserved[second_enemy] && !reserved[fight.second]){
				reserved[fight.second] = 1;
				reserved[second_enemy] = 1;
				battle_day.push(pair<LL,LL>(fight.second,second_enemy));
			}
		}
	}
}

int main(){
    cin >> N;
    battle = vector<queue<LL>>(N+1);
    for(int i=1;i<=N;i++){
    	for(int j=0;j<N-1;j++){
    		LL x;
    		cin >> x;
    		battle[i].push(x);
    	}
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8960