akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int i,j,k,paper[10][10]={0},x,y,n,c=0,max=0;
	
	while(scanf("%d",&x)!=EOF){
		scanf(",%d,%d",&y,&n);
		
		if(n==0)break;
		
		if(n==1){
			if(y-1>=0)paper[y-1][x]++;
			if(y+1<10)paper[y+1][x]++;
			if(x-1>=0)paper[y][x-1]++;
			if(x+1<10)paper[y][x+1]++;
			if(y>=0 && y<10 && x>=0 && x<10)paper[y][x]++;
		}
		if(n==2){
			if(y-1>=0)paper[y-1][x]++;
			if(y+1<10)paper[y+1][x]++;
			if(x-1>=0)paper[y][x-1]++;
			if(x+1<10)paper[y][x+1]++;
			if(y-1>=0 && x-1>=0)paper[y-1][x-1]++;
			if(y-1>=0 && x+1<10)paper[y-1][x+1]++;
			if(y+1<10 && x-1>=0)paper[y+1][x-1]++;
			if(y+1<10 && x+1<10)paper[y+1][x+1]++;
			if(y>=0 && y<10 && x>=0 && x<10)paper[y][x]++;
		}
		if(n==3){
			if(y-1>=0)paper[y-1][x]++;
			if(y+1<10)paper[y+1][x]++;
			if(x-1>=0)paper[y][x-1]++;
			if(x+1<10)paper[y][x+1]++;
			if(y-1>=0 && x-1>=0)paper[y-1][x-1]++;
			if(y-1>=0 && x+1<10)paper[y-1][x+1]++;
			if(y+1<10 && x-1>=0)paper[y+1][x-1]++;
			if(y+1<10 && x+1<10)paper[y+1][x+1]++;
			
			if(y-2>=0)paper[y-2][x]++;
			if(y+2<10)paper[y+2][x]++;
			if(x+2<10)paper[y][x+2]++;
			if(x-2>=0)paper[y][x-2]++;
			if(y>=0 && y<10 && x>=0 && x<10)paper[y][x]++;
		}
	}
	
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(paper[i][j]==0)c++;
			if(paper[i][j]>=max)max=paper[i][j];
		}
	}
	printf("%d\n%d\n",c,max);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  // rep(i, n - 1) {
  //   if (a[i] == a[i + 1]) {
  //     a[i] = INF;
  //     cout << "--" << endl;
  //   }
  // }
  int res = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        ll b = a[i];
        ll c = a[j];
        ll d = a[k];
        if (b == INF || c == INF || d == INF) continue;
        if (b + c > d && b + d > c && c + d > b && c != d && b != c) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

map<ll, ll> mp;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;cin>>n;
  ll a[5];
  for(int i=0;i<5;i++)cin>>a[i];

  ll res = 0;
  ll mn = 0;
  int mn_idx = 0;
  for (int i=0;i<5;i++){
    ll ppm = n/a[i];
    if(n%a[i])ppm++;
    // cout<<':'<<ppm<<endl;
    if(ppm>=mn){
      mn = ppm;
      mn_idx = i;
    }
  }

  cout<<(mn+4)<<endl;

  return 0;
}


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

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

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int c[10][10];
int main(){
    int R,C;
    cin>>R>>C;
    REP(i,10)REP(j,10)cin>>c[i][j];
    REP(k,10)REP(i,10)REP(j,10)chmin(c[i][j],c[i][k]+c[k][j]);
    LL ret=0;
    REP(i,R)REP(j,C){
        int v;
        cin>>v;
        if(v>=0)ret+=c[v][1];
    }
    cout<<ret<<endl;
    return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    vector<int> order(5);
    for(int i = 0; i < 5; i++){
        cin >> order[i];
    }
    int ans = INT_MAX;
    do{ 
        int t = 0;
        for(int i = 0; i < 5; i++){
            t += order[i];
            if(i == 4) break;
            while(t % 10 != 0){
                t++;
            }
        }
        ans = min(ans, t);
    }while(next_permutation(ALL(order)));
    cout << ans;
    return 0;
}


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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define int long long 
#define str string
#define elif else if

int i,j,k;
int dx,dy;
int a,b,c,x,y,n,m,cnt=0,ans=0;
str s,t;

signed main(){ 
  cin>>s;
  sort(s.begin(),s.end());
  //debg(s);
  for(i=0;i<s.length();i+=2){
    if(s[i]!=s[i+1]){
      debg("No");
      return 0;
    }
  }
  debg("Yes");
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int num = B - A;
  int height = 0;
  for (int i = 0; i < num; i++) height += i;
  cout << height - A << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long; 
const ll INF = ll(1e18)+5;

int main() {
    ll N,x;
    cin >> N >>x;
    vector<ll> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    vector<vector<ll>> mina(N);
    for(int i=0;i<N;i++){
        mina[i].resize(N);
        mina[i][0] =a[i];
    }
    vector<ll> chose(N,INF);
    ll maxX =0;
    for(int i=0;i<N;i++)for(int j=1;j<N;j++){
        mina[i][j] = min(mina[i][j-1],a[(i-j+N)%N]);
    }
    ll ans = INF;
    for(int j=0;j<N;j++){
        ll temp =j*x;
        for(int i=0;i<N;i++){
            temp += mina[i][j];
        }
        ans = min(ans,temp);
    }
    cout << ans << endl;
 

    return 0;
}

Measured memory_bytes: 34980
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;

void trace(int a[], int n){
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << endl;
}

void bubleSort(int a[], int n) {
	int counter = 0;
	for (int i = 1; i < n; i++) {
		for (int j = n - 1; j >= i; j--) {
			if (a[j] < a[j - 1]) {
				int t = a[j];
				a[j] = a[j - 1];
				a[j - 1] = t;
				counter++;
			}
		}
	}
	trace(a, n);
	cout << counter << endl;
}



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

	return 0;
}



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

int main(){
    int n, k, q; cin >> n >> k >> q;
    vector<int> score(n+1, k-q);
    rep(i, q) {
        int a; cin >> a;
        score[a]++;
    }
    rep(i, n) {
        int num = i+1;
        if(score[num] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, X;
  cin >> N >> X;
  vector<ll> x(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> x.at(i);
  }
  sort(x.begin(), x.end());
  ll ans = abs(x.at(0) - X);
  for (ll i = 0; i < N - 1; ++i)
  {
    ans = __gcd(ans, x.at(i + 1) - x.at(i));
    // cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-10)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int n;
string maps[500];

int main() {
	cin >> n;
	REP(i, n) cin >> maps[i];
	
	int ans = INF;
	int allblack = 0; // 全てが黒である列の数
	bool exist[500] = {}; // j列に黒が存在するか
	int bcnt[500] = {}; // i行の黒の数
	
	REP(j, n) {
		bool ok = true;
		REP(i, n) {
			if (maps[i][j] != '#') ok = false;
			else {
				exist[j] = true;
				bcnt[i]++;
			}
		}
		if (ok) allblack++;
	}
	
	REP(i, n) {
		int cnt = 0;
		if (!exist[i]) {
			if (bcnt[i] >= 1) cnt++;
			else continue;
		}
		cnt += n - bcnt[i];
		
		cnt += n - allblack;
		
		
		
		chmin(ans, cnt);
	}
	
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long long ans = 0;
    for (auto& x : a) {
        cin >> x;
    }

    for (int i = 0; i < n - 1; ++i) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] && a[i + 1]) {
            ans++;
            a[i]--;
            a[i + 1]--;
        }
    }

    ans += a[n - 1] / 2;

    cout << ans << endl;
}

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

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll sum{0};
	ll i{1};
	for (; i <= N; ++i)
	{
		sum += i;
		if (sum >= N)
			break;
	}

	
	ll t = sum - N;
	
	
	for (ll j = 1; j <= i; ++j)
	{
		if (t == j) continue;
		std::cout << j << std::endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s[105];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int m;
	cin >> m;
	string t[105];
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	long long count = 0,ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) {
				count++;
			}
		}
		for (int k = 0; k < m; k++) {
			if (s[i] == t[k]) {
				count--;
			}
		}
		ans = max(ans, count);
		
		count = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(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 fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
int mx = 1e5;
vector<vi > adj(mx+7);
vi dp(mx+7,0);
vi indegree(mx+7,0);
int solve(int u, int &ans){
	// if(dp[u])return dp[u];
	// trace(u)
	for(auto v:adj[u]){
		dp[v] = max(dp[v], dp[u]+1);
		ans = max(ans, dp[v]);
		indegree[v]--;
		if(indegree[v]==0)
		solve(v,ans);
	}
}
int main(){
	fast_io;
	int n,m;
	cin>>n>>m;
	
	
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		indegree[y]++;
	}
	vi s;
	for(int i=1;i<=n;i++){
		// trace2(i,indegree[i])
		if(!indegree[i]){
			s.pb(i);
		}
	}
	int ans = 0;
	for(auto k:s){
		// trace(k)
		solve(k,ans);
	}
	cout<<ans;
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cmath>
//Tomas Mollerのアルゴリズム
using namespace std;
typedef struct{
	double x;
	double y;
	double z;
}V;

V Sub(V a, V b){
	V c;
	c.x=a.x-b.x;
	c.y=a.y-b.y;
	c.z=a.z-b.z;
	return c;
}

V Gai(V a, V b){
	V c;
	c.x=a.y*b.z-a.z*b.y;
	c.y=a.z*b.x-a.x*b.z;
	c.z=a.x*b.y-a.y*b.x;
	return c;
}

double Nai(V a,V b){
	return a.x*b.x+a.y*b.y+a.z*b.z;
}


int chk(V p1,V p2,V v1, V v2,V v3){
	double x,y,z;
	V a,b,c,d,n,m;
	a=Sub(v2,v1);
	b=Sub(v3,v1);
	n=Gai(a,b);
	c=Sub(p1,v1);
	x=Nai(c,n);
	d=Sub(p2,v1);
	y=Nai(d,n);
	if ((x>0.0&&y>0.0) || (x<0.0&&y<0.0)) return 1;
	
	z = x/(x-y);
	m.x=(1.0-z)*c.x+z*d.x;
	m.y=(1.0-z)*c.y+z*d.y;
	m.z=(1.0-z)*c.z+z*d.z;
	if(n.x<0.0)n.x*=-1.0;
	if(n.y<0.0)n.y*=-1.0;
	if(n.z<0.0)n.z*=-1.0;
	if(n.x>n.y && n.x>n.z){
		z = 1.0/(a.y*b.z-a.z*b.y);
		x = (b.z*m.y-b.y*m.z)*z;
		y = (a.y*m.z-a.z*m.y)*z;
	}
	else if(n.y>n.z){
		z = 1.0/(a.z*b.x-a.x*b.z);
		x = (b.x*m.z-b.z*m.x)*z;
		y = (a.z*m.x-a.x*m.z)*z;
	}
	else{
		z = 1.0/(a.x*b.y-a.y*b.x);
		x = (b.y*m.x-b.x*m.y)*z;
		y = (a.x*m.y-a.y*m.x)*z;
	}
	
	return (x<0.0 || y<0.0 || x+y>1.0);
}

int main(){
	V p1,p2,v1,v2,v3;
	cin>>p1.x>>p1.y>>p1.z;
	cin>>p2.x>>p2.y>>p2.z;
	cin>>v1.x>>v1.y>>v1.z;
	cin>>v2.x>>v2.y>>v2.z;
	cin>>v3.x>>v3.y>>v3.z;
	if(chk(p1,p2,v1,v2,v3))cout<<"HIT\n";
	else cout<<"MISS\n";
	
	return 0;
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	int cnt=0;
	int A[100];
	cin>>N;
	static int i,Alice,Bob;
	for(i=0;i<N;i++)	cin>>A[i];
	sort(A,A+N);
	for(i=N-1;i>=0;i--){
		if(cnt==0){
			Alice+=A[i];
			cnt=1;
		}
		else{
			cnt=0;	Bob+=A[i];
		}
	}
	cout<<Alice-Bob<<endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 3e5 + 5;
int n, ans;
string s;
int l[N], r[N];
int main() {
    cin >> n >> s;
    ans = n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        l[i] = sum;
        if (s[i] == 'W')
            ++sum;
    }
    sum = 0;
    for (int i = n - 1; i >= 0; --i) {
        r[i] = sum;
        if (s[i] == 'E')
            ++sum;
    }
    for (int i = 0; i < n; ++i) {
        ans = min(ans, l[i] + r[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6100
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i;
    scanf("%d %d",&a,&b);
    if(a<=b)
    {
        for(i=0;i<b;i++)
        {
            printf("%d",a);
        }
        printf("\n"); 
    }
    else if(a>b)
    {
        for(i=0;i<a;i++)
        {
            printf("%d",b);
        }
        printf("\n"); 
    }
    return 0;
} 

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

bool checkATCG(char c){
	if(c == 'A' || c == 'T' || c == 'C' || c == 'G')
      	return true;
  	else 
    	return false;
}

int main(){
	string s;
  	cin >> s;
  int now=0, max=0;
	for(int i=0; i<s.size(); i++){
    	if( checkATCG(s[i])) now++;
      	else{
        	if(now > max) max = now;
          now = 0;
        }
    }
  	if(now > max) max = now;
  	
  	cout << max << endl;

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

int main() {
    int ans = 1;
    int arr[100005] = {};
    bool used[100005] = {};
    int next;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }
    ans = 0;
    next = 1;
//    used[1] = true;
//    next = arr[1];
//    if(next == 2){
//        cout << ans << endl;
//        return 0;
//    }
    while(true){
        if(used[next]){
            ans = -1;
            break;
        }
        if(next == 2){
            break;
        }
        used[next] = true;
        ans++;
        next = arr[next];
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cstdio>
#include <cstring>

typedef long long LL;

const int MAXN = 2000;
const int MOD = 924844033;

int N, K;
int Fac[MAXN + 5];

int Cnt;
bool Begin[MAXN * 2 + 5];

int Dp[MAXN * 2 + 5][MAXN * 2 + 5][2];

int main() {
	scanf("%d%d", &N, &K);
	Fac[0] = 1;
	for (int i = 1; i <= N; i++)
		Fac[i] = (LL)Fac[i - 1] * i % MOD;
	for (int i = 1; i <= K; i ++) {
		for (int j = i; j <= N; j += K)
			Begin[++Cnt] = (j == i);
		for (int j = i; j <= N; j += K)
			Begin[++Cnt] = (j == i);
	}
	Dp[0][0][0] = 1;
	for (int i = 1; i <= 2 * N; i++) {
		for (int j = 0; j <= i; j++) {
			Dp[i][j][0] = (Dp[i - 1][j][0] + Dp[i - 1][j][1]) % MOD;
			if (!Begin[i] && j)
				Dp[i][j][1] = Dp[i - 1][j - 1][0];
		}
	}
	int Ans = 0;
	for (int i = 0; i <= N; i++) {
		int tmp = (Dp[N * 2][i][0] + Dp[N * 2][i][1]) % MOD;
		if (i & 1)
			tmp = -tmp;
		Ans = ((Ans + (LL)tmp * Fac[N - i] % MOD) % MOD + MOD) % MOD;
	}
	printf("%d", Ans);
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)

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

    if(n % 3 == 0 || m % 3 == 0 || (n+m) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x,T a,T b){return a<=x&&x<=b;}
template<class T> void amin(T &a,T v){if(a>v) a=v;}
template<class T> void amax(T &a,T v){if(a<v) a=v;}
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


#if 1 // B


int main()
{
	int N;
	ll x;
	cin >> N >> x;

	vector <ll> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	ll best = BIGLL;


	for (int mv = 0; mv <= N - 1; mv++)
	{
		ll total = accumulate(a.begin(), a.end(), mv*x);
		amin(best, total);

		vector <ll> nexta(N);
		for (int i = 0; i < N; ++i)
		{
			nexta[i] = min(a[(i-1+N)%N], a[i]);
		}
		a = nexta;
	}

	cout << best << endl;

	return 0;
}

#else
int main()
{
	ll a, b, c;
	cin >> a >> b >> c;

	ll ret = 0;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{

	}
	else
	{
		ret = min(a*b, min(b*c, c*a));
	}

	cout << ret << endl;

}

#endif

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];
	sort(A, A + N);

	ll S = A[0];
	int kotae = 1;
	rep1(i, N - 1) {
		if (S * 2 < A[i]) kotae = 1;
		else kotae++;
		S += A[i];
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Node{int u,v;};
bool operator<(Node a,Node b){return a.v>b.v;}
priority_queue<Node> Q;
bool vis[1<<17];
int n,A,B,bul[1<<17];
void dfs(int B,int A,int p)
{
	if(bul[p^((1<<n)-1)]==1){printf("%d %d ",A,A^B);return;}
	for(int i=0;i<n;++i)
		if(!(p&(1<<i))&&(B&(1<<i)))
			for(int j=0;j<n;++j)
			{
				if(p&(1<<j))continue;
				if(i==j)continue;
				int T=(1<<i)^(1<<j);
				dfs(1<<j,A,p|(1<<i));
				dfs(B^T,A^T,p|(1<<i));
				return;
			}
}
int main()
{
	n=read();A=read();B=read();
	for(int i=1;i<1<<n;++i)bul[i]=bul[i>>1]+(i&1);
	if(bul[A^B]&1)puts("YES"),dfs(A^B,A,0),puts("");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}

int main(){
    int a,b;
    cin >> a >> b;
    //doubelにする強引な方法
    // int x = ((double)a+(double)b)/2.0 + 0.999999999;

    //組み込み関数ceilを使う方法
    int x = ceil(((double)a+(double)b)/2);

    //
    // int x = a+b;
    // if(x%2!=0) x = (x+1)/2;

    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

ans = 0

while True:
    if ans > 999999:
        print(-1)
        break
    elif a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        print(ans)
        break
    n_a = b/2 + c/2
    n_b = a/2 + c/2    
    n_c = a/2 + b/2
    a = n_a
    b = n_b
    c = n_c
    ans += 1


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    char c; cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        puts("vowel");
    } else {
        puts("consonant");
    }
}

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

int main(){
	int n;
	cin>>n;
	
	long long int A=1;
	long long int B=1;
	long long int as=1;
	long long int t,a;
	long long int x;
	
	for(int i=0;i<n;i++){
		cin>>t>>a;
		x=max((A+t-1)/t,(B+a-1)/a);
		A=x*t;
		B=x*a;
	}
	
	cout<<A+B<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public double[] Sarray() { return ReadLine().Split().Select(double.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var abhm = Sarray();
            var a = abhm[0];
            var b = abhm[1];
            var h = abhm[2];
            var m = abhm[3];
            var th = (h * 60 + m) / 720 * 2 * Math.PI;
            var tm = (m/60) * 2 * Math.PI;
            var xh = a * Math.Cos(th);
            var yh = a * Math.Sin(th);
            var xm = b * Math.Cos(tm);
            var ym = b * Math.Sin(tm);
            var dx = xh - xm;
            var dy = yh - ym;
            var ans = Math.Sqrt(dx * dx + dy * dy);
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 19608
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(M)]

graph = [[0]*N for _ in range(N)]
for a, b in ab:
	graph[a-1][b-1] = 1
	graph[b-1][a-1] = 1

ans = 0
for i in permutations(range(1, N)):
	i = list(i)
	i.insert(0, 0)
	# print(i)
	for j in range(N-1):
		if graph[i[j]][i[j+1]] != 1:
			break
	else:
		ans += 1
print(ans)


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
string s,st,a[100005];
int n,cnt;

void setup()
{
    n=1;
    a[n].clear();
    for(int i=0;i<s.size();i++)
        if (s[i]==' ')
        {
            n++;
            a[n].clear();
        }
        else
            a[n]=a[n]+s[i];
}

void Lower_case()
{
    for (int i=0;i<s.size();i++)
        if ('A'<=s[i] && s[i]<='Z')
            s[i]=char(s[i]+32);
}

int main()
{
    cnt=0;
    getline(cin,st);
    while (1>0)
    {
        s.clear();
        getline(cin,s);
        if (s=="END_OF_TEXT") break;
        Lower_case();
        setup();
        for(int i=1;i<=n;i++)
            if (st==a[i]) cnt++;
    }
    printf("%d\n",cnt);
}



Measured memory_bytes: 4040
import sys
input = sys.stdin.readline

def main():
  s = input().strip()
  t = "abc"
  count = [0, 0, 0]
  for i in range(len(s)):
    for j in range(3):
      if s[i] == t[j]:
        count[j] += 1
  m = min(count)
  jud = count[0] - m
  jud = max(jud, count[1] - m)
  jud = max(jud, count[2] - m)
  
  if jud <= 1:
    print("YES")
  else:
    print("NO")
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

struct Node
{
    Node *parent;
    Node *left;
    Node *right;
    int key;
};

void insert(Node **root, int num)
{
    Node *newNode = (Node *)malloc(sizeof(Node));
    newNode->key = num;
    newNode->left = newNode->right = NULL;

    // find target leaf.
    Node *target;
    for (Node *n = *root; n != NULL; )
    {
        target = n;
        n = (num < n->key) ? n->left : n->right;
    }
    newNode->parent = target;

    if (*root == NULL)
        *root = newNode;
    else if (num < target->key)
        target->left = newNode;
    else
        target->right = newNode;
}
Node *findNode(Node *u, int num)
{
   if (u == NULL)
       ;
   else if (num == u->key)
       return u;
   else if (num < u->key)
       return findNode(u->left, num);
   else if (num > u->key)
       return findNode(u->right, num);
   return NULL;
}

void preorder(Node *u)
{
    if (u == NULL) return;
    cout << " " << (u->key);
    preorder(u->left);
    preorder(u->right);
}
void inorder(Node *u)
{
    if (u == NULL) return;
    inorder(u->left);
    cout << " " << (u->key);
    inorder(u->right);
}


int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    Node *root = NULL;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string command;
        cin >> command;
        if (command.find("insert") == 0)
        {
            int num;
            cin >> num;
            insert(&root, num);
        } else if (command.find("find") == 0)
        {
            int num;
            cin >> num;
            Node *ans = findNode(root, num);
            if (ans == NULL)
                cout << "no" << endl;
            else
                cout << "yes" << endl;
        } else
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 21776
N,M = map(int,input().split())
if N == 2 or M == 2:
    Ans = 0
elif N == 1 or M == 1:
    if not N == M:
        Ans = max(N,M)-2
    else:
        Ans = 1
else:
    Ans = (N-2)*(M-2)
print(Ans)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int a[100010];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    int cnt[100010] = {};
    ll ans = 0;
    rep(i,0,N){
        if(a[i] <= 1e5){
            cnt[a[i]]++;        
        }else{
            ans++;
        }
    }
    rep(i,1,100001){
        if(cnt[i] < i){
            ans += cnt[i];
        }else if(cnt[i] > i){
            ans += cnt[i] - i;
        }
    }
    print(ans);

}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class ATheNumberOfEvenPairs {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, m;
	    in >> n >> m;

        out << n * (n-1) / 2 + m * (m-1) / 2 << endl;
	}
};


int main() {
	ATheNumberOfEvenPairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> ans(n,0);
    for(int i=0;i<n-1;i++){
        ll a;
        cin>>a;
        a--;
        ans[a]++;
    }
    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 4844
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<ext/rope>
#define int long long
using namespace std;
using namespace __gnu_cxx;
typedef long long LL;
const int MAXN = 2e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
signed main(){
	int n; cin>>n;
	if(n==0 || n==1) { puts("0");return 0; }
	if(n%2==1) { puts("0");return 0; }
	int base=1,res=0;
	while(base*5<=n && base>0){
		base *= 5;
		res += n/(base*2);
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
const int N= 3e5+7;
int vis[N], East [N], West[N];


class NBAFinals
{
public :
    int  dubsAgain (vector < int > scores,string team)
    {
        int arr[2]= {0,0};
        int ans;
        for( int i = 0 ; i<scores.size() ; i ++)
        {
            if(team[i]=='W'||team[i]=='?')
            {
                arr[0]+=(scores[i]==0?4:scores[i]);
            }
            else
                arr[1]+=(scores[i]==0?1:scores[i]);
        }

        return ans=arr[0]>arr[1];
    }
};
int main()
{

    int n ;
    string s ;
    cin>>n>>s;
    for( int i=1 ; i<= n ; i++)
    {
        if(s[i-1]=='E')
        {

            West[i]=1+West[i-1];
            East[i]=East[i-1];
        }
        else
        {
            East[i]=1+East[i-1];
            West[i]=West[i-1];

        }
    }
    int mn =INT_MAX;
    for( int i=1 ; i<= n ; i++)
    {
        int e =East[i]-East[0];
        int w =West[n]-West[i-1];
        cerr<<e<<" "<<w<<" "<<endl;

        if(mn>e+w)
            mn=e+w;

    }
    cout<<mn-1<<endl;



}



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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> D(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> D[i];
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = i+1; j < N; j++ ) {
            ans += D[i]*D[j];
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//


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

	int ans = 9999;

	rep(i, N)
	{
		int c, t;
		cin >> c >> t;
		if ( t <= T )
		{
			ans = MIN(ans, c);
		}
	}

	if ( ans == 9999 )
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
int n,x,t;
  cin>>n>>x>>t;
  if((n%x)==0)
  {
    cout<<(n/x)*t;
  }
else
  if((n%x)!=0)
  {
    cout<<((n/x)+1)*t;
  }

}

Measured memory_bytes: 3632
n,k,q = map(int, input().split())
A = []
for i in range(q):
  A.append(int(input()))

scores = [k-q] * n
for i in range(q):
  scores[A[i]-1] = scores[A[i]-1] + 1

for i in range(n):
  if scores[i] <= 0:
    print("No")
  else:
    print("Yes")
  

Measured memory_bytes: 10516
#include <stdio.h>

int main(void)
{
    int a,b,c,d;
    scanf("%d %d %d", &a ,&b ,&c);
    if(a < b){
        if(b < c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else {
        printf("No\n");
    }
  
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,maxv=0,sum=0;
    //vector<int> l(n);
    cin >> n;
    for(int i=0;i<n;i++){
        int l;
        cin >> l;
        sum += l;
        maxv = max(maxv, l);
    }
    
    if(maxv < sum- maxv){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

/* ?????????????´??????????????????? */
void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" "); /* ??£??\??????????´?????????????????????????????????? */
    printf("%d", A[i]);
  }
  printf("\n");
}

/* ?????\????????? (0??????????????????) */
void insertionSort(int A[], int N) {
  int j, i, v;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v ) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];
  
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  
  trace(A, N);
  insertionSort(A, N);
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n,k;
	int a=1;
	cin>>n>>k;
	rep(i,n){
		a=min(a*2,a+k);
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b;
	while(~getII(a,b)) printf("%s\n",(a>8||b>8)?":(":"Yay!");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int prob[200005],req[200005];
int main(){
	int n;
	while(~getI(n)){
		F(i,0,n) getI(prob[i]);
		VgetI(m);
		F(i,0,m) getI(req[i]);
		if(m>n){
			puts("NO");
			continue;
		}
		sort(prob,prob+n);
		sort(req,req+m);
		bool no=0;
		for(int i=0,j=0;j<m;){
			if(i>=n){
				no=1;
				break;
			}
			if(prob[i]<req[j])
				i++;
			else if(prob[i]==req[j])
				i++,j++;
			else{
				no=1;
				break;
			}
		}
		no==0?puts("YES"):puts("NO");
	}
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

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

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int A, B, C;
	cin >> A >> B >> C;

	string ans = "NO";
	if (B - A == C - B) ans = "YES";

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


Measured memory_bytes: 256
N,K,C=map(int,input().split())
SL=input()
SR=SL[::-1]
Left=[]
Right=[]
Last=-N-1
Rast=-N-1
cL=cR=0
for i in range(N):
    if SL[i]=="o" and i-Last>C and cL<=K:
        Left.append(i)
        Last=i
        cL+=1
    if SR[i]=="o" and i-Rast>C and cR<=K:
        Right.append(N-i-1)
        Rast=i
        cR+=1
Right=Right[::-1]

ans=[]
for k in range(K):
    if Left[k]==Right[k]:
        ans.append(Left[k]+1)

if len(ans)==0:
    print()
else:
    for a in ans:
        print(a)

Measured memory_bytes: 29044
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
const int NMAX=3000;
int N;
ll x;
ll A[2010];
class RMQ{
public:
  ll dat[NMAX*2-1];//セグメント木を持つ配列
  int n;
  RMQ(int n_);//コンストラクタ
  void update(int k,ll a);//k番目(0-indexed)の値をaに変更
  ll query(int a,int b,int k,int l,int r);//[a,b)の最小値を求める
};
RMQ::RMQ(int n_){
  n=1;
  while(n<n_) n*=2;//簡単のため要素数を2のべき乗にする
  rep(i,2*n-1){
    dat[i]=INFLL;
  }
}
void RMQ::update(int k,ll a){//k番目(0-indexed)の値をaに変更
  k+=n-1;//a[k]=dat[k+n-1]
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=std::min(dat[2*k+1],dat[2*k+2]);
  }
}
ll RMQ::query(int a,int b,int k,int l,int r){//[a,b)の最小値を求める。(k,l,r)=(節点の番号,節点の区間の左端,右端)。通常(a,b,0,0,n)と呼ぶ。
  if(r<=a||b<=l) return INFLL;//[a,b)と[l,r)が交差しなければINTMAXを返す
  if(a<=l&&r<=b) return dat[k];//[l,r)が[a,b)に完全に含まれていれば節点の値を返す
  else{//違うなら2つの子の最小値
    ll v1=query(a,b,2*k+1,l,(l+r)/2);
    ll v2=query(a,b,2*k+2,(l+r)/2,r);
    return std::min(v1,v2);
  }
}

int main(){
  cin>>N>>x;
  rep(i,N) cin>>A[i];
  RMQ rmq(N);
  rep(i,N){
    rmq.update(i,A[i]);
  }
  int nn=rmq.n;
  ll res=INFLL;
  for(ll num=0;num<N;num++){
    ll temp=x*num;
    int numi=num;
    rep(i,N){
      if(i-numi>=0) temp+=rmq.query(i-numi,i+1,0,0,nn);
      else temp+=std::min(rmq.query(0,i+1,0,0,nn),rmq.query(N-(numi-i),N,0,0,nn));
    }
    res=std::min(res,temp);
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

result = 0

for x in range(len(A) - 1):
	result += B[x]
	if A[x]+1 == A[x+1]:
		result += C[A[x]-1]
result += B[len(A)-1]
print(result)


Measured memory_bytes: 3064
#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 x, y;
  cin >> x >> y;
  if (y % 2 == 0 && y / 2 - x >= 0 && 2 * x - y / 2 >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  long double a,b; cin>>a>>b;
  
  cout<<long(floor(a*long(b*100+0.5)/100))<<endl;

}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a == b || b == c || c == d){
    cout << "Bad" << endl;
  }
  else {
  cout << "Good" << endl;
  }
  
}


Measured memory_bytes: 256
// ＡＢＣのＡ過去問を解くだけだよ

// フォント:Electroharmonix
// x:小文字(ｘ)    X:大文字(Ｘ)
// +:プラス(＋)    &:アンド(＆)

#include <bits/stdc++.h>

using namespace std;

void Main()
{
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1);
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256