akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        vec: [i64; 5],
    }
    let mn = vec.into_iter().min().unwrap();
    let ans = if n % mn == 0 { n / mn } else { n / mn + 1 };
    println!("{}", 4 + ans);
}


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

int main() {
   int H,W;
   cin >> H >> W;
   string S[H];
   for (int i=0; i<H; i++) {
       cin >> S[i];
   }
   vector<vector<int>> X(H,vector<int> (W));
   for (int i=0; i<H; i++) {
       for (int j=0; j<W; j++) {
           if (j==0) {
               if (S[i][j]=='#') X[i][j]=0;
               else X[i][j]=1;
           }
           else {
               if (S[i][j]=='#') X[i][j]=0;
               else X[i][j]=X[i][j-1]+1;
           }
       }
       for (int j=W-2; j>=0; j--) {
           if (X[i][j]!=0) X[i][j]=max(X[i][j],X[i][j+1]);
       }
   }
   vector<vector<int>> Y(H,vector<int> (W));
   for (int j=0; j<W; j++) {
       for (int i=0; i<H; i++) {
           if (i==0) {
               if (S[i][j]=='#') Y[i][j]=0;
               else Y[i][j]=1;
           }
           else {
               if (S[i][j]=='#') Y[i][j]=0;
               else Y[i][j]=Y[i-1][j]+1;
           }
       }
       for (int i=H-2; i>=0; i--) {
           if (Y[i][j]!=0) Y[i][j]=max(Y[i][j],Y[i+1][j]);
       }
   }
   int count=0;
   for (int i=0; i<H; i++) {
       for (int j=0; j<W; j++) {
           int z=X[i][j]+Y[i][j];
           if (count<z) count=z;
       }
   }
   cout << count-1 << endl;
}

Measured memory_bytes: 42304
#include <iostream>
#include <cmath>

using namespace std;

int main(){

    int n;

    int t;

    int a;

    cin>>n;
    cin>>t>>a;

    int temp;

    int point = 0;

    double mostnear = 1000;

    for (int i = 1; i <= n; i++){
        cin >> temp;
        if(abs((double)t - (double)temp * 0.006 - (double)a) < mostnear){
            point = i;
            mostnear = abs((double)t - (double)temp * 0.006 - (double)a);
        }

    }

    cout<<point<<endl;

    return 0;
}

Measured memory_bytes: 256
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 string s;
 string t;
 cin>>s>>t;
 ll n=sz(s);
 ll m=sz(t);
 ll dp[n+1][m+1];
 fr(n+1)
 dp[i][0]=0;
 fr(m+1)
 dp[0][i]=0;
 rep(i,1,n+1)
 {
  rep(j,1,m+1){
    if(s[i-1]==t[j-1]){
      
      dp[i][j]=dp[i-1][j-1]+1;
    }
    else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
  }
 }

 vector<char> ans;
 ll i=n;
 ll j=m;
 while(i!=0&&j!=0){
  //cout<<i<<" "<<j<<endl;
 if(s[i-1]==t[j-1])
 {
//cout<<i<<" "<<j<<" "<<s[i-1]<<" "<<t[j-1]<<endl;
  ans.pb(s[i-1]);
  i-=1;
  j-=1;
 }
 else if(dp[i-1][j]>dp[i][j-1])
  i-=1;
else
  j-=1;
}
if(sz(ans)==0)
cout<<"";
//cout<<sz(ans)<<" "<<dp[n][m];
else{
for(int i=dp[n][m]-1;i>=0;i--)
{
  cout<<ans[i];
}
}
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 74016
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = [0] + h
dp = [float('inf')]*(N+1)
dp[0] = 0
dp[1] = 0
dp[2] = abs(h[2]-h[1])
for i in range(3,N+1):
  p = 1
  while p <= K and i-p > 0:
    dp[i] = min(dp[i],dp[i-p]+abs(h[i]-h[i-p]))
    p += 1
print(dp[N])

Measured memory_bytes: 55648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  ll ans = N/2;
  if (N % 2 == 0) ans--;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

// -val, minx
set<pii> S;

ll ans[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)S.insert(pii(-a[i],i));
  REP(i,n-1){
    auto it = S.begin();
    pii A = *(it++);
    pii B = *it;
    ll sz = i+1;
    ll av = -A.first;
    ll bv = -B.first;
    ll nxtv = bv;
    int id = A.second;
    int nxtid = min(A.second, B.second);
    ll sa = av-bv;
    ans[id] += sa*sz;
    S.erase(S.begin());
    S.erase(S.begin());
    S.insert(pii(-nxtv,nxtid));
  }
  ll rest = -(S.begin()->first);
  ans[0] += rest * n;
  REP(i,n)printf("%lld\n",ans[i]);
  return 0;
}


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

int main() {
    int N;
    const int d = 1000000000+7;
    cin >>N;
    long long power = 1;
    for(int i = 1;i<=N;i++){
        power = power*i; 
        power = power%d;
     }
     cout << power << endl;
}

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 REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

vll isp;
struct Sieve {
  vector<bool> isprime;

  void init(size_t max){
    if(max+1 > isprime.size()){     // resizeで要素数が減らないように
        isprime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    isprime[0] = false; // 0は素数ではない
    isprime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(isprime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                isprime[i*j] = false;      // 素数ではない

    REP(i, (int)max) {
      if(isprime[i]) isp.pb(i);
    }
  }
};


int main () {
  cin.tie(0);
  cout << setprecision(10);

  Sieve s;
  s.init(100000);

  while(1) {
    ll m, a, b; cin >> m >> a >> b;
    if(m == 0) break;
    ll ma = 0;
    P p;
    REP(i, SZ(isp)) {
      if(isp[i] > m) break;
      FOR(j, i, SZ(isp)) {
        if(isp[j] > m) break;
        if(isp[i] * isp[j] > m) break;
        if(isp[i] * b - isp[j] * a >= 0) {
          if(ma < isp[i] * isp[j]) {
            ma = isp[i] * isp[j];
            p = P(isp[i], isp[j]);
          }
        }
      }
    }
    cout << p.fi << " " << p.se << endl;
  }
}



Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const int mod = 109;
int cnt[mod];

int main(){
  while(int n = getInt()){
    int ans = -1;
    const int n2 = n / 2;

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

    for(int i = 0; i < n; i++){
      int a = getInt();
      int m = a % mod;
      if(++cnt[m] > n2) ans = a;
    }

    if(ans == -1)
      puts("NO COLOR");
    else
      printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;

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

  long long count = 0;

  for(int i=1; i<=N; i++) {
    if ( i%3 != 0 && i%5 != 0) {
      count += i;
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 3636
n = input()
nl = input()
nl = nl.split()
minn = maxn = sumn = int(nl[0])
for i in range(1,int(n)):
    minn = min(minn,int(nl[i]))
    maxn = max(maxn,int(nl[i]))
    sumn = sumn + int(nl[i])
else:
    print(minn,maxn,sumn)
    


Measured memory_bytes: 6312
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

    string dic = s;
    sort(ALL(dic));
    dic.erase(unique(ALL(dic)), dic.end());

    vector<string> ans;
    rep(i, dic.size()){
        rep(j, s.size())if(s[j] == dic[i]){
            string tmp = "";
            for(int k=j; k < min(j+5, int(s.size())); ++k){
                tmp = tmp + s[k];
                ans.push_back(tmp);
            }
        }
        sort(ALL(ans));
        ans.erase(unique(ALL(ans)), ans.end());
        if(ans.size() >= 5)break;
    }
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 1660
r, c = map(int,input().split())
print_list_sum = lambda l : print(" ".join(map(str,l)) + " " + str(sum(l)))
a = [list(map(int,input().split())) for _ in range(r)]
s = [0] * c
for i in range(r):
    for j in range(c):
        s[j] += a[i][j]
    print_list_sum(a[i])
print_list_sum(s)


Measured memory_bytes: 5692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

ll expmod(ll x, ll n, ll mod){
	if(n == 0) return 1;
	else if(n % 2 == 0){
		ll temp = expmod(x, n / 2, mod);
		return (temp * temp) % mod;
	}
	else{
		return (expmod(x, n - 1, mod) * x) % mod;
	}
}

ll modinv(ll x, ll mod){
	return expmod(x, mod - 2, mod);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a, b;
	cin >> a >> b;
	if(a > b) swap(a, b);
	forn(i, b) cout << a;
	cout << endl;
}		


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

def dfs(i,count):
    if i!="":
        if int(i)>N:
            return count
    if "3" in i and "5" in i and "7" in i:
        count+=1
    count=dfs("3"+i,count)
    count=dfs("5"+i,count)
    count=dfs("7"+i,count)
    return count
  
print(dfs("",0))

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

int n,s[12],freq[10000][2],count,change,ccc;
int i,j;

int main(){
	while(scanf("%d",&n)*n){
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		count=0;

		while(1){
			change=0;count++;ccc++;

			for(i=0;i<n;i++){
				if(freq[s[i]][2]<ccc){freq[s[i]][1]=1;freq[s[i]][2]=ccc;} else freq[s[i]][1]++;
			}

			for(i=0;i<n;i++){
				if(freq[s[i]][1]!=s[i])change=1;
				s[i]=freq[s[i]][1];
			}

			if(!change){count--;break;}

		}

		printf("%d\n",count);
		for(i=0;i<n;i++)printf("%d%c",s[i],i==n-1 ? '\n' : ' ');

	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int dfs(int n) {
    if(n <= 1) return 1;
    else return dfs(n/2)*2+1;
}

signed main() {
    int h;
    cin >> h;

    cout << dfs(h) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char c;
	int cnt=0;
	for(int i=0;i<h*w;++i){
		cin>>c;
		cnt+=c=='#';
	}
	cout<<(cnt==h+w-1?"P":"Imp")<<"ossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(322);

ll const mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n; vector<ll>a(n);
    for(ll i = 0; i<n;i++) cin >> a[i];
    ll ans = 0;
    for(ll i =0 ;i<n;i++){
        for(ll j = i+1;j<n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout << ans;
    return 0;
}
/*

*/

Measured memory_bytes: 256
N = int(input())
P = [float(v) for v in input().split()]
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

#  for i,p in enumerate(P,1): dp[i][0] = (1-p)
dp[0][0] = 1
dp[1][0] = P[0]

threshold = N // 2

ans = 0
for i in range(1,N+1):
    p = P[i-1]
    for j in range(0,N+1):
        if j != 0:
            dp[i][j] = (dp[i-1][j-1] * p) + dp[i-1][j] * (1-p)
        else:
            dp[i][j] = dp[i-1][j] * (1-p)

ans = 0

for i,v in enumerate(dp[N]):
    if i > threshold:
        ans += v
print(ans)


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

int n;
float x, ans=0;
string s;

int main(void){
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x >> s;
		if(s=="JPY") ans += x;
		if(s=="BTC") ans += x*380000;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
#define RREP(i,n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;

int main() {

    int H,W,N;
    cin >> H >> W >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];

    int ans[110][110];
    vector< pair<int,int> > idx;
    REP(i,H) {
        if (i % 2 == 0) {
            REP(j,W) idx.push_back(make_pair(i,j));
        } else {
            RREP(j,W) idx.push_back(make_pair(i,j));
        }
    }

    int cnt = 0;
    REP(i,a.size()) {
        REP(j,a[i]) {
            ans[idx[cnt].first][idx[cnt].second] = i + 1;
            cnt++;
        }
    }

    REP(i,H) {
        REP(j,W) cout << ans[i][j] <<  " ";
        cout << endl;
    }

    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    ll cnt = 0;
    for(ll i=N-1;i>=0;i--){
        if(((A[i]+cnt)%B[i])!=0){
            cnt += B[i] - ((A[i]+cnt)%B[i]);
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main()
{
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)(s1[0]-32) << (char)(s2[0]-32) << (char)(s3[0]-32);


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    
    vector<ll> a(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        
        a[i] -= i + 1;
    }
    
    sort(a.begin(), a.end());
    
    ll c = a[n / 2];
    
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ans += abs(c - a[i]);   
    }
    
    cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    for(int i=1; i<=N; ++i) cin >> A[i];

    vector<int> res(N + 1, 0);
    for(int i=N; i>=1; --i) {
        int tmp = 0;
        for(int j=2*i; j<=N; j+=i) tmp += res[j];
        if(tmp % 2 == 1 && A[i] == 0) res[i] = 1;
        else if(tmp % 2 == 0 && A[i] == 1) res[i] = 1;
    }

    cout << accumulate(begin(res), end(res), 0) << endl;
    for(int i=1; i<=N; ++i) {
        if(res[i]) cout << i << endl;
    }
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

static const int N = 60;

using namespace std;

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

    int n;
    array<int, N> v, c;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    for (int i = 0; i < n; i++)
        cin >> c[i];

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        const int now_val = v[i] - c[i];
        if(now_val>0)
            ans += now_val;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N, M, L;
  while(cin>>N>>M>>L){
    double P[100], T[100], V[100];
    REP(i, N) cin>>P[i]>>T[i]>>V[i];
    REP(i, N) P[i] /= 100;
    double p[100][51];
    double f[100][51];
    REP(i, N){
      REP(j, M + 1){
        f[i][j] = (double)L/V[i] + j * T[i];
        p[i][j] = pow(P[i], j) * pow(1 - P[i], M - j);
        REP(k, j) p[i][j] *= (M - k);
        REP(k, j) p[i][j] /= (k + 1);
      }
    }
    double a[100] = {};
    REP(i, N){
      REP(j, M + 1){
        double tp = p[i][j];
        REP(k, N) if(i != k){
          double p_k = 0;
          REP(l, M + 1){
            if(f[k][l] > f[i][j]){
              p_k += p[k][l];
            }
          }
          tp *= p_k;
        }
        a[i] += tp;
      }
      printf("%.8f\n", a[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	map<lint, lint> data;
	vector<lint> V(N);

	for (int i = 0; i < N; i++)
	{

		cin >> V[i];
		data[V[i]]++;
	}

	lint a = 0;
	for (auto to : data)
	{
		a += to.second * (to.second - 1) / 2;
	}

	for (int i = 0; i < N; i++)
	{
		lint c = data[V[i]] * (data[V[i]] - 1) / 2;
		lint d = (data[V[i]] - 1) * (data[V[i]] - 2) / 2;
		cout << a - c + d << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);


int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    ll n,m;
    cin>>n>>m;
    ll a=n-2;
    ll b=m-2;
    if(n==1 && m==1) cout<<n<<endl;
    else if(n==1) cout<<b<<endl;
    else if(m==1) cout<<a<<endl;
    else cout<<a*b<<endl;

return 0;
}



Measured memory_bytes: 256
S = input()

def dfs(start, S, curSum, res):
	if start >= len(S):
		res[0] += curSum
		return

    # put a plus on each space until last
	for i in range(start+1, len(S) + 1):
		dfs(i, S, curSum+int(S[start:i]), res)

	
res = [0]

dfs(0, S, 0, res)
print(res[0])

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  x %= 11;
  if (x >= 6) {
    ans++;
    x -= 6;
  }
  if (x > 0) { ans++; }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;
use std::mem::*;
use std::cell::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_3<T: FromStr, U: FromStr, V: FromStr>(&mut self) -> (T, U, V)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug,
          <V as FromStr>::Err: fmt::Debug {
        (self.read(), self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

const MOD: i64 = 1000000007;

thread_local! {
    static FACT_MEMO: RefCell<[i64; 200000]> = RefCell::new([0; 200000]);
}

fn fact(x: i64) -> i64 {
    FACT_MEMO.with(|rc| {
        let ux = x as usize;
        {
            let memo = rc.borrow();
            if memo[ux] > 0 {
                return memo[ux];
            }
        }
        let y = if x > 0 { x * fact(x - 1) % MOD } else { 1 };
        rc.borrow_mut()[ux] = y;
        y
    })
}
fn pow(a: i64, b: i64) -> i64 {
    if b > 0 {
        let y = pow(a * a % MOD, b >> 1);
        if b & 1 > 0 { a * y % MOD } else { y }
    } else {
        1
    }
}
fn inv(x: i64) -> i64 {
    pow(x, MOD - 2)
}
fn conb(a: i64, b: i64) -> i64 {
    fact(a) * inv(fact(b)) % MOD * inv(fact(a - b)) % MOD
}

fn f(n: i64, a: i64, b: i64, c: i64) -> i64 {
    let mut y = 0;
    let pa = pow(a * inv(a + b) % MOD, n);
    let ec = 100 * inv(100 - c) % MOD;
    for wb in 0..n {
        let pb = pow(b * inv(a + b) % MOD, wb);
        y += (n + wb) * ec % MOD * pa % MOD * pb % MOD * conb(n - 1 + wb, wb) % MOD;
        y %= MOD;
    } 
    y
}

fn run() {
    let mut ip = Input::new();
    let n = ip.read();
    let a = ip.read();
    let b = ip.read();
    let c = ip.read();

    let y = (f(n, a, b, c) + f(n, b, a, c)) % MOD;
    println!("{}", y);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(100 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 14204
#!python3

class Node:
    
    def __init__(self, num):
        self.num = num
        self.depth = 0
        self.parent = (None, None)


LI = lambda: list(map(int, input().split()))

# input
N = int(input())
AB = [LI() for _ in range(N - 1)]
M = int(input())
UV = [LI() for _ in range(M)]

# params
links = [[] for _ in range(N)]
nodes = [Node(i) for i in range(N)]
w = []
p2 = [2 ** i for i in range(51)]


def create_links():
    for i in range(N - 1):
        a, b = AB[i][0] - 1, AB[i][1] - 1
        links[a].append((b, i))
        links[b].append((a, i))


def create_tree(v, p=-1):
    for u, i in links[v]:
        if u == p:
            continue
        nodes[u].parent = (nodes[v], i)
        nodes[u].depth = nodes[v].depth + 1
        create_tree(u, v)


def between_links(s, t):
    x = nodes[s]
    y = nodes[t]
    if x.depth > y.depth:
        x, y = y, x
    s = set()
    while x.depth < y.depth:
        y, i = y.parent
        s.add(i)
    while x is not y:
        x, i = x.parent
        y, j = y.parent
        s.add(i)
        s.add(j)
    return s


def create_between_links():
    for u, v in UV:
        s = between_links(u - 1, v - 1)
        w.append(s)


def main():
    create_links()
    create_tree(0)
    create_between_links()
    
    ans = 0
    n = p2[M]
    for i in range(n):
        f = 0
        s = set()
        for j in range(M):
            if i >> j & 1:
                f += 1
                s |= w[j]
        v = p2[N - 1 - len(s)]
        if f % 2 == 0:
            ans += v
        else:
            ans -= v
    print(ans)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 44268
#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, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++) {
    int j = i;
    double x = 1;
    while(j<k) {
      x *= 0.5;
      j *= 2;
    }
    ans += x/n;
  }
  printf("%.10f\n", ans);
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(n-2):
    a = []
    a.extend([p[i], p[i+1], p[i+2]])
    s = set(a)
    if len(s)==3:
        a3 = sorted(a)
        if a3[1]==a[1]:
            ans += 1
    elif len(s)==2:
        if a[1]<a[2] and a[1]<a[0]:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  vector<int> a(5);
  rep(i,5){cin >> a[i];}
  int k; cin >> k;
  int flag=0;
  rep(i,5){
  	for (int j=i+1; j<5; j++){
      if (a[j]-a[i]>k){flag=1;break;}
    }
    if (flag==1) {break;}
  }
  
  if (flag) {cout << ":(" << endl;}
  else {cout << "Yay!" << endl;}

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n, t;
    cin >> n >> t;
    vector<vector<int>> c(n, vector<int> (2));
    rep(i, n) cin >> c[i][0] >> c[i][1];
    int mi = 10000;
    rep(i, n) {
        if(c[i][1] <= t) mi = min(mi, c[i][0]);
    }
    if(mi != 10000) cout << mi << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
 int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
 int ans=0;
 if(a+b<2*c){
   if(x<=y)ans=(a+b)*x+b*(y-x);
   else ans=(a+b)*y+a*(x-y);  
 }
 else {
     if(x<=y){
         if(2*c>b)ans=2*c*x+b*(y-x);
         else ans=2*c*x+2*c*(y-x);
     }
     else {
         if(2*c>a)ans=2*c*y+a*(x-y);
         else ans=2*c*y+2*c*(x-y);
     }
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	   String s=sc.next();
	   char prev=s.charAt(0);int count=0;
	   for(int i=1;i<s.length();i++)
	   {
	       if(s.charAt(i)!=prev)
	       {
	           count++;
	           prev=s.charAt(i);
	       }
	   }
	   System.out.println(count);}}

Measured memory_bytes: 25564
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 74740
using System;

namespace ABC139_B {
    class Program {
        static decimal A { get; }
        static decimal B { get; }
        static Program() {
            var inp = Console.ReadLine().Split();
            A = Convert.ToDecimal(inp[0]);
            B = Convert.ToDecimal(inp[1]);
        }
        static void Main(string[] args) {
            Console.WriteLine(Math.Ceiling((B - 1) / (A - 1)).ToString());
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	ll x, l = 1e9 + 3, r = 0; rep(i, n) cin >> x, l = min(x, l), r = max(r, x);
	
	print(r - l);
	
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ > 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on
ll n = 400004;
ll bit[400004] = {0};
ll mod = 998244353LL;

void add(int idx, int val) {
    for (++idx; idx < n; idx += idx & -idx)
        bit[idx] = (bit[idx] + val + mod) % mod;
}

void range_add(int l, int r, int val) {
    add(l, val);
    add(r + 1, -val);
}

int point_query(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret = (ret + bit[idx]) % mod;
    return ret;
}

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

    nxt2(ll, N, K);
    vector<pair<int, int>> ranges;
    rep(i, K) {
        nxt2(int, L, R);
        ranges.push_back(make_pair(L, R));
    }
    sort(all(ranges));

    range_add(1, 1, 1);

    for (int i = 1; i <= N; i++) {
        // cout << "i = " << i << endl;
        ll curr = point_query(i);
        for (auto ri : ranges) {
            // cout << "Add " << curr << " to " << i + ri.first << " : " << i + ri.second << endl;
            range_add(i + ri.first, i + ri.second, curr);
        }
        // for (int j = 1; j <= N; j++) {
        //     cout << point_query(j) << " ";
        // }
        // cout << endl;
    }
    ll res = point_query(N);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6672
#include <stdio.h>
int main (void){
    int i, ans=0;
    char S[20], T[20];
    scanf("%s%s", S, T);
    for(i=0;S[i]!='\0';i++){
        if(S[i]!=T[i]){
            ans+=1;
            break;
        }
    }
    if(ans==0){
        printf("Yes\n");
    }else printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int d;
	while (scanf("%d", &d) != EOF) {
		int area = 0;
		for (int i=0; i<600; i += d) area += i * i;
		printf ("%d\n", area * d);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>

#define N 123456
#define INI 0
#define NO 1
#define PRIME 2

using namespace std;

int main(void){

	int pri[2*N+2]={INI};
	int n,cnt;

	pri[0]=NO,pri[1]=NO;
	for(int i=2;i<=2*N;i++){
		if(pri[i]==INI){
			pri[i]=PRIME;
			for(int j=2*i;j<=2*N;j+=i){
				pri[j]=NO;
			}
		}
	}

	while(1){
		cin>>n;
		if(n==0) break;
		cnt=0;
		for(int i=n+1;i<=n*2;i++){
			if(pri[i]==PRIME) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int n,ans;
int a[N];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 20000
#define M 10000

main(){
  int i,j,a;
  unsigned short *b,*d;
  int c[M+1];
  scanf("%d",&a);
  b = malloc(sizeof(short)*a+1);
  d =  malloc(sizeof(short)*a+1);
 for(i=0;i<=M;i++){
    c[i]=0;
  }
  for(j=0;j<a;j++){
    scanf("%d",&b[j+1]);
    c[b[j+1]]++;
  }
 
  for(i=1;i<=M;i++){
    c[i]=c[i]+c[i-1];
  }
  for(j=a;j>=1;j--){
    d[c[b[j]]]=b[j];
    c[b[j]]--;
  }
  
  for(i=1;i<a;i++){
    printf("%d ",d[i]);
  }
  printf("%d\n",d[a]);
  return 0;
  }
  

Measured memory_bytes: 8456
#include <ios>
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);

	int n, i, m, c = 0, a[100] = {};
	cin >> n;
	for(i = 0; i < n; ++i)
		cin >> a[i];
	
	for(i = 0; i < n; ++i){
		m = i;
		for(int j = i; j < n; ++j){
			if( a[j] < a[m] )
				m = j;
		}
		if( m != i ){
			swap( a[i], a[m] );
			++c;
		}
	}

	for(i = 0; i < n; ++i){
		cout << a[i];
		if( i != n - 1 )
			cout << " ";
	}
	cout << "\n" << c << "\n";

	return 0;
}

Measured memory_bytes: 1200
while True:
  x, y = map(int, input().split())
  if x == 0:
    break
  mp = [[1] + list(map(int, input().split())) + [1] for _ in range(y)]
  mp.insert(0, [1] * (x + 2))
  mp.append([0] * (x + 2))
  mp.append([0] * (x + 2))
  tr = [[0] * (x + 2) for _ in range(y + 2)]
  
  for i in range(1, x + 1):
    if mp[1][i] == 0:
      tr[1][i] = 1
  
  for i in range(2, y + 1):
    for j in range(1, x + 1):
      if mp[i][j] == 0:
        for k in range(j - 1, j + 2):
          if mp[i - 1][k] == 0:
            tr[i][j] += tr[i - 1][k]
        if mp[i - 2][j] == 2:
          tr[i][j] += tr[i - 2][j]
  
      elif mp[i][j] == 2:
        if mp[i - 1][j] == 0:
          tr[i][j] += tr[i - 1][j]
        if mp[i - 2][j] == 2:
          tr[i][j] += tr[i - 2][j]
  
  ans = sum(tr[y])
  for i in range(1, x + 1):
    if mp[y - 1][i] == 2:
      ans += tr[y - 1][i]
  print(ans)


Measured memory_bytes: 5612
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
int main(void){
  int h,w,d;
  cin>>h>>w>>d;
  vii a(h,vi(w));
  vector<pair<int,int>> nextloc(h*w);
  rep(i,h)rep(j,w){
    cin>>a[i][j];
    a[i][j]--;
  }
  rep(i,h)rep(j,w){
    nextloc[a[i][j]]={i,j};
  }
  vi costs(h*w,0);
  rep(i,d){
    costs[i]=0;
    int now=i;
    int nowcost=0;
    while(now+d<h*w){
      int y=nextloc[now+d].first;
      int x=nextloc[now+d].second;
      costs[a[y][x]]=abs(y-nextloc[now].first)+abs(x-nextloc[now].second) +nowcost;
      nowcost=costs[a[y][x]];
      now=now+d;
    }
  }
  int q;
  cin>>q;
  vi l(q);
  vi r(q);
  rep(i,q){
    cin>>l[i]>>r[i];
    l[i]--;
    r[i]--;
  }
  /*rep(i,h*w){
    cout<<costs[i]<<endl;
  }*/
  rep(i,q){
    cout<<(costs[r[i]]-costs[l[i]])<<endl;
  }
  return 0;
}

Measured memory_bytes: 3328
import itertools

N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

ans = 0
for A in list(itertools.combinations_with_replacement(range(1, M+1), N)):
#    print(A)                                                                                          
    score = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            score += d[i]
    if ans < score:
        ans = score

#    print(A, score)                                                                                   
print(ans)


Measured memory_bytes: 21608
#include <stdio.h>
 
int main(void){
    int a, b;
    char op;
 
    for(;;){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?')
            break;
 
        printf("%d\n", op^'+' ? op^'-' ? op^'*' ? a/b : a*b : a-b : a+b);
    }
 
    return 0;
}


Measured memory_bytes: 2120
x,y = map(int,input().split())
if x == 1 and y == 1:print(int(10e5))
elif 1<=x<=3 and 1<=y<=3:
    print(int((8-x-y)*1e5))
elif 1<=x<=3:print(int((4-x)*1e5))
elif 1<=y<=3:print(int((4-y)*1e5))
else:print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
__int128 cost;
#define ld long double
#define li __int128
#define ll long long
#define int long long
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector <int> P(n*n);
    for(int i = 0; i < n*n; ++i)cin >> P[i];
    vector <vector <int> > a(n, vector <int> (n, 1)); //upd
    vector <vector <int> > u(n, vector <int> (n, 1)); //upd
    auto ok = [&](int c, int d){
        bool q = 1;
        if(c < 0 || d < 0 || c >= n || d >= n)q = 0;
        return q;
    };
    /*
    auto mi = [&](int c, int d){
        int w = a[c][d];
        if(ok(c-1,d)){w = min(w,a[c-1][d]);}
        if(ok(c+1,d)){w = min(w,a[c+1][d]);}
        if(ok(c,d+1)){w = min(w,a[c][d+1]);}
        if(ok(c,d-1)){w = min(w,a[c][d-1]);}
        //int r = min(min(c, n-c-1),min(d, n-d-1));
        a[c][d] = w;
    };*/
    function <void(int,int)> up = [&](int c, int d){
        int w = a[c][d] + u[c][d];
        int x;
        if(ok(c-1,d)){if(a[c-1][d] != (x = min(w,a[c-1][d]))){a[c-1][d]=x;up(c-1,d);}}
        if(ok(c+1,d)){if(a[c+1][d] != (x = min(w,a[c+1][d]))){a[c+1][d]=x;up(c+1,d);}}
        if(ok(c,d+1)){if(a[c][d+1] != (x = min(w,a[c][d+1]))){a[c][d+1]=x;up(c,d+1);}}
        if(ok(c,d-1)){if(a[c][d-1] != (x = min(w,a[c][d-1]))){a[c][d-1]=x;up(c,d-1);}}

    };
    function <void(int,int)> up2 = [&](int c, int d){
        int w = a[c][d];
        int x;
        if(ok(c-1,d)){if(a[c-1][d] != (x = min(w,a[c-1][d]))){a[c-1][d]=x;up(c-1,d);}}
        if(ok(c+1,d)){if(a[c+1][d] != (x = min(w,a[c+1][d]))){a[c+1][d]=x;up(c+1,d);}}
        if(ok(c,d+1)){if(a[c][d+1] != (x = min(w,a[c][d+1]))){a[c][d+1]=x;up(c,d+1);}}
        if(ok(c,d-1)){if(a[c][d-1] != (x = min(w,a[c][d-1]))){a[c][d-1]=x;up(c,d-1);}}

    };

    int odp = 0;
    for(int h = 0; h < n*n; ++h){
        int i = P[h] - 1;
        int wi = i/n;
        int kol = i%n;
        a[wi][kol] = min(min(wi, n-wi-1),min(kol, n-kol-1));
    }

    for(int h = 0; h < n*n; ++h){
        int i = P[h] - 1; 
        int wi = i/n;
        int kol = i%n;
        odp += a[wi][kol];
        u[wi][kol] = 0;
        //mi(wi,kol);
        up(wi,kol);


    }
    cout << odp << '\n';
}


Measured memory_bytes: 46964