akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (998244353)
#define BIGNUM (ll(1e18))

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

    ll N;
    cin >> N;
    vector<ll> D(N);
    vector<ll> m(1e5+1);
    ll mmax = 0;
    REP(i, N) {
        cin >> D[i];
        m[D[i]]++;
        mmax = max(mmax, D[i]);
    }
    
    if (D[0] != 0 || m[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll score = 1;
    SREP(i, 1, mmax+1) {
        REP(j, m[i]) {
            score = (score*m[i-1])%MOD;
        }
    }
    cout << score << endl;
}


Measured memory_bytes: 1792
//https://atcoder.jp/contests/dp/tasks/dp_a

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

int ara[100005];
int sol[100005];

int main()
{
    int n;
    while(cin >> n)
    {
        memset(sol, 0, sizeof(sol));
        for(int i=0; i<n; i++){
            cin >> ara[i];
        }

        sol[0] = 0;
        sol[1] = abs(ara[0] - ara[1]);
        for(int i=2; i<n; i++){
            sol[i] = min((sol[i-1] + abs(ara[i] - ara[i-1])), (sol[i-2] + abs(ara[i] - ara[i-2])));
        }
        cout << sol[n-1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 1024
/**

    WARNING
          This Code Sucks
                        Just Like My Life :(

                                            **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb emplace_back
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e6+5;
const  double EPS = 1e-14;
const int mod = 1e9+7;
/*
ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
*/


int main()
{
    ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
    ///freopen("input.txt", "r", stdin);
#endif
    ll a,b,x;
    cin>>a>>b>>x;
    ll ans=(b/x)-(a/x);
    if(a%x==0)
        ans++;
    cout<<ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
vector<int> s[N],tmp;
int n,dep[N];
void sol(int u) {
	if(!s[u].size()) return;
	for(int i=0;i<s[u].size();++i) sol(s[u][i]);
	for(int i=0;i<s[u].size();++i) tmp.PB(dep[s[u][i]]);
	sort(tmp.begin(),tmp.end(),greater<int> ());
	int ans=s[u].size();
	for(int i=0;i<tmp.size();++i) ans=max(ans,tmp[i]+i+1);
	tmp.clear();
	dep[u]=ans;
//	cerr<<u<<' '<<dep[u]<<endl;
}
int main() {
	rd(n);
	for(int i=2,x;i<=n;++i) rd(x),s[x].PB(i);
	sol(1);
	printf("%d\n",dep[1]);
	return 0;
}

Measured memory_bytes: 10752
def main():
    N = int(input())
    S = input()
    if N%2 == 1:
        print('No')
        exit()
    for i in range(N//2):
        if S[i] != S[N//2+i]:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__': main()

Measured memory_bytes: 3060
public class Main {

  private static void solve() {
    int k = ni();

    long sum = 0;
    for (int a = 1; a <= k; a++) {
      for (int b = 1; b <= k; b++) {
        for (int c = 1; c <= k; c++) {
          int g = a;
          g = gcd(g, b);
          g = gcd(g, c);
          sum += g;
        }
      }
    }
    System.out.println(sum);

  }

  public static int gcd(int a, int b) {
    while (b > 0) {
      int c = a;
      a = b;
      b = c % b;
    }
    return a;
  }



  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main() {
    int64_t lf=2,ls=1;
    int n;
    cin >> n;
    if(n==1)
        cout << ls << endl;
    else{
        for(int i=2;i<n+1;i++)
            if(i%2==0)
                lf += ls;
            else
                ls += lf;
      cout << max(ls,lf) << endl;
    }
}


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

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    for (ll i =b; i <= c; ++i) {
        if(i%a==0) {
            cout <<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C;
	cin >> A >> B >> C;

	cout << (A + B + C >= 22 ? "bust" : "win") << endl;
	
	return 0;
}



Measured memory_bytes: 764
# 105の約数は1, 3, 5, 7, 3 * 5, 3 * 7, 5 * 7, 3 * 5 * 7
# ほかにありえるのは
# ①1, 3, 5, 9, ...
# ②1, 3, 5, 11, ...
# ③1, 3, 7, 9, ...
# ④1, 3, 5, 13, ...
n = int(input())
if n < 105: print(0)
elif n < 135: print(1)
elif n < 165: print(2)
elif n < 189: print(3)
elif n < 195: print(4)
else: print(5)

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



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format

	string S;
	int Q;
	cin >> S;
	cin >> Q;
	int T;
	int F;
	string C;

	bool revearsed = false;

	for(int i=0;i<Q;i++){
		cin >> T;
		if(T==1){
			revearsed = !revearsed;
		}else{
			cin >> F;
			cin >> C;
			if(revearsed==true){
				reverse(C.begin(),C.end());
			}
			if(F==1){
				if(revearsed==false){
					S.insert(0,C);
				}else{
					S.append(C);
				}
			}else{
				if(revearsed==false){
					S.append(C);
				}else{
					S.insert(0,C);
				}
			}
		}
	}
	if(revearsed==true){
		reverse(S.begin(),S.end());
	}
	cout << S << endl;

    return 0;
}


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

int main() {
  int64_t n;
  cin >> n;
  int64_t ans=0;
  for(int i=2; i<1000000; i++){
    int x=i;
    
    while(n%i==0) {
      if(n%x==0){
        ans++;
        n=n/x;
      }
      else{
        while(n%i==0){
          n=n/i;
        }
      }
      x*=i;
    }
    
  }
  if(n!=1) ans++;
  cout << ans << endl;
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
#include<string>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	string str;
	cin>>str;
	int N = str.size();
	int c_x = 0;
	int i = 0,j = N-1;
	while(i < j){
		
		if(str[i] == str[j]){
			i++;
			j--;
		}
		else if( (str[i] == 'x') ){
			c_x++;
			i++;
		}
		else if((str[j] == 'x') ){
			c_x++;
			j--;
		}
		else{
			c_x = -1;
			break;
		}
	}

	cout<<c_x<<endl;
	
	return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    double d = N;
    if(N % 2 == 0){
        N --;
    }
    cout << ((N/2) + 1) / d << endl;
    }

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

int top;
int s[1000];

void push(int x)
{
  top++;
  s[top] = x;
}

int pop()
{
  top--;
  return s[top+1];
}

int main(void)
{
  int a, b;
  top = 0;
  char v[200];
  
  while (scanf("%s", v) != EOF) {
    if (v[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (v[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
    } else if (v[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(v));
    }
  }
  printf("%d\n", pop());

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n, k;
  cin >> n >> k;
  vec p(n);
  rep(i,n) {
    cin >> p[i];
  }

  sort(all(p));

  ll sum = 0;
  rep(i,k) {
    sum += p[i];
  }

  cout << sum << endl;
}


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

int main()
{
	int n;
	while (cin >> n,n)
	{
		int dp[n+3];
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (int i=0; i<n; i++)
		{
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
			dp[i+3] += dp[i];
		}
		cout << dp[n]/3650 + (dp[n]%3650==0 ? 0 : 1) << endl;
	}
}

Measured memory_bytes: 0
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in =new Scanner(System.in);
	    int n=in.nextInt();
	    double[] p=new double[n];
	    for(int i=0;i<n;i++)p[i]=in.nextDouble();
	    double[][] a=new double[n][n+1];
	    for(int i=0;i<n;i++){
	        for(int j=0;j<n+1;j++)a[i][j]=0;
	    }
	    a[0][1]=p[0];
	    a[0][0]=1-p[0];
	    for(int i=1;i<n;i++){
	        a[i][0]=a[i-1][0]*(1-p[i]);
	        for(int j=1;j<=i+1;j++){
	            a[i][j]=a[i-1][j-1]*p[i]+a[i-1][j]*(1-p[i]);
	        }
	    }
	    double ans=0;
	    int k= n/2+1;
	    for(int i=k;i<n+1;i++){
	        ans+=a[n-1][i];
	    }
	    System.out.println(ans);
	}
}


Measured memory_bytes: 122472
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;

int ketasu(int n){
    string s=to_string(n);
    return s.size();
}


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

    a=a*pow(10,ketasu(b));

    
    a+=b;
    int c=sqrt(a);
    
    if(c*c==a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, C;
	cin >> N >> C;
	vector<vector<pair<int, int>>> program(C+1);
	for(int i=0; i<N; i++){
		int s,t,c;
		cin >> s >> t >> c;
		program[c].push_back({s, t});
	}

	vector<pair<int, int>> ts;
	for(int c=1; c<=C; c++){
		if(program[c].size()==0) continue;
		sort(program[c].begin(), program[c].end());
		auto p = program[c][0];
		for(int j=1; j<program[c].size(); j++){
			if(p.second == program[c][j].first){
				p.second = program[c][j].second;
			} else {
				ts.push_back({p.first, -c});
				ts.push_back({p.second, c});
				p = program[c][j];
			}
		}
		ts.push_back({p.first, -c});
		ts.push_back({p.second, c});
	}

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

	int ans = 0;
	set<int> current;
	for(int i=0; i<ts.size(); i++){
		debug(ts[i].first, ts[i].second);
		if(ts[i].second < 0){
			current.insert(-ts[i].second);
			ans = max(ans, (int)current.size());
		} else {
			current.erase(ts[i].second);
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
    int cnt = 0,N;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int m;
        scanf("%d",&m);
        if(m % 2)cnt++;
    }
    if(cnt % 2)printf("NO\n");
    else printf("YES\n");
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;

	lli ans = 0;

	for(lli i=1;i<=n;i++)ans+=i;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
O = list(input())
E = list(input())
A = []
if len(O)==len(E):
    for i in range(len(O)):
        A.append(O[i])
        A.append(E[i])
else:
    for i in range(len(E)):
        A.append(O[i])
        A.append(E[i])
    A.append(O[len(O)-1])
    
print(''.join(A))

Measured memory_bytes: 38384
N=int(input())
A=[int(i) for i in input().split()]
sorted_A=sorted(A)

def add(B,a,n):
    x = a
    while x<=n:
        B[x]+=1
        x+=x&(-x)
        
def sums(B,a):
    x=a
    S=0
    while x!=0:
        S+=B[x]
        x-=x&(-x)
    return S
  
  
  
def invnumber(n,A):
  B=[0]*(n*2+1)
  invs=0
  for i in range(n):
      s=A[i]+n
      invs+=sums(B,s)
      add(B,s,n*2)
  return n*(n-1)//2-invs
  
def Check(x):
  S=[0]
  for i in range(N):
    if A[i]>sorted_A[x]:
      S.append(S[-1]+1)
    else:
      S.append(S[-1]-1)
  return invnumber(N+1,S)
      
l,r=0,N-1
while l<r:
  m=(l+r)//2
  if Check(m)>N*(N+1)//4:
    r=m
  else:
    l=m+1
print(sorted_A[l])


Measured memory_bytes: 107620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[114514],b[114514],c[114514],dp[114514][3];
int main() {
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
	for(int i=1;i<n;i++){
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
int main(void) {
	int heap[251], heap_size, i;

	scanf("%d", &heap_size);
	for (i = 1; i <= heap_size; i++) {
		scanf("%d", heap+i);
	}
	for (i = 1; i <= heap_size; i++) {
		printf("node %d: key = %d, ", i, heap[i]);
		if (i/2 > 0) {
			printf("parent key = %d, ", heap[i/2]);
		}
		if (2*i <= heap_size) {
			printf("left key = %d, ", heap[2*i]);
		}
		if (2*i+1 <= heap_size) {
			printf("right key = %d, ", heap[2*i+1]);
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int main(){
    int N, p[10], pmax = 0, imax, ans = 0;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> p[i];
        if(p[i] > pmax){
            pmax = p[i];
            imax = i;
        }
    }
    for(int i = 0; i < N; ++i){
        if(i == imax)p[i] = p[i] / 2;
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

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



















/* 

Kが7の倍数なら1，11，…からK/7の倍数を探す
そうでなければ1，11，…からKの倍数を探す

*/

// ax = 1 (mod m) の解
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


// 1, 11, …に初めてAの倍数が出てくる項数
int64_t first (int64_t A) {
    int result = -1;
    
    if (A % 2 == 0 || A % 5 == 0) {
        return -1;
    }

    if (A == 1) {
        return 1;
    }
    
    // A % 10^n の周期を求める
    vector<int> period(1, 1);
    int n = 10 % A;
    while (n != 1) {
        period.push_back(n % A);
        n *= 10;
        n %= A;
    }

    /* for (int i = 0; i < period.size(); i++) {
        cout << period[i] << " ";
    }
    cout << endl; */

    // 周期をTとして，1がT個並んだものをAで割った余りをunit_residueとする
    int64_t T = period.size();
    vector<int64_t> period_sum(T, 1);
    int64_t unit_residue = 0;
    for (int64_t i = 1; i < T; i++) {
         period_sum[i] = (period_sum[i - 1] + period[i]) % A; 
    }
    unit_residue = period_sum[T - 1];

    /* for (int i = 0; i < period_sum.size(); i++) {
        cout << period_sum[i] << " ";
    }
    cout << endl; */
    
    if (unit_residue == 0) {
        int min = 0;
        for (int i = 0; i < T; i++) {
            if (period_sum[i] == 0) {
                return i + 1;
            }
        }
    }

    // 各period_sum[i]に対してunit_residue * x + period_sum[i] = 0 (mod A)の最小解を求める
    int64_t gcd = __gcd(unit_residue, A);
    int64_t inverse = modinv(unit_residue / gcd, A / gcd);
    vector<int64_t> minimum(T, A + 1);
    for(int i = 0; i < T; i++) {
        if (period_sum[i] % gcd == 0) {
            minimum[i] = (inverse * (A / gcd - period_sum[i] / gcd)) % (A / gcd);
        }
    }

    /* for (int i = 0; i < T; i++) {
        cout << minimum[i] << " ";
    }
    cout << endl; */
 
    // minimum[i]が最小となる添え字のうち最小の値をfitとする
    int64_t fit = 0;
    int64_t min = 1000000000;
    for (int i = 0; i < T; i++) {
        if (min > minimum[i]) {
            min = minimum[i];
            fit = i;
        }
    }
    result = T * min + fit + 1;
    return result;
}



int main () {
    int64_t K;
    cin >> K;

    if (K % 7 == 0) {
        cout << first (K / 7) << endl;
    }

    else {
        cout << first (K) << endl;
    }
}

Measured memory_bytes: 14944
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    b = a;
    sort(ALL(b));

    rep(i,n){
        if(a[i] == b[n-1]) cout << b[n-2] << endl;
        else cout << b[n-1] << endl;
    }
}

Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;


int main(){
	
	string a;
	cin>>a;
	
	int n;
	cin>>n;
	
	int cnt = 0;
	
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		
		s = s+s;
		
		
		for(int j=0;j<s.size();j++){
			bool ok = true;
			for(int k=0;k<a.size();k++){
				if(s[j+k] != a[k])ok = false;
			}
			if(ok){
				cnt++;
				break;
			}
		}
	}
	
	printf("%d\n", cnt);
	
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ll long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INt_MAX
#define inf llONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < ll, ll > a[N], tmp;
ll c[N];
ll dp[100];

bool cmp(pair < ll, ll > A, pair < ll, ll > B) {
    return A.fir * (B.sec + 1) > B.fir * (A.sec + 1);
}

void solve() {

    int n; ll t;
    scanf("%d %lld", &n, &t);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
        scanf("%lld %lld", &tmp.fir, &tmp.sec);
        if(tmp.fir == 0) c[++ cnt2] = tmp.sec + 1;
        else a[++ cnt1] = tmp;
    }

    sort(c + 1 , c + cnt2 + 1);
    sort(a + 1, a + cnt1 + 1, cmp);

    rep(i, 1, 30) dp[i] = t + 1;
    dp[0] = 0;
    rep(i, 1, cnt2 ) c[i] += c[i - 1];

    rep(i, 1, cnt1 ) {
        dep(j, 1, 30) {
            dp[j] = min(dp[j], (a[i].fir + 1) * (dp[j - 1] + 1) + a[i].sec);
        }
    }

    int ans = 0 ;
    for(int i = 0 ;i <= 30 ;i ++)
     {
       if(dp[i] > t) continue ;
       int j = 0 ;
       if(cnt2)
        j = upper_bound(c + 1 , c + cnt2 + 1 , t - dp[i]) - c - 1;
       ans = max(ans , i + j) ;
     }
    printf("%d\n", ans);
    return ;
}
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct T { ll b, l, u; };

bool trivial(const vector<T> &v) {
  ll result = 0;
  REP(i,v.size()) result += v[i].b;
  return result == 0;
}

ll score(const T& t, ll x) {
  if (t.b <= x) return (x - t.b) * t.u;
  else return (x - t.b) * t.l;
}

bool ok(vector<T> &v, ll x, ll t) {
  const int n = v.size();
  ll q = t / x, r = t % x;
  sort(ALL(v), [&](const T& a, const T& b) { return score(a, x) - score(a, 0) > score(b, x) - score(b, 0); });
  ll sum = 0;
  REP(i,n) {
    if (i < q) sum += score(v[i], x);
    else sum += score(v[i], 0);
  }
  ll result = -(1LL << 60);
  // cout << "qrs =  " << q << ' ' << r << ' ' << sum << endl;
  // REP(i,n) cout << score(v[i], 0) << ' ' << score(v[i], r) << ' ' << score(v[i], x) << endl;
  REP(i,n) {
    ll cnt = sum;
    if (i < q) {
      cnt -= score(v[i], x);
      cnt += score(v[i], r);
      cnt -= score(v[q], 0);
      cnt += score(v[q], x);
    } else {
      cnt -= score(v[i], 0);
      cnt += score(v[i], r);
    }
    // cout << "cnt: " << i << ' ' << cnt << endl;
    gs(result, cnt);
  }


  // cout << t << ' ' << result << endl;
  return result >= 0;
}

int main() {
  ll n, x;
  while (cin >> n >> x) {
    vector<T> v(n);
    REP(i,n) {
      cin >> v[i].b >> v[i].l >> v[i].u;
    }

    if (trivial(v)) { cout << 0 << endl; continue; }
    // ok(v, x, 115);
    // break;
    ll lb = 0, ub = x * n;
    while (lb + 1 < ub) {
      ll mid = (lb + ub) / 2;
      if (ok(v, x, mid)) ub = mid;
      else lb = mid;
    }

    cout << ub << endl;
  }
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<list>
 
using namespace std;
 
int  main(int arg,char** argc)
{
  long long int n,a,i=0;
  cin>>n>>a;
  while(n>0)
  {
    i++;
    n-=a;
  }
  cout<<i;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool jg=false;
    if((s.at(0)==s.at(1))&&(s.at(2)==s.at(3))&&(s.at(1)!=s.at(2))){
        jg=true;
    }
    if((s.at(0)==s.at(3))&&(s.at(2)==s.at(1))&&(s.at(0)!=s.at(1))){
        jg=true;
    }
    if((s.at(0)==s.at(2))&&(s.at(1)==s.at(3))&&(s.at(0)!=s.at(1))){
        jg=true;
    }
    if(jg==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
const ll INF = (ll)1e18;

template<typename Head> Head minimum(Head head, Head tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail)
{
  return std::min(head, minimum(tail...));
}

int main()
{
  ll N;
  ll A, B;
  std::cin >> N;
  std::cin >> A >> B;

  std::vector<ll> va;
  std::vector<ll> vb;
  std::vector<ll> vc;
  for (ll i = 0; i < N; i++) {
    ll p;
    std::cin >> p;
    if (p <= A) va.push_back(p);
    if (p >= A+1 && p <= B) vb.push_back(p);
    if (p >= B+1 ) vc.push_back(p);
  }

  ll ans = (ll)minimum(va.size(), vb.size(), vc.size());
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
A= [[int(i) for i in input().split()] for i in range(h)]
B = []
count = 0

for i in range(h):
    for j in range(w - 1):
        if A[i][j] % 2 == 1:
            A[i][j + 1] += 1
            B.append([i + 1, j + 1, i + 1, j + 2])
            count += 1

for i in range(h - 1):
    if A[i][-1] % 2 == 1:
        A[i + 1][-1] += 1
        B.append([i + 1, w, i + 2, w])
        count += 1
        
print(count)
for i in B: 
    print(i[0], i[1], i[2], i[3])

Measured memory_bytes: 30196
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())

L = [[] for _ in range(K)]
for i in range(N):
  temp = T[i]
  MOD = i%K
  L[MOD].append(temp)
ans = 0
for i in range(len(L)):
  for j in range(len(L[i])):
    if j == 0:
      Flag = True #なんでも出せる
    elif not Flag: #前回が制限された
      Flag = True
    elif Flag and L[i][j] == L[i][j-1]:
      Flag = False
    if L[i][j] == "r" and Flag: 
      ans += P
    elif L[i][j] == "s" and Flag: 
      ans += R
    elif L[i][j] == "p" and Flag: 
        ans += S
print(ans)
      

Measured memory_bytes: 13436
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    // ０を超えるための回数
    if(k < x / d){
        cout << x - d*k;
        return 0;
    }
   //原点を超えずに限界まで近いた後の回数
    k -= x / d;

    //残り回数が偶数なら往復するほうがよい
    if(k % 2 == 0){
        cout << x % d;
    }
    else {
        cout << d - (x%d);
    }
}

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

int main() {
  vector<vector<bool>> cards(4, vector<bool>(13, false));
  int n;
  cin >> n;
  char mark;
  int rank;
  for (int i = 0; i < n; i++) {
    cin >> mark >> rank;
    switch (mark) {
      case 'S':
        cards[0][rank - 1] = 1;
        break;
      case 'H':
        cards[1][rank - 1] = 1;
        break;
      case 'C':
        cards[2][rank - 1] = 1;
        break;
      case 'D':
        cards[3][rank - 1] = 1;
        break;
      default:
        break;
    }
  }
  for (int mark = 0; mark < 4; mark++) {
    for (int rank = 1; rank <= 13; rank++) {
      auto flag = cards[mark][rank - 1];
      if (!flag) {
        switch (mark) {
          case 0:
            cout << "S " << rank << endl;
            break;

          case 1:
            cout << "H " << rank << endl;
            break;

          case 2:
            cout << "C " << rank << endl;
            break;

          case 3:
            cout << "D " << rank << endl;
            break;
          default:
            break;
        }
      }
    }
  }
}



Measured memory_bytes: 3084
//
// Created by watemus on 09.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int t; cin >> t;
        n -= t;
    }
    cout << (n >= 0 ? n : -1) << endl;
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3644
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

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

class BMinorChange {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
string s,t;
cin>>s>>t;
int cnt=0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i]!=t[i]) cnt++;
        }
        cout<<cnt;
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    BMinorChange solver;
    solver.solve(in, out);
}


Measured memory_bytes: 3804
#include <iostream>  
#include <stdio.h>  
#include <math.h>  
#include <string.h>  
  
using namespace std;  
  
const int N = 1e6;  
const int SQRTN = ceil(sqrt((double) N));  
bool isPrime[N];  
int prefixsum[N];  
  
// Eratosthenes筛选法  
void esieve(void)  
{  
    memset(isPrime, true, sizeof(isPrime));  
  
    isPrime[0] = isPrime[1] = false;  
    for(int i=2; i<=SQRTN; i++) {  
        if(isPrime[i]) {  
            for(int j=i*i; j<=N; j+=i)  //筛选  
                isPrime[j] = false;  
        }  
    }  
}  
  
void maketable()  
{  
    prefixsum[0] = 0;  
    for(int i = 1; i <= N; i++)  
        prefixsum[i] = isPrime[i] ? prefixsum[i - 1] + 1 : prefixsum[i - 1];  
}  
  
int main()  
{  
    esieve();  
  
    maketable();  
  
    int n;  
    while(~scanf("%d", &n))  
        printf("%d\n", prefixsum[n]);  
  
    return 0;  
}  



Measured memory_bytes: 8072
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), x = sc.nextInt();
        int cur = 0;
        int cnt = 0;

        for(int i=0;i<n;i++) {
            cur += sc.nextInt();
            if(cur <= x) cnt++;
        }


        pw.println(cnt+1);
        pw.close();
    }
}

Measured memory_bytes: 21332
N = int(input())
Ratio = [tuple(map(int, input().split())) for _ in range(N)]
from math import ceil
Vote = (1, 1)
for t,a in Ratio:
    p = max((t+Vote[0]-1)//t, (a+Vote[1]-1)//a)
    Vote = (p*t, p*a)
print(sum(Vote))

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){int n,i,ans=0,k,a,c;
      map<int,int>mp;
      cin>>n;
      for(i=1;i<=n;i++){
          cin>>c;
          k=i-c;
          ans+=mp[k];
          a=i+c;
          mp[a]++;
      }cout<<ans;
    return 0;}

Measured memory_bytes: 26268
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string s;
  cin >> s;
  int64_t res = 0, k = 0;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s[i] == 'W') {
      res += i - k;
      ++k;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>
long long caculate(long long k,long long w);
int main()
{
	int n,i;
	long long a[105],k,w,s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	  {
	    scanf("%lld",&a[i]);
	  }
	  if(n==1) s=a[0];
	  for(i=0;i<=n-2;i++)
	   {
	   	  if(i==0)
	   	    {
	   	    	k=a[0];
	   	    	w=a[1];
	   	    	s=k/caculate(k,w)*w;
			}
			if(i!=0 && n!=2)
			{
				k=s;
				w=a[i+1];
				s=k/caculate(k,w)*w;
			}
	   }
	      printf("%lld\n",s); 
}
long long caculate(long long k,long long w)
{
	long long r,t;
	if(w>k)
	  {
	  	 t=w;w=k;k=t;
	  }
	while(w)
	  {
	  	  r=k%w;
	  	  k=w;
	  	  w=r;
	  }
   return k;
}

Measured memory_bytes: 128
def binary_search1(A, i):
    l = 0
    r = len(A)
    if i <= A[1]:
        return 0
    while True:
        m = (r + l) // 2
        if A[m] < i <= A[m + 1]:
            return m
        if A[m] < i:
            l = m + 1
        elif A[m] >= i:
            r = m

def binary_search2(A, i):
    l = 0
    r = len(A)
    if i >= A[len(A) - 2]:
        return 0
    while True:
        m = (r + l) // 2
        if A[m] <= i < A[m + 1]:
            return len(A) - m - 2
        if A[m] <= i:
            l = m + 1
        elif A[m] > i:
            r = m

n = int(input())
a = [0] + sorted(list(map(int, input().split()))) + [10 ** 10]
b = list(map(int, input().split()))
c = [0] + sorted(list(map(int, input().split()))) + [10 ** 10]
ans = 0
for i in b:
    ans += binary_search1(a, i) * binary_search2(c, i)
print(ans)

Measured memory_bytes: 24068
// sync

#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e3;

int n, m, x[N], y[N], c[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", x + i, y + i);
		c[(x[i] + y[i]) & 1]++;
	}
	if (c[0] && c[1]) return puts("-1"), 0;
	printf(c[0] ? "32\n1 " : "31\n");
	for (int i = 30; i >= 0; i--) printf("%d%c", 1 << i, " \n"[!i]);
	for (int i = 1; i <= n; i++) {
		if (c[0]) putchar('R'), x[i]--;
		for (int j = 30; j >= 0; j--)
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0)
					x[i] -= 1 << j, putchar('R');
				else
					x[i] += 1 << j, putchar('L');
			} else {
				if (y[i] > 0)
					y[i] -= 1 << j, putchar('U');
				else
					y[i] += 1 << j, putchar('D');
			}
		puts("");
	}
}

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

int main() {
    int n;
    cin>>n;
    bool b=false;
    int r;
    for(int i=1;i<1000;i++){
    	if(i*(i+1)/2==n){
    		b=true;
    		r=i;
		}
	}
	if(b==false){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
		cout<<r+1<<endl;
		vector<vector <int>> v(r+1);
		v[0].push_back(1);
		v[1].push_back(1);
		for(int i=1;i<r;i++){
			int left=i*(i+1)/2;
			int right=(i+1)*(i+2)/2;
			int index=0;
			for(int j=left+1;j<=right;j++){
				v[index].push_back(j);
				v[i+1].push_back(j);
				index++;
			}
		}
		
		for(int i=0;i<r+1;i++){
			cout<<v[i].size()<<" ";
			for(int j=0;j<v[i].size();j++){
				cout<<v[i][j]<<" ";
			}
			cout<<endl;
		}	
	}
	
}

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

int main()
{
	string s;
	int ans = INT32_MAX;

	cin >> s;

	int sz = s.size();
	for( int i = 0; i < sz - 1; i++ ) {
		if( s[i] != s[i + 1] ) {
			ans = min( ans, max( i + 1, sz - i - 1 ) );
		}
	}
	if( ans == INT32_MAX ) {
		ans = sz;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
//Kyokai no Kanata //
#include<bits/stdc++.h>

using namespace std;

typedef long long int LL;
typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
  const char* comma=strchr(names+1,',');
  cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define M(x) ((x)%mod)
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
float  inf=std::numeric_limits<double>::infinity();
const int mod = (int)(1e9) + 7;
LL DP[3];
int main(){
  string s;LL f=1; cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A') DP[0]=M(DP[0]+f);
    else if(s[i]=='B') DP[1]=M(DP[1]+DP[0]);
    else if(s[i]=='C') DP[2]=M(DP[1]+DP[2]);
    else DP[2]=M(M(3*DP[2])+DP[1]),DP[1]=M(M(3*DP[1])+DP[0]),DP[0]=M(M(3*DP[0])+f),f=M(f*3);

}
 cout<<DP[2]<<"\n";
return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	
	int cnt=0;
	int tmp1=0;
	int tmp0=0;
	for(int i=0; i<s.size(); i++){
		if(s.at(i)=='1'){
			if(tmp0){
				tmp0--;
				cnt+=2;
			}else{
				tmp1++;
			}
		}else{
			if(tmp1){
				tmp1--;
				cnt+=2;
			}else{
				tmp0++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <ll> vi;
ll mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,m,k,x,i,y,j,z,ans=0,sum=0,c=0;
	string s;
	cin>>n>>k;
	cin>>s;
	vi v;
	for(i=0;i<s.length()-1;i++){
	   if(s[i]=='A' && s[i+1]=='C'){
	       c++;
	   }
	   v.pb(c);
	}
	v.pb(c);
//	cout<<v[0]<<v[1]<<v[2]<<v[3]<<v[6]<<endl;
	for(i=0;i<k;i++){
	    c=0;
	    cin>>x>>y;
	    if(x==1) cout<<v[y-2]<<endl;
	    else if(y==1) cout<<0<<endl;
	    else cout<<v[y-2]-v[x-2]<<endl;
	}
    return 0; 
}

Measured memory_bytes: 1860
//https://qiita.com/Nabetani/items/1f41e38cb92654ede6d8
//http://gi.ics.nara-wu.ac.jp/~takasu/lecture/programming/H26-gengo1-9.pdf
//1個前の正面データを保有していたら、次が上面なのか補足可能
#include <iostream>
#include <string>
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using std::cin;
using std::cout;
using std::endl;
using std::string;
//using std::vector;

/*サイコロのクラス設計
メンバー変数　上面の情報、各面が保有する数、各方向の面;
メンバー関数　数字割り当て、投げ、
*/

class Dice
{
private:
public:
    int face[6]; //各面のポイント[0:1面,1:2面...]

    int BUsur, //Buffor_1回前の上面の数_後で名前変える
        Usur,  //上面の数、
        Nsur,  //各方向の面の数[0:current,1:previous]
        Ssur,
        Esur,
        Wsur,
        Bsur; //Bottomsur

    string order; //INPUTの2行目

    Dice(); //(int)にすると怒られ
    void Allocate_num();
    void Infor_upsur(int);
    void Infor_sur(); //これいる？
    void D_throw();   //throwだと何か反応
};

//rocket::rocket(int x, float y) : nenryo(x), sokudo(y) {} //;ではなくて{}

Dice::Dice() //;を付けない
    : face{0},
      BUsur(1),
      Usur(1),
      Nsur(5),
      Ssur(2),
      Esur(3),
      Wsur(4),
      Bsur(6)
{
}

void Dice::Allocate_num()
{
    for (int i = 0; i < 6; i++)
    {
        cin >> face[i]; //input 1行目読み込み
    }
}

void Dice::Infor_upsur(int x)
{
    if (x == 0)
        cout << face[Usur - 1] << endl;
    else if (x == 1)
        cout << face[BUsur - 1] << endl;
}

void Dice::Infor_sur()
{
}

void Dice::D_throw()
{
    int n = 0;
    cin >> order;

    //input 2行目読込できる かつ 最後の文字がnullではない.
    while (order[n] != '\0') //cin>>order && order[n] != '\0'にしてしまうとnullのstringが来るまで読み込み続ける
    {
        BUsur = Usur; //Upper情報の更新
        if (order[n] == 'N')
        {
            //前:後[U:S ,S:B, B:N, N:BU] EとWは保持
            Usur = Ssur;
            Ssur = Bsur;
            Bsur = Nsur;
            Nsur = BUsur;
        }
        else if (order[n] == 'S')
        {
            //前:後[U:N, N:B, B:S, S:BU] E,Wは保持
            Usur = Nsur;
            Nsur = Bsur;
            Bsur = Ssur;
            Ssur = BUsur;
        }
        else if (order[n] == 'E')
        {
            //[U:W, W:B, B:E, E:BU] N,Sは保持
            Usur = Wsur;
            Wsur = Bsur;
            Bsur = Esur;
            Esur = BUsur;
        }
        else if (order[n] == 'W')
        {
            //[U:E, E:B, B:W, W,BU]
            Usur = Esur;
            Esur = Bsur;
            Bsur = Wsur;
            Wsur = BUsur;
        }

        n++;
    }
}

//Allocate_num,error
/*
10_A.cc: In function ‘int main()’:
10_A.cc:49:11: error: request for member ‘Allocate_num’ in ‘first’, which is of non-class type ‘Dice()’
     first.Allocate_num();
*/
//https://blog.amagi.dev/entry/20121130/cpp_create_instance
int main()
{
    Dice first; //first()にするとエラー
    first.Allocate_num();
    first.D_throw();
    first.Infor_upsur(0); //cout << ~ <<にしない

    /* dice_firstの中の変数を呼び出したいとき
    cout << first.face[1] << first.face[5];
    */
    return 0;
}


Measured memory_bytes: 3196
import sys

for i in sys.stdin:
    h,w = map(int,i.split())

    if h==0 and w==0:
        break

    for i in range(h):
        str = ''
        for j in range(w):
            if (i+j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print()

Measured memory_bytes: 7648
h,n = map(int,input().split())
magic = [ list(map(int,input().split())) for i in range(n)]
INF = float("inf")

dp =  [[INF]*(h+1) for i in range(n+1)]

"""
i番目までの魔法の中から攻撃力の合計が
jを超えるように選んだときの消費精神力の最小値
"""

for i in range(n):
    for j in range(h):
        if j < magic[i][0]:#その魔法で一撃
             dp[i+1][j+1] = min(dp[i][j+1],magic[i][1])
        elif j >= magic[i][0] and 0<= j+1-magic[i][0] <= h:
            dp[i+1][j+1] = min(dp[i][j+1],dp[i][j+1-magic[i][0]]+magic[i][1],dp[i+1][j+1-magic[i][0]]+magic[i][1])#その魔法を連打したときが考慮されていない
        
print(dp[n][h])


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

typedef unsigned long long ull;

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

	int n;
	cin >> n;

	ull sum = 0;
	for (int i = 1; i <= n; i++) {
		ull numberofthingsidivides = n/i;
		sum += (i*(1+numberofthingsidivides)*numberofthingsidivides)/2;
	}
	cout << sum << '\n';
}


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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
import math
n,x,t=map(int, input().split())

print(math.ceil(n/x)*t)

Measured memory_bytes: 9152