akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int tap = 0;
    int socket = 1;
    while(true){
        if(socket >= b)
            break;

        socket = socket + a - 1;
        tap++;
    }

    cout << tap << endl;

    return 0;
}

Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
	input = myconv(input,2);
  myout(input[1]+input[0])
}
Main(myin());

Measured memory_bytes: 21064
// In the name of Allah the Lord of the Worlds.

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

int main(void)
{
    int n;
    vector<int>v;
    cin >> n;
    for(int i=0;i<n;i++){

        int in;
        scanf("%d",&in);
        v.push_back(in);
    }

    sort(v.begin() , v.end());

    int sum = 0;
    int c = 0;
    for(int i=n-1;i>=0;i--){

        if(c%2)sum-=v[i];
        else sum+=v[i];
        c++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

int readInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


vector<vector<int>> v(200020);
ll n,c[200020];
vector<vector<ll>> cnt(200020);
ll rem[200020];

int dfs(int p, int pre){
    int ret = 1;
    for(auto i:v[p]){
        if(i != pre){
            int t = dfs(i,p);
            cnt[p].push_back(t);
            ret += t;
        }
    }
    rem[p] = n - ret;
    return ret;
}

ll ans[200020];
ll used[200020];

void f(int p,int pre){
    ll sum = 0;
    for(auto i:cnt[p]){
        sum += i;
    }
    ans[c[p]] += sum + rem[p] - used[c[p]]+1;
    ans[c[p]] += (rem[p] - used[c[p]]) * sum;
    ll tmp = sum;
    for(auto i:cnt[p]){
        sum -= i;
        ans[c[p]] += i*sum;
    }
    int k = 0;
    for(auto i:v[p]){
        if(i != pre){
            int t = used[c[p]];
            used[c[p]] = rem[i];
            f(i,p);
            used[c[p]] = t;
            k++;
        }
    }
    used[c[p]] += tmp+1;
}


signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(20);

    n = readInt();
    for(int i=0;i<n;i++){
        c[i] = readInt();
        c[i]--;
    }
    for(int i=1;i<n;i++){
        int a = readInt(), b = readInt();
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0,-1);
    f(0,-1);
    for(int i=0;i<n;i++){
        printf("%ld\n",ans[i]);
    }
}


Measured memory_bytes: 49896
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{   
    ll l,r;
    cin >> l >> r;
    ll dif = (r - l + 1);
    if(dif>=2020)    
    {
        cout<<"0\n";
    }
    else
    {
        ll ans = 1e18;
        for(ll i=l;i<=r;i++)
        {
            for(ll j=i+1;j<=r;j++)
            {
                ll temp = i*j;
                temp %= 2019;
                ans = min(ans,temp);
            }
        }
        cout<<ans;
    }
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
} 

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
	double r;
	cin >> r;
	cout << setprecision(20);
	cout << (M_PI*r*r) << " " << (2 * M_PI*r) << endl;
	return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n,k;
	cin>>n>>k;

	ll mi=n;
	n%=k;
	mi=min(mi,n);
	cout<<min(mi,k-n)<<endl;

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny")
  cout << "Cloudy" << endl;
  else if(S == "Cloudy")
  cout << "Rainy" << endl;
  else
  cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, M, S, T;
  cin >> N >> M >> S >> T;
  S--; T--;
  vector<vector<pair<int64_t,int64_t>>> GY(N,vector<pair<int64_t,int64_t>>(0));
  vector<vector<pair<int64_t,int64_t>>> GS(N,vector<pair<int64_t,int64_t>>(0));
  pair<int64_t,int64_t> P;
  for(int i=0; i<M; i++){
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    P = make_pair(b,c);
    GY.at(a).push_back(P);
    P = make_pair(a,c);
    GY.at(b).push_back(P);
    P = make_pair(b,d);
    GS.at(a).push_back(P);
    P = make_pair(a,d);
    GS.at(b).push_back(P);
  }
  
  int64_t INF = 1e18;
  vector<int64_t> D1(N,INF); //startからyenでの距離
  vector<int64_t> D2(N,INF); //goalからsnukeでの距離
  
  priority_queue<pair<int64_t,int64_t>, vector<pair<int64_t,int64_t>>, greater<pair<int64_t,int64_t>>> PQ;
  P = make_pair(0,S);
  PQ.push(P);
  D1.at(S) = 0;
  while(PQ.size()){
    P = PQ.top();
    int64_t x = P.first;
    int64_t y = P.second;
    PQ.pop();
    if(D1.at(y) < x){
      continue;
    }
    for(int i=0; i<GY.at(y).size(); i++){
      P = GY.at(y).at(i);
      int64_t a = P.first; //to
      int64_t b = P.second;  //cost
      if(D1.at(a) > x + b){
        D1.at(a) = x + b;
        P = make_pair(D1.at(a),a);
        PQ.push(P);
      }
    }
  }
  
  P = make_pair(0,T);
  PQ.push(P);
  D2.at(T) = 0;
  while(PQ.size()){
    P = PQ.top();
    int64_t x = P.first;
    int64_t y = P.second;
    PQ.pop();
    if(D2.at(y) < x){
      continue;
    }
    for(int i=0; i<GS.at(y).size(); i++){
      P = GS.at(y).at(i);
      int64_t a = P.first; //to
      int64_t b = P.second;  //cost
      if(D2.at(a) > x + b){
        D2.at(a) = x + b;
        P = make_pair(D2.at(a),a);
        PQ.push(P);
      }
    }
  }
 
  
  vector<int64_t> use(N);
  for(int i=0; i<N; i++){
    use.at(i) = D1.at(i) + D2.at(i);
  }

  int64_t MIN = 1e18;
  vector<int64_t> ans(N);
  for(int i=N-1; i>=0; i--){
    MIN = min(MIN,use.at(i));
    ans.at(i) = 1e15 - MIN;
  }
  
  for(int i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }

}


Measured memory_bytes: 20344
#include <bits/stdc++.h>
using namespace std;
const int Maxn=5005;
int n;
char s[Maxn],t[Maxn];
int pool1[2*Maxn],pool2[2*Maxn],*a=pool1+Maxn,*b=pool2+Maxn;
int main(){
    cin>>n>>(s+1)>>(t+1);
    int cnta=0,cntb=0,ans=INT_MAX;
    if(s[1]!=t[1])a[++cnta]=0;
    for(int i=1;i<n;i++)
        if(s[i]!=s[i+1])
            a[++cnta]=i;
    for(int i=1;i<n;i++)
        if(t[i]!=t[i+1])
            b[++cntb]=i;
    for(int i=cnta+1;i<=n;i++)a[i]=n;
    for(int i=cntb+1;i<=n;i++)b[i]=n;
    for(int i=-n;i<=n;i++){
        if(i&1)continue;
        int sum=0;
        for(int delta=-n;delta<=n;delta++){
            int pos=i+delta;
            if(pos>n)sum+=n-b[delta];
            else if(pos<-n)sum+=b[delta];
            else sum+=abs(a[pos]-b[delta]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    rep(i, S.size()) {
        if(i < A) {
            if(!(S[i] - '0' >= 0 && S[i] - '0' <= 9)) {
                cout << "No" << endl;
                return 0;
            }
        } else if(i == A) {
            if(!(S[i] == '-')) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(!(S[i] - '0' >= 0 && S[i] - '0' <= 9)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a>=3200) cout << s;
    else cout << "red";
    cout << endl;   
}

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

int main() {
  int a,b;
  string s;
  cin >> a >> b >> s;
  bool flag = true;
  for(int i=0;i<a;i++){
    if( s.at(i) < 48 || s.at(i) > 57 ) flag = false;
  }
  
  if( s.at(a) != '-' ) flag = false;
  
  for(int i=a+1;i<=a+b;i++){
    if( s.at(i) < 48 || s.at(i) > 57 ) flag = false;
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 25 18:21:29 2018
ABC107B
@author: maezawa
"""

h, w = list(map(int, input().split()))
lattice = []
for i in range(h):
    hi = input()
    if '#' not in hi:
        continue
    else:
        lattice.append(hi)

#print(*lattice, sep='\n')

hn = len(lattice)
rem = []
for i in range(w):
    flag = 0
    for s in lattice:
        if s[i] == '#':
            flag = 1
            break
    if flag == 0:
        rem.append(i)
        
newlattice = []

for s in lattice:
    for i in reversed(range(w)):
        if i in rem:
            if i == w:
                s = s[:i]
            else:
                s = s[:i]+s[i+1:]
    newlattice.append(s)

for s in newlattice:
    print(s)

        
        

Measured memory_bytes: 3064
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line.split_whitespace().map(String::from).collect();
        self.index = 0;
    }
}

fn main() {
    const NMAX: usize = 10000;
    let mut count = vec![0; NMAX + 1];

    const LIMIT: i64 = 200;
    for i in 1..LIMIT {
        for j in 1..LIMIT {
            for k in 1..LIMIT {
                let value = i.pow(2) + j.pow(2) + k.pow(2) + i * j + j * k + i * k;
                if value as usize <= NMAX {
                    count[value as usize] += 1;
                }
            }
        }
    }

    let mut reader = TokenReader::new();
    let n: usize = reader.next();
    for i in 1..n + 1 {
        println!("{}", count[i]);
    }
}


Measured memory_bytes: 2168
n=int(input())
A=list(map(int,input().split()))
idx=dict()
mod=10**9+7
for i in range(1+n):
    if A[i] in idx:
        x=idx[A[i]]
        y=i
        break
    idx[A[i]]=i
kaijo=[1]
for i in range(1,n+2):
    kaijo.append((kaijo[-1]*i)%mod)
gyaku=[pow(kaijo[n+1],mod-2,mod)]
from collections import deque
gyaku=deque(gyaku)
for i in range(n+1,0,-1):
    gyaku.appendleft((gyaku[0]*i)%mod)
gawa=n-1-(y-x-1)
zentai=n-1
gawa_conb=[1]
for i in range(1,1+gawa):
    if i<1+gawa//2:
        gawa_conb.append((kaijo[gawa]*gyaku[i]*gyaku[gawa-i])%mod)
    else:
        gawa_conb.append(gawa_conb[gawa-i])
gawa_conb+=[0]*(zentai-gawa)
zentai_conb=[1]
for i in range(1,1+zentai):
    if i<1+zentai//2:
        zentai_conb.append((kaijo[zentai]*gyaku[i]*gyaku[zentai-i])%mod)
    else:
        zentai_conb.append((zentai_conb[zentai-i]))
if n>1:
    print((zentai_conb[1]+zentai_conb[0]*2-gawa_conb[0])%mod)
    for i in range(2,n):
        print((zentai_conb[i-2]+zentai_conb[i]+zentai_conb[i-1]*2-gawa_conb[i-1])%mod)
    print((zentai_conb[n-2]+zentai_conb[n-1]*2-gawa_conb[n-1])%mod)
    print((zentai_conb[n-1])%mod)
else:
    print(1)
    print(1)

Measured memory_bytes: 29524
n = int(input())
a = list(map(int, input().split()))

m = [0] * (n+1)
mx = 1
for i in range(n+1):
    mx -= a[i]
    m[i] = mx

    if (mx <= 0 and i != n) or (mx < 0 and i == n):
        print(-1)
        exit()
    mx *= 2

a.reverse()
m.reverse()
m[0] = a[0]
for i in range(1, n+1):
    m[i] = min(m[i], m[i-1]) + a[i]

print(sum(m))


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

using namespace std;


ifstream fin("date.in");
ofstream fout("date.out");

const int Nmax = 1e6 + 50;

int main()
{
  int x, y, z;

  cin >> x >> y >> z;

  int sum = y + z;

  cout << (x - z) / sum;
  
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> p(n);
	for (auto &v : p) {
		cin >> v;
	}

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		int mid = p[i + 1];

		vector<int> vec;
		vec.push_back(p[i]);
		vec.push_back(p[i + 1]);
		vec.push_back(p[i + 2]);
		sort(begin(vec), end(vec));

		if (mid == vec[1]) {
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int A, B;
   cin >> A >> B;
   if (A <= B) {
      cout << "Impossible\n";
      return 0;
   }
   int N = A + B;
   vector<int> st;
   for (int i = 0; i < N; ++i) {
      if (st.empty()) {
         st.emplace_back(i);
      } else {
         cout << "? " << i << " " << st.back() << endl;
         char ans;
         cin >> ans;
         if (ans == 'N') {
            st.pop_back();
         } else {
            st.emplace_back(i);
         }
      }
   }
   int z = st[0];
   string S;
   for (int i = 0; i < N; ++i) {
      cout << "? " << z << " " << i << endl;
      char ans;
      cin >> ans;
      if (ans == 'Y') {
         S += '1';
      } else {
         S += '0';
      }
   }
   cout << "! " << S << endl;
   return 0;
}

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

int main(){
string s;
cin>>s;
int ca=0;
int cb=0;

for(int i=0;i<s.length();i++){
    if(s[i]=='A')
        ca++;
        else
            cb++;
}
if(ca==0||cb==0)
    cout<<"No"<<endl;
else
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<unordered_map>
#include<complex>
#include<cstring>
#include<iostream>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int,2>
typedef long long LL;
typedef complex<double> cp;
const LL P = 200003;
const LL INF = 1e18;
const int N = 524300, Q = sqrt(P);
const double PI = acos(-1);
//mt19937 rng(time(0));
 
int n, m, x[N], root, p[N], degree[N], id[N];
LL cnt[N];
cp a[N];

LL pw(LL x, LL n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%P) if(n&1) res = res * x % P;
	return res;
}

void calcDgr(){
	unordered_map<LL, int> pws;
	LL tmp=1;
	rep(i,0,Q) pws[tmp]=i,tmp=tmp*root%P;
	rep(x,2,P-1) if(p[x]==x) rep(i,0,P/Q+1){
		tmp = pw(root, P-1-i*Q%(P-1)) * x % P;
		if(pws[tmp]) { degree[x] = pws[tmp]+i*Q; break; }
	}
	pws[1] = 0;
	rep(x,2,P-1) degree[x] = (degree[x/p[x]] + degree[p[x]]) % (P-1);
}

void fft(cp a[], int n, int t){
	rep(i,0,n-1) if(i<id[i]) swap(a[i],a[id[i]]);  //逆变换的时候再swap一次，正好变回原顺序 
	for(int h=2; h<=n; h<<=1){
		cp wn(cos(2*PI/h), t*sin(2*PI/h));
		for(int j=0; j<n; j+=h){
			cp w(1,0), tmp;
			rep(k, j, j+(h>>1)-1){
				tmp = a[k+(h>>1)] * w;
				a[k+(h>>1)] = a[k] - tmp;
				a[k] += tmp;
				w *= wn;
			}
		}
	}
	if(t==-1) rep(i,0,n-1) a[i] /= n;
}

int main(){
	//find the primitive root
	for(LL x=2;;++x){
		bool flag = true;
		for(LL i=2;i*i<=P-1;++i) if((P-1)%i==0 && pw(x,(P-1)/i)==1) {
			flag = false; break;
		}
		if(flag){
			//cout<<"primitive root = "<<x<<endl;
			root = x; break;
		}
	}
	
	rep(i,2,P) p[i] = i;
	rep(i,2,P) if(p[i]==i)
		for(int j=i+i;j<=P;j+=i) p[j]=i;
	calcDgr();
	//rep(x,1,10)cout<<degree[x]<<",";cout<<endl;
	
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&x[i]);
		//cout<<x[i]<<" "<<degree[x[i]]<<endl;
		if(x[i]) cnt[degree[x[i]]]++;
	}
	for(m=1;m<=(P<<1);m<<=1);
	rep(i,0,P) a[i] = cnt[i];
	rep(i,0,m-1) id[i] = (id[i>>1]>>1)|(i&1?m>>1:0);
	
	fft(a,m,1); rep(i,0,m-1) a[i] *= a[i]; fft(a,m,-1);
	
	memset(cnt,0,sizeof cnt);
	rep(i,0,m) cnt[i%(P-1)] += (LL)(a[i].real()+.5);
	LL ans = 0;
	rep(i,0,P-2){
		//if(cnt[i]) cout<<i<<" "<<cnt[i]<<endl;
		ans += 1ll * cnt[i] * pw(root, i);
	}
	rep(i,1,n) ans -= 1ll * x[i] * x[i] % P;
	
	cout<<ans/2ll<<endl;
	return 0;
}

Measured memory_bytes: 26848
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 4010
using namespace std;

ll a, b, c, n, m, num;
char s[N];

inline ll read(){ 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(); 
	REP(i, 1, n){
		s[i] = getchar();
		if (s[i] == 'R') a++;
		else if (s[i] == 'G') b++;
			else c++;
	}
	num = a * b * c, m = (n - 3) >> 1;
	REP(i, 0, m)
		for (ll j = 1; j + 2 * i + 2 <= n; ++j)
			if (s[j] != s[j + i + 1] && s[j + i + 1] != s[j + 2 * i + 2] && s[j + 2 * i + 2] != s[j]) num--;
	printf("%lld\n", num);
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3780
/* 163-A.cpp
 *     Created on : Apr 19, 2020 
 *     Time       : 5:57:48 PM
 *     Author     : null_ptr
 */
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

const double pi=acos(-1);

int main()
{
	int n;
	cin>>n;
	cout<<setprecision(9)<<fixed<<pi*2.0*n<<'\n';
}


Measured memory_bytes: 3780
# ABC125 C - GCD on Blackboard
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))

l = n*[0]
r = n*[0]
ans = 0

for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

for i in range(n-1,0,-1):
    r[i-1] = gcd(r[i],a[i])

for i in range(n):
    ans = max(ans,gcd(l[i],r[i]))
print(ans)



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

int main() {

  int A, B;
  cin >> A >> B;
  
  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
//const int MOD = 1e9 + 7;

ll N, M, K, Q, D;
string S;

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

    int base = 1;
    for (int i = 0; i < D; i++) {
        base *= 100;
    }

    if (N != 100) {
        cout << base * N << endl;
    } else {
        cout << base * 101 << endl;
    }

    return 0;
}


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

using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> node[limit];
ll dist[limit];

void dfs(int v, int p, ll d) {
    dist[v] = d;
    for(auto &e: node[v]) {
        if(e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

int main() {
    int i, N, Q, K, a, b, c, x, y;

    cin >> N;
    for(i=0; i<N-1; ++i) {
        cin >> a >> b >> c;
        --a, --b;
        node[a].push_back({b, c});
        node[b].push_back({a, c});
    }

    cin >> Q >> K;
    --K;
    dfs(K, -1, 0);

    for(i=0; i<Q; ++i) {
        cin >> x >> y;
        --x, --y;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
struct edge{int to;ll cost;};
vector<vector<edge>> G;
int main(){
    int n,m;cin>>n>>m;
    G.resize(n);
    for(int i=0;i<m;i++){
        int u,v;ll c;cin>>u>>v>>c;--u;--v;
        G[u].push_back({v,-c});
    }
    vector<ll> d(n,LINF);
    d[0]=0;
    bool f=false;
    for(int i=0;i<2*n;i++){
        for(int j=0;j<n;j++){
            if(d[j]==LINF)continue;
            for(auto e:G[j]){
                if(d[e.to]>d[j]+e.cost){
                    d[e.to]=d[j]+e.cost;
                    if(i>=n-1&&e.to==n-1)f=true;
                }
            }
        }
    }
    if(f){
        cout<<"inf"<<endl;
        return 0;
    }
    cout<<-d[n-1]<<endl;
}   


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

int main(void){
	
	int a,b;
	
	cin>>a>>b;

	if(a>b){
		if(b==1){
			cout<<"Bob"<<endl;
		}
		else{
			cout<<"Alice"<<endl;
		}
	}
	else if(a==b){
		cout<<"Draw"<<endl;
	}
	else{
		if(a==1){
			cout<<"Alice"<<endl;
		}
		else{
			cout<<"Bob"<<endl;
		}
	}

	
	return 0;
}


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

using namespace std;
#define int long long
#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

signed main() {
    char c;
    cin >> c;
    cout << (char)(c+1)<<endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextInt();
        long r = sc.nextInt();
        long min = 2018;
        
        if (r - l <= 3000) {
            for (long i = l; i <= r - 1; i++) {
                for (long j = i + 1; j <= r; j++) {
                    long mod = i * j % 2019;
                    if (mod < min) {
                        //System.out.println(i + ", " + j);
                        min = mod;
                    }
                }
            }
        } else {
            min = 0;
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
/* ex4_1
   KKOO  */

#include <stdio.h>
//ceil関数を使うために導入
#include <math.h>
//プロトタイプ宣言
int put_watchman(float tree, float view_width);

int main(void){
    float num_n, num_d;
    int ans;
    //木の本数と視界の幅を入力
    scanf("%f %f", &num_n, &num_d);

    ans = put_watchman(num_n, num_d);
    printf("%d\n", ans);

    return 0;
}

//関数の定義
int put_watchman(float tree, float view_width){
    int watchman, view;
    //監視員は一度に(視界の幅*２＋１)本の木を見られる
    view = view_width * 2 + 1;
    //木の本数÷監視員の視界をして割り切れなければ1人追加する
    watchman = ceil( tree / view );
    return watchman;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    vector<double> V(N);
    for (auto &x : V) {
        cin >> x;
    }
    sort(V.begin(), V.end());
    double ans = V.at(0);
    for (int i = 1; i < N; ++i) {
        ans = (V.at(i) + ans) / 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main(void){

    ll N;
    cin >> N;
    
    ll W[N];
    for(int i=0; i<N; i++){
        cin >> W[i];
    }
    
    ll T;
    
    ll S1, S2;
    ll min = 10000;
    
    for(T=0;T<N-1;T++){
        S1=0;
        S2=0;
        for(ll i=0; i<=T; i++){
            S1 += W[i];
        }
        for(ll i=T+1; i<N; i++){
            S2 += W[i];
        }
       //cout << abs(S1-S2) << "\n";
        if(abs(S1-S2)<min){
            min = abs(S1-S2);
        }
        
    }
    
    cout << min << endl;
    

    return 0;
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;
int n = 0, m = 0;
int a[MAXN];
int b[MAXN];


int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	if(a.size() == n){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}


    return 0;
} 

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--)
using ll = long long;
using namespace std;

ll x[120],y[120],h[120];
int main(){
    ll n,sx=0,sy=0,s=0,m=0,tmp=0,st=0,cnt=0;
    cin>>n;
    bool p=true;
    rep(i,0,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,0,n)if(h[i]>0){st=i;cnt++;}
    rep(i,0,101){
        rep(j,0,101){
            s=abs(i-x[st])+abs(j-y[st])+h[st];
            p=true;
            rep(k,0,n){
                if(h[k]==0)continue;
                if(abs(i-x[k])+abs(j-y[k])+h[k]!=s){p=false;break;}
            }
            if(p) {sx=i;sy=j;m=max(m,s);}
        }
    }
    rep(i,0,n)if(tmp<h[i]){tmp=h[i];st=i;}
    if(cnt>1 &&m>tmp)cout<<sx<<" "<<sy<<" "<<m<<endl;
    else cout<<x[st]<<" "<<y[st]<<" "<<h[st]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  int ans = 0;
  rep(i,n){
    ans += 2*min(a.at(i),k-a.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
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>;
ll p[100005],x[100005],n,m,k,diff[100005];
vl expo(ll k)
{
    vl v;
    if(k==1)
    {
        v.pb(0);
        rep(i,1,n)
            v.pb(p[i]);
            return v;
    }
    vl g=expo(k/2);
    vl temp=g;
    rep(i,1,n)
    temp[i]=g[g[i]];
    g=temp;
    if(k&1)
    {
        rep(i,1,n)
            temp[i]=g[p[i]];
    }
    return temp;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    rep(i,1,n+1)
    cin>>x[i];
    rep(i,1,n)
        diff[i]=x[i+1]-x[i];
    cin>>m>>k;
    rep(i,1,n)
        p[i]=i;
    ll a;
    rep(i,0,m)
    {
        cin>>a;
        swap(p[a-1],p[a]);
    }
    vl g=expo(k);
    vl temp;
    temp.pb(0);
    rep(i,1,n)
        temp.pb(diff[i]);
    rep(i,1,n)
        diff[i]=temp[g[i]];
    vl f;
    f.pb(x[1]);
    rep(i,1,n)
        f.pb(f.back()+diff[i]);
    rep(i,0,n)
    cout<<f[i]<<"\n";
}


Measured memory_bytes: 7252
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define KDNGU ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first

using namespace std;

typedef long long LL;
typedef long double LD;

const int N = 1e5 + 9, M = 1e3 + 9, OO = 0x3f3f3f, MOD = 1e9 + 7;


int dp[N][3];
int happiness[N][3];

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];

    for (int i = 0; i < 3; ++i) dp[0][i] = happiness[0][i];

    for (int i = 1; i < n; ++i)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; ++k)
                if (j != k)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + happiness[i][j]);

    cout << *max_element(dp[n - 1], dp[n - 1] + 3);

}
/*
    GOOD LUCK :*
*/


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const ll LLINF = LLONG_MAX/3;

int main(){
	int N;
	cin >> N;
	vector<int> dir(N);
	string S;
	cin >> S;
	REP(i, N) dir[i] = (S[i]=='W');
	vector<int> dir_sum(N+1);
	dir_sum[0] = 0;
	REP(i, N) dir_sum[i+1] = dir_sum[i] + dir[i];
	ll res = LLINF;
	REP(i, N){
		ll left_west = dir_sum[i] - dir_sum[0];
		ll right_west = dir_sum[N] - dir_sum[i+1];
		res = min(res, left_west + (N-i-1-right_west));
	}
	cout << res << endl;
    return 0;
}

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

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))

Measured memory_bytes: 3188
a,b,c=map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
  print(0)
else:
  temp=max(a,b,c)//2  
  print(min(a,b,c)*(a+b+c-min(a,b,c)-max(a,b,c))*abs(temp-max(a,b,c)+temp))

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int32_t main() {

    int n, k; cin >> n >> k;
    vector<pair<int, int>> dt(n);
    for(int i = 0; i < n; ++i) cin >> dt[i].second >> dt[i].first;

    sort(dt.rbegin(), dt.rend());

    unordered_set<int> seen;

    priority_queue<int, vector<int>, greater<int>> pq;

    int ret = 0, cur = 0;
    for(int i = 0; i < k; ++i) {
        int t = dt[i].second, d = dt[i].first;
        if(seen.find(t) == seen.end()) {
            seen.insert(t);
        } else {
            pq.push(d);
        }
        cur += d;
    }
    ret = cur + seen.size()*seen.size();

    for(int i = k; i < n; ++i) {
        int t = dt[i].second, d = dt[i].first;
        if(seen.find(t) == seen.end()) {
            if(pq.size() > 0) {
                seen.insert(t);
                cur -= pq.top();
                cur += d;
                pq.pop();
                int cand = cur + seen.size()*seen.size();
                ret = max(ret, cand);
            }
        }
    }

    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 5516
#include<bits/stdc++.h>
using namespace std;
int a,b,sum;
char s[100001];
int main()
{
	cin>>a>>b;
	for(int i=1;i<=a+b+1;i++)
		cin>>s[i];
	if(s[a+1]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}	
	for(int i=1;i<=a+b+1;i++)
	{
		if((s[i]<'0'||s[i]>'9')&&i!=a+1)
			sum++;
	}
	if(sum>0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int gcd(int a, int b);

int main() {
    int n, x, ans;
    cin >> n >> x;
    vector<int> pos(n);
    rep(i, n) cin >> pos.at(i);
    ans = abs(pos.at(0) - x);
    rep(i, n) ans = gcd(max(ans, abs(pos.at(i) - x)), min(ans, abs(pos.at(i) - x)));
    cout << ans << endl;
}

int gcd(int a, int b) {
    if(a % b == 0) return b;
    return gcd(b, a % b);
}

Measured memory_bytes: 640
require 'set'
s = gets.chomp.chars
K = gets.to_i

sorted_set = SortedSet.new()
(0...(s.size)).each do |i|
  (i...([i + K, s.size].min)).each do |j|
    subs = s[i..j]
    sorted_set.add(subs)
  end
end
puts sorted_set.to_a[K - 1].join('')


Measured memory_bytes: 4472
N, X, Y = map(int, input().split())

ans = [0] * (N)

for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(j - i, abs(X - i) + abs(j - Y) + 1)
        ans[d] += 1

for a in ans[1:]:
    print(a)


Measured memory_bytes: 3444
N = gets.to_i
A = gets.split.map(&:to_i)

A.unshift 0
(1..N).each do |i|
  A[i] += A[i - 1]
end

def calc(iP, iQ, iR) 
  l, h = [A[iP], A[iQ] - A[iP], A[iR] - A[iQ], A[N] - A[iR]].minmax
  h - l
end

def canMoveNext(s, f, i)
  i + 1 != f && (2 * A[i + 1] - A[f] - A[s - 1]).abs < (2 * A[i] - A[f] - A[s - 1]).abs
end

iP = 1
iR = 3
ans = calc(1, 2, 3)
(2..(N - 2)).each do |iQ|
  while canMoveNext(1, iQ, iP)
    iP += 1
  end
  while canMoveNext(iQ + 1, N, iR)
    iR += 1
  end 
  tmp = calc(iP, iQ, iR)
  ans = tmp if tmp < ans 
end
puts ans



Measured memory_bytes: 21516
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main {
	//2337 start

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			while(n-- > 0){
				int m = sc.nextInt();
				Line2D [][] data = new Line2D[m][4];
				for(int i = 0 ; i< m; i++){
					Point2D [] input = new Point2D[4];
					for(int j = 0; j < 4; j++){
						int x = sc.nextInt();
						int y = sc.nextInt();
						input[j] = new Point2D.Double(x, y);
					}
					
					for(int j = 0 ; j< 4; j++){
						data[i][j] = new Line2D.Double(input[j], input[(j+1) % 4]);
					}
				}
				solve(data, m);
			}
			
			
		}
	}
	
	private void solve(Line2D[][] data, int m) {
		UnionFind uf = new UnionFind(m);
		for(int i = 0 ; i < m ;i++){
			for(int j = i+1; j < m; j++){
				if(intersect(data[i], data[j])){
					uf.unite(i, j);
				}
			}
		}
		
		HashSet<Integer> res = new HashSet<Integer>();
		for(int i = 0 ; i < m; i++){
			res.add(uf.find(i));
		}
		System.out.println(res.size());
		
	}

	private boolean intersect(Line2D[] l, Line2D[] m) {
		for(int i = 0 ; i < l.length ; i++){
			for(int j = 0 ; j < m.length; j++){
				if(l[i].intersectsLine(m[j])){
					return true;
				}
			}
		}
		
		int temp = l[0].relativeCCW(m[0].getP1());
		boolean flg = true;
		for(int i = 1 ; i < l.length; i++){
			if(l[i].relativeCCW(m[0].getP1()) * temp < 0 ){
				flg = false;
				break;
			}
		}
		if(flg) return true;
		
		temp = m[0].relativeCCW(l[0].getP2());
		flg = true;
		for(int i = 1; i < m.length; i++){
			if(m[i].relativeCCW(l[0].getP2()) * temp < 0){
				return false;
			}
		}
		
		return true;
	}

	class UnionFind{
		int [] par, rank;

		public UnionFind(int n) {
			par = new int[n];
			rank = new int[n];
			for(int i = 0 ; i < n; i++){
				par[i] = i;
				//rank[i] = 0;
			}
		}
		int find(int x){
			if(par[x] == x)return x;
			else return par[x] = find(par[x]);
		}
		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return ;
			if(rank[x] < rank[y]) par[x] = y;
			else{
				par[y] = x;
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		boolean same(int x, int y){
			return find(x) == find(y);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from time import clock
a=clock()
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(s, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if s[mid] == val:return mid
        elif s[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,s):
    for i in range(1,n):s[i]+=s[i-1]
    return s;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
# code here---
n,x,t=iia()
a=ceil(n/x)
print(a*t)


Measured memory_bytes: 72668
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[555555];
int n;
int a[555555],la;
int dp[555555][4];
int calc(int S,int E){
	if(S > E)return 0;
	la = 0;
	int pnt = S;
	for(int i=S; i<=E; i++){
		if(s[i] == '0'){
			a[la++] = i-pnt;
			pnt = i+1;
		}
	}
	a[la] = E + 1 - pnt;
	if(la == 0)return 0;
	dp[0][0] = 0;//0: no.
	dp[0][1] = a[0];//1: eat all left
	dp[0][2] = a[1] - 1;//2: eat all right except 1
	dp[0][3] = a[1];//3: eat all right
	for(int i=1;;i++){
		dp[i][0] = 0;
		for(int j=0; j<4; j++)
			dp[i][0] = max(dp[i][0], dp[i-1][j]);
		if(i==la)break;

		dp[i][1] = max(
			dp[i-1][0] + a[i],max(
			dp[i-1][1] + a[i]-1,
			dp[i-1][2] + 1));

		dp[i][2] = dp[i-1][0] + a[i+1] - 1;
		if(a[i]>1){
			dp[i][2] = max(dp[i][2], dp[i-1][1] + a[i+1] - 1);
			dp[i][2] = max(dp[i][2], dp[i-1][2] + a[i+1] - 1);
		}

		dp[i][3] = dp[i-1][0] + a[i+1];
		if(a[i]>1){
			dp[i][3] = max(dp[i][3], dp[i-1][1] + a[i+1]);
			dp[i][3] = max(dp[i][3], dp[i-1][2] + a[i+1]);
		}
	}
	return dp[la][0];
}
int main(){
	int S, E;
	scanf("%d%s",&n,s);
	for(S = 0; S < n && s[S] == '0'; S++);
	if(S == n){
		puts("0");
		return 0;
	}
	for(E = n-1; E >= 0 && s[E] == '0'; E--);
	int pnt = S;
	int res = 0;
	for(int i=S; i<=E;)
		if(s[i] == '0' && s[i+1] == '0'){
			res += calc(pnt, i-1);
			while(i<=E && s[i] == '0')
				i++;
			pnt = i;
		}else{
			i++;
		}
	res += calc(pnt, E);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 2688
# coding: utf-8
def day(y,m,d):
    my,mm,md = y-1,m-1,d-1 
    day = my // 3 * 590 + my % 3 * 195 + md
    if y % 3 == 0:
        day += mm * 20
    else:
        day += mm // 2 * 39 + mm % 2 * 20
    return day
n = int(input())
for i in range(n):
    Y,M,D = [int(x) for x in input().split()]
    print(196470 - day(Y,M,D))

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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << (a*b)/__gcd(a,b);
}

Measured memory_bytes: 256
N = int(input())
L = []
sumB = 0
for i in range(N):
 A, B = map(int, input().split())
 sumB -= B
 L.append(A + B)
L.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    sumB += L[i]
print(sumB)

Measured memory_bytes: 7388
int main()
{
    int base,hour,minute,second;

    scanf("%d",&base);

    hour = base / 3600;
    minute = (base-hour*3600)/60;
    second = base - hour * 3600 - minute * 60;

    printf("%d:%d:%d\n",hour,minute,second);

    return 0;
}


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


int main()
{		
	long long n;
	int i, k, ans = 0, x, c, t;
	
	scanf("%lld", &n);
	for(i = 2, k = sqrt(n); i <= k; i++){
		if(n % i) continue;
		x = 0;
		do{
			n /= i;
			x++;
		}while(n % i == 0);
		k = sqrt(n);
		t = 1, c = 1;
		while(1){
			t += c + 1;
			if(t > x) break;
			c++;
		}
		ans += c;
	}
	if(n > 1) ans++;
	printf("%d\n", ans);
				
	return 0;
}

Measured memory_bytes: 2152
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	vector<int>a(N);
	vector<int>b(N);
	REP(i,N)cin>>a[i];
	REP(i,N)cin>>b[i];
	int ans=0;
	REP(i,N){
		int co=0;
		int k=0;
		while(k<=i){
			co+=a[k];
			k++;
		}
		co+=b[k-1];
		FOR(j,i+1,N){
			co+=b[j];
		}
		ans=max(ans,co);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int howtimes,shuffle,lastcard=0,i,j,k;
  char card[1000]={};
  
  //scan
  while(1){
    
    scanf("%s",card);
    
    if(card[0] != '-'){
      
      scanf("%d",&howtimes);
      
      for(i = 0; card[i] != '\0'; i++){
	
	lastcard=i+1;
	
      }
      
      for(i = 0; i < howtimes; i++){
	
	scanf("%d",&shuffle);
	
	for(j = 0; j < shuffle; j++){
	  
	  card[lastcard+j]=card[j];
	  
	}
	
	for(j = 0; j < lastcard; j++){
	  
	  card[j]=card[shuffle+j];
	  
	}
	
      }
      
      for(i = 0; i < lastcard; i++){
	
	printf("%c",card[i]);
	
      }
      
      printf("\n");
      
    } else {
      
      break;
      
    }  
    
  }
  
  return 0;
  
}

Measured memory_bytes: 568
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a,b,c,d,e]
cost = [(10 - (i%10))%10 for i in l]
time = []
idx = cost.index(max(cost))
for i in range(len(l)):
    if i == idx:
        time.append(l[i])
    else:
        time.append(l[i]+cost[i])
print(sum(time))


Measured memory_bytes: 3064
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   S: String(1..6);
begin
   S := get_line;
   if S(3) = S(4) and then S(5) = S(6) then put_line("Yes");
   else put_line("No");
   end if;
end main;

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	int res = 1;
	rep(i, 3) {
		res *= N;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256