akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int dp[100001];
using namespace std;
int dfs(int s, int d, vector<int> &a){
    //cout<<s<<" "<<dp[s]<<" "<<d<<endl;
    if(dp[s]!= -1){
        if(dp[s] == 1)return d%2;
        else return (d + 1)%2;
    }
    int ans = (d+1)%2;
    for(int i = 0 ; i < a.size() ; i++){
        if(s - a[i] >= 0){
            int x = dfs(s - a[i], d + 1, a);
            if(x == d%2){
                ans = d%2;
                break;
            }
        }
    }
    if(ans == d%2)dp[s] = 1;
    else dp[s] = 0;
    return ans;
} 

int main(){
    long long mod = 1000000007;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    vector<int> a(n, 0);
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    memset(dp, -1, sizeof(dp));
    int ans = dfs(k, 0, a);
    if(ans == 0){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    return 0;
}

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

using namespace std;

//#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

int N;
int p[5000], tmp[5000];

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

    cin >> N;
    for(int i = 0; i < N; ++i) cin >> p[i];
    int res = INF;
    for(int i = 0; i <= p[0]; ++i) {
        int cnt = i;
        memset(tmp, 0, sizeof(tmp));
        tmp[0] = i;
        for(int j = 1; j < N; ++j) {
            cnt += (p[j - 1] - tmp[j - 1]) * 2;
            tmp[j] += p[j - 1] - tmp[j - 1];
            chmin(tmp[j], p[j]);
        }
        cnt += p[N - 1] - tmp[N - 1];
        chmin(res, cnt);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3236
#!/usr/bin/env python3
import sys
from collections import defaultdict


def solve(N: int, S: "List[str]"):
    ndic = defaultdict(int)

    for s in S:
        ndic[s[0]] += 1

    M = [m for m in "MARCH" if ndic[m] > 0]

    res = 0
    for i in range(len(M)-2):
        for j in range(i+1,len(M)-1):
            for k in range(j+1,len(M)):
                res += ndic[M[i]] * ndic[M[j]] * ndic[M[k]] 
    print(res)




# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

// #define rep(i,x,n,inc=1) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 100000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

char res[1000];

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

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

	ll t, i, x, j, y, 	z, k, N;
	ll len, p = 1;
	// rd(N--);
	cin >> N;
	N--;

	for (len = (1); len < (100); len++) {
		p *= 26;
		if (N >= p) {
			N -= p;
			continue;
		}
		break;
	}
	for (i = (0); i < (len); i++) {
		res[len - 1 - i] = N % 26 + 'a';
		N /= 26;
	}
	ce(res);


}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF =1LL << 60;

//DP テーブル
ll dp[100100];

int main() {
   ll N,M; 
   cin >> N>>M;
   vcl bs(N+1);

   rep(i,M){
       ll a;
       cin>>a;
       bs[a]=1;
   }
vcl dp(N+2);

// 初期条件
dp[N] = 1;

// ループ
for (ll i = N-1; i >= 0;i--) {
       if(bs[i]){
dp[i]=0;
  continue;     }
  dp[i]=dp[i+1]+dp[i+2];
  dp[i]%=mod;
}
cout<<dp[0]<<endl;

return 0 ;

}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var x = sc.intarr[0];

        int ma = 1;
        for(int i = 1; i <= 35; ++i)
        {
            for(int j = 2; j <= 10; ++j)
            {
                
                if ((int)Math.Pow(i, j) <= x&& (int)Math.Pow(i, j)>=1)
                {

                    int l = (int)Math.Pow(i, j);
                    //wr.wri(l);
                    ma = Math.Max(ma, l);
                }
            }
        }

        wr.wri(ma);

    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(){
  int n,s,cnt=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    int flag=0;
    for(int j=1;j*j<s;j++){
      int a=s-j;
      int b=2*j+1;
      if(a%b==0){
	if(a/b<s){
	  flag=1;
	  break;
	}
      }
    }
    if(flag==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

using i64=int64_t;

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

void solve(){
    int N,K;
    cin >> N >> K;

    if(N%K==0) cout << 0 << endl;
    else cout << 1 << endl;
}

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


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

using namespace std;



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

	auto f = [](int x) {
		int sum = 0;

		while (x > 0) {
			sum += x % 10;
			x /= 10;
		}

		return sum;
	};

	int x;
	cin >> x;

	if (x % f(x)) cout << "No";
	else cout << "Yes";

	//system("pause");

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  string ans = "No";
  if(s[2]==s[3] && s[4]==s[5])
    ans = "Yes";
  cout << ans << endl;
}

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

for i in range(1,n-1):
    if p[i] != max(p[i-1],p[i],p[i+1]) and p[i] != min(p[i-1],p[i],p[i+1]):
        count+=1
        
print(count)

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n;
int a[1007][1007];
int indeg[maxn],dist[maxn];
vector<int> G[maxn];

inline int index(int a,int b)
{
    return (min(a,b)-1)*n+max(a,b);
}

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n-1;j++)
        {
            cin>>a[i][j];
        }
        for (int j=1;j<=n-2;j++)
        {
            G[index(i,a[i][j])].pb(index(i,a[i][j+1]));
            indeg[index(i,a[i][j+1])]++;
        }
    }

    queue<int> q;
    for (int i=1;i<=n*n;i++)
    {
        if (indeg[i]==0) q.push(i),dist[i]=1;
    }
    int maxx=0;
    while (!q.empty())
    {
        int now=q.front();
        maxx=max(maxx,dist[now]);
        q.pop();
        for (int i:G[now])
        {
            indeg[i]--;
            if (!indeg[i]) dist[i]=dist[now]+1,q.push(i);
        }
    }
    for (int i=1;i<=n*n;i++) if (dist[i]==0) return cout<<-1<<endl,0;
    cout<<maxx<<endl;
}



Measured memory_bytes: 53120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  while (k <= n + 1) {
    ll head = k * (k - 1) / 2;
    ll tail = k * ((2 * n) - (k - 1)) / 2;
    ans += (tail - head + 1);
    ans %= MOD;
    k++;
  }

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


Measured memory_bytes: 3608
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

   ll ans=a*b/__gcd(a,b);
   cout<<ans<<endl;
}



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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

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

char str1[4010];
char str2[4010];

int main(){
  while(~scanf("%s %s",str1,str2)){
    int ans = 0;
    int len1 = strlen(str1);
    int len2 = strlen(str2);

    for(int off = -len1; off <= len2; off++){
      int len = 0;
      for(int i = max(off, 0); i < min(len1+off, len2); i++){
        if(str1[i-off] == str2[i])
          ans = max(ans, ++len);
        else
          len = 0;
      }
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const int Max=1e6+9;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
int n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
char grid[11][11]={'.'};
int mem[Max][5];
void init()
{
    memset(mem,-1,sizeof mem);
}
//////////////////////////////////////////////////////////

int a[Max],b[Max],c[Max];
int solve (int i ,int last )
{
    if(i==n)
        return 0;

    int &ret=mem[i][last];
    if(~ret)return ret;
    ret=0;
    if(last!=0)
        ret=max(ret,a[i]+solve(i+1,0));
    if(last!=1)
        ret=max(ret,b[i]+solve(i+1,1));
    if(last!=2)
        ret=max(ret,c[i]+solve(i+1,2));
        return ret;
}

void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
init();
   n =D();
   for(int i=0; i<n;i++)
   {
       a[i]=D();
       b[i]=D();
       c[i]=D();
   }
   printf("%d",solve(0,3));



}


Measured memory_bytes: 32280
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	
	void Solve() {
		int N; cin >> N;
		int A[100];
		int SA = 0;
		rep(i, N) cin >> A[i];
		rep(i, N) SA += A[i];
		UL p = 0;
		rep(i, N) { A[i] = abs(A[i] * N - SA); }
		rep(i, N) {
			if (A[p] > A[i]) p = i;
		}
		cout << p << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int h, n;
    scanf("%d %d", &h, &n);
    int a[n];
    for (int i = 0; i <n ; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i <n ; ++i) {
        h = h-a[i];
    }
    if(h>0) printf("No");
    else printf("Yes");
}

Measured memory_bytes: 512
#include <stdio.h>

inline int min(int a, int b)
{
    if (a<b)    return a;
    else        return b;
}

int main(void)
{
    int c[10][10];
    int i, j, k, h, w, d, s=0;

    scanf("%d%d", &h, &w);

    // 魔力表
    for (i=0; i<10; i++) {
        for (j=0; j<10; j++) {
            scanf("%d", &c[i][j]);
        }
    }

    // 1に変換する最少魔力
    for (k=0; k<=9; k++) {
        for (i=0; i<=9; i++) {
            for (j=0; j<=9; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    for (i=0; i<h; i++) {
        for (j=0; j<w; j++) {
            scanf("%d", &d);
            if (d!=-1) {
                s += c[d][1];
            }
        }
    }
    printf("%d\n", s);


    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <string>
#include <stdlib.h>
#include <iostream>
using namespace std;

int n;
string str;
string ans;
void go()
{
	for (int i = 1; i <= n - 2; i++) {
		char nxt;
		if (ans[i] == 'S') {
			if (str[i] == 'o') {
				nxt = ans[i - 1];
			}
			else {
				nxt = (ans[i - 1] == 'S' ? 'W' : 'S');
			}
		}
		else {
			if (str[i] == 'o') {
				nxt = (ans[i - 1] == 'S' ? 'W' : 'S');
			}
			else {
				nxt = ans[i - 1];
			}
		}
		if (i == n - 2) {
			if (ans[n-1] != nxt) {
				return;
			}
		}
		ans[i + 1] = nxt;
	}
	if (ans[n - 1] == 'S') {
		if (str[n - 1] == 'o' && ans[0] == ans[n - 2] || str[n - 1] == 'x' && ans[0] != ans[n - 2]) {
			cout << ans << endl; exit(0);
		}
	}
	else {
		if (str[n - 1] == 'x' && ans[0] == ans[n - 2] || str[n - 1] == 'o' && ans[0] != ans[n - 2]) {
			cout << ans << endl; exit(0);
		}
	}
}
int main() {
	cin >> n;
	ans.resize(n);
	cin >> str;
	//[0] = sheep
	if (str[0] == 'o') {
		ans[0] = 'S';
		//양양
		ans[n - 1] = ans[1] = 'S';
		go();
		//늑늑
		ans[n - 1] = ans[1] = 'W';
		go();

		ans[0] = 'W';
		ans[n - 1] = 'S'; ans[1] = 'W';
		go();
		ans[n - 1] = 'W'; ans[1] = 'S';
		go();
	}
	else {
		ans[0] = 'S';
		ans[n - 1] = 'S'; ans[1] = 'W';
		go();
		ans[n - 1] = 'W'; ans[1] = 'S';
		go();

		ans[0] = 'W';
		ans[n - 1] = ans[1] = 'S';
		go();
		ans[n - 1] = ans[1] = 'W';
		go();
	}
	puts("-1");
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<long long> v(n);
	long long ans=0,ruiseki=0;;

	for(long long i=0;i<n;i++){
		cin>>v.at(i);
		ruiseki+=v.at(i);
	}

	for(long long i=0;i<n;i++){
		long long hoge=(ruiseki-v.at(i))%inf;
		ans+=hoge*v.at(i);
		ans%=inf;
	}

	cout<<(ans*modinv((long long)2,inf))%inf<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 4840
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 10005

int n,m;

int solve() {
	int temp[maxN]={};
	for(int i=0;i<m;i++){
		cin>>temp[i];
	}
	for(int i=0;i<m;i++){
		
		n-=temp[i];
		if(n<0){
			return -1;
		}
	}
	return n;
}

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	
	cin>>n>>m;
	cout<<solve()<<endl;
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<stdlib.h>

int main()
{

    int a,  i, n;

    scanf("%d", &a);
    i=1;
    while((360*i)%a!=0)
    {
        i++;
    }
    n = (360*(i))/(a*1.0);
    printf("%d", n);

    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  vector<LL> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<LL> ruiseki(n+1);
  ruiseki[0]=0;
  for(int i=0;i<n;i++){
    ruiseki[i+1]=a[i]+ruiseki[i];
  }
  vector<LL> bubun(n*(n+1)/2);
  int now=0;
  for(int i=0;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      bubun[now]=ruiseki[j]-ruiseki[i];
      now++;
    }
  }
  LL ans=0;
  int count=0;
  vector<bool> use(n*(n+1)/2,true);
  for(LL i=63;i>=0;i--){
    count=0;
    for(int j=0;j<n*(n+1)/2;j++){
      if((bubun[j]&(1ll<<i))&&use[j]){
        count++;
      }
    }
    if(count>=k){
      ans+=(1ll<<i);
      for(int j=0;j<n*(n+1)/2;j++){
        if((bubun[j]&(1ll<<i))==0){
          use[j]=false;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    string s;
    cin >> s;
    bool check = false,check2 = false;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'A')check = true;
        if(s[i] == 'B')check2 = true;
        
    }
    if(check && check2)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << 180 * (n-2) << endk;
  return 0;
}


Measured memory_bytes: 3560
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
using ll = long long;


int main(){
	char s[3];

	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	
	int x, y;
	int z = 0;

	x = 700;
	y = 100;
	for (int i = 0; i < 3; i++) {
		if ('o' == s[i]) {
			z++;
		}
	}

	cout << x + (y*z) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def main():
    n = int(stdin.readline().rstrip())
    ls = list(map(int, stdin.readline().split()))
    ans = 0
    m = 10**9 + 7
    sum1 = sum(ls)%m
    for i in range(n-1):
        sum1 = sum1-ls[i]
        ans = ((sum1 * ls[i])+ans) % m
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

struct S {
    int a,b,c,d;
};
vector<S> s;

ll ans=0, N, M, Q;
int A[11];

void f(int pos) {
    A[pos] = A[pos-1];

    while (A[pos] <= M) {
        if (pos == N) {
            ll score = 0;
            for (auto& [a,b,c,d] : s) {
                if (A[b] - A[a] == c) {
                    score += d;
                }
            }
            ans = max(ans, score);
        } else {
            f(pos + 1);
        }
        A[pos]++;
    }
}

int main() {
    fastio;
    cin >> N >> M >> Q;
    s.resize(Q);
    for (auto& [a,b,c,d] : s) {
        cin >> a >> b >> c >> d;
    }
    A[0] = 1;
    f(1);
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;



int main()
{

    ll X;
    cin >> X;

    int num = 10000;
    ll table[num];
    
    for(int i = 0;i<num;i++){
        table[i] = pow(i,5);
    }
    
    ll ans_a = 0;
    ll ans_b = 0;
    for(int a = 0;a < num;a++){
        int hugou = 0;
        ll nokori = X - table[a];
        if(nokori > 0) hugou = -1;
        else hugou = 1;
        
        for(int b = 0;b < num;b++){
            if( table[a] - hugou * table[b] == X){
                ans_a = a;
                ans_b = hugou * b;
                cout << ans_a << " "<< ans_b << endl;
                return 0;
            }// else if( table[b] > abs(nokori)){
            //     break;
                
            // }
        }
    }

    return 0;
}


Measured memory_bytes: 4220
import itertools

n = int(input())
ans = 0


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def q(m):
    check = 0
    while m >= check * (check + 1) / 2:
        check += 1
    return check - 1


a = prime_factorize(n)
gr = itertools.groupby(a)
for key, group in gr:
    ans += q(len(list(group)))

print(ans)


Measured memory_bytes: 9120
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int pattern = 4;
    int num = N;
    while(num > 0) {
        num /= 10;
        pattern *= 4;
    }
    set<int> st;
    rep(i, pattern) {
        string S;
        int bit = i;
        int cnt[3] = {};
        while(bit > 0) {
            if (bit % 4 == 0) {S += '3'; cnt[0]++;}
            else if (bit % 4 == 1) {S += '5'; cnt[1]++;}
            else if (bit % 4 == 2){S += '7'; cnt[2]++;}
            else break;
            bit /= 4;
        }
        // cout << S << endl;
        if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) {
            st.insert(stoll(S));
        }
    }
    int ans = 0;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        if(*itr <= N) {
            ans++;
            //cout << *itr << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += min(X[i], K - X[i]);
    }
    cout << ans * 2 << endl;
    return 0;
}

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

a = [i for i in range(1, 1000)]
b = [-i for i in range(1, 1000)]
c = []
for idx in range(len(a)):
    c.append(a[idx])
    c.append(b[idx])
c.append(0)
c.sort()

tmp = []
for i in c:
    if not i in p:
        tmp.append([abs(X-i), i])
tmp2 = [10000000000, -1]
for i in tmp:
    if tmp2[0] > i[0]:
        tmp2[0] = i[0]
        tmp2[1] = i[1]

print(tmp2[1])


Measured memory_bytes: 67488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    int l1 = a[(n - 1) / 2], l2 = a[(n - 1) / 2 + 1];
    int r1 = b[(n - 1) / 2], r2 = b[(n - 1) / 2 + 1];
    if (n & 1)
        cout << r1 - l1 + 1 << endl;
    else
        cout << (r1 + r2) - (l1 + l2) + 1 << endl;
}

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

const int N = 105, K = 1e5+5;
int n, k, a[N], dp[K];

int32_t main() {
  scanf("%d%d", &n, &k);

  for (int i = 0; i < n; i++)
    scanf("%d", a+i);

  for (int i = 1; i <= k; i++) {
    int cnt[2] = {0,0};

    for (int j = 0; j < n; j++)
      if (i - a[j] >= 0)
        cnt[dp[i-a[j]]]++;

    if (cnt[0] > 0)
      dp[i] = 1;
  }

  printf("%s\n", dp[k] ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String forecast = sc.next();
		String result = sc.next();
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			if(forecast.charAt(i) == result.charAt(i)) ans++;
		}
		System.out.println(ans);
	}
}




Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n = read();
	string s = "";
	int k = 1;
	while (n != 0) {
		if (n % (k * 2) != 0) {
			s = "1" + s;
			n -= k;
		}
		else s = "0" + s;
		k *= -2;
	}
	if (s.size() == 0) s = "0";
	cout << s << endl;
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  string ans = "NO";
  int i = 1;
  while (a*i % b != 0) {
    if (a*i % b == c) {
      ans = "YES";
      break;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n, mx;
  cin >> n >> mx;
  vector<int> w(n+1), v(n+1);
  rep(i,n) cin >> w[i+1] >> v[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(mx+1,0));
  dp[0][0] = 0;
  for(int i=0; i<n; ++i) {
    for(int j=0; j<=mx; ++j) {  
      if (j+w[i+1] <= mx) dp[i+1][j+w[i+1]] = max(dp[i+1][j+w[i+1]], dp[i][j]+v[i+1]); 
      dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
    }
  }
  // for(int i=0; i<=n; ++i) {
  //   cout << i << ": "; 
  //   for(int j=0; j<=mx; ++j) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[n][mx] << endl;
  return 0;
}

Measured memory_bytes: 83140
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define F first
#define S second
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;

int x[114514], v[114514], rwa[114514];
int rm[114514], lm[114514];
int ans;
signed main() {
	int n, c; cin >> n >> c;
	rep(i, n)cin >> x[i + 1] >> v[i + 1];
	n++;
	x[n] = c;
	n++;
	rep(i, n)rwa[i + 1] = v[i];
	rep(i, n)rwa[i + 1] += rwa[i];
	rep(i, n) {
		rm[i] = rwa[i + 1] - x[i];
	}
	rep(i, n)rm[i + 1] = max(rm[i], rm[i + 1]);

	for (int i = 1; i < n; i++) {
		int d = rwa[n] - rwa[i] - 2 * (c - x[i]) + rm[i - 1];
		ans = max(ans, d);
	}

	for (int i = 0; i < n; i++)x[i] = c - x[i];
	reverse(v, v + n);
	reverse(x, x + n); 
	rep(i, n)rwa[i + 1] = v[i];
	rep(i, n)rwa[i + 1] += rwa[i];
	rep(i, n) {
		rm[i] = rwa[i + 1] - x[i];
	}
	rep(i, n)rm[i + 1] = max(rm[i], rm[i + 1]);

	for (int i = 1; i < n; i++) {
		int d = rwa[n] - rwa[i] - 2 * (c - x[i]) + rm[i - 1];
		ans = max(ans, d);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[55];

void solve() {
    vector<P> res;
    int m = 0, idx = 1;
    for (int i = 1; i <= n; i++) {
        if (abs(a[i]) > m) {
            m = abs(a[i]);
            idx = i;
        }
    }
    cout << 2 * n - 1 << endl;
    for (int i = 1; i <= n; i++) {
        cout << idx << " " << i << endl;
    }

    if (a[idx] >= 0) {
        for (int i = 1; i < n; i++) {
            cout << i << " " << i + 1 << endl;
        }
    } else {
        for (int i = n; i > 1; i--) {
            cout << i << " " << i - 1 << endl;
        }
    }
}

void input() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i]; 
}

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

    input();
    solve();
}


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

using namespace std;

#define MOD 998244353

int n, nn, c[2];
char x[300005];
set<char> v[2];
long long ans = 1;

int main() {
	scanf("%d%s", &n, x);
	nn = n * 3;
	for (int i = 1; i <= n; i++)
		ans = ans * i % MOD;
	for (int i = 0; i < nn; i++)
		if (c[1] && !v[1].count(x[i])) {
			ans = ans * c[1] % MOD;
			c[1]--;
		} else if (c[0] && !v[0].count(x[i])) {
			ans = ans * c[0] % MOD;
			if (++c[1] == 1) {
				v[1] = v[0];
				v[1].insert(x[i]);
			}
			if (--c[0] == 0)
				v[0].clear();
		} else {
			c[0]++;
			v[0].insert(x[i]);
		}
	printf("%lld\n", ans);
}


Measured memory_bytes: 512
from itertools import accumulate

N, K = map(int, input().split())
*A, = map(int, input().split())
for i in range(K):
    a = [0]*N
    allN = True
    for j in range(N):
        l, r = max(j-A[j], 0), (j+A[j]+1)
        a[l] += 1
        if r < N:
            a[r] -= 1
        if A[j] != N:
            allN = False
    A = list(accumulate(a))
    if allN:
        break

print(*A)


Measured memory_bytes: 184188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <stack>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int n; std::cin >> n;
    std::vector<std::array<int, 3>> Pos(n);
    for(int i = 0; i < n; ++i){ std::cin >> Pos[i][0] >> Pos[i][1]; Pos[i][2] = i; }
    std::sort(Pos.begin(), Pos.end());

    std::stack<int, std::vector<int>> Stk;

    atcoder::dsu uf(n);
    Stk.emplace(0);
    for(int i = 1; i < n; ++i){
        const int v = Stk.top();
        if(Pos[v][1] > Pos[i][1]){ Stk.emplace(i); continue; }
        uf.merge(v, i);
        Stk.pop();
        while(not Stk.empty() and Pos[Stk.top()][1] < Pos[i][1]){
            uf.merge(Stk.top(), i);
            Stk.pop();
        }
        Stk.emplace(v);
    }
    std::vector<int> res(n);
    for(int i = 0; i < n; ++i) res[Pos[i][2]] = uf.size(i);
    for(int i = 0; i < n; ++i) std::cout << res[i] << '\n';
    return 0;
}

Measured memory_bytes: 7160
//https://atcoder.jp/contests/abc176/tasks/abc176_a
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(int)ceil(1.0*n/x)*t<<"\n";
	return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int a[26];
int main()
{
	int i,n,k;
	string s;
	cin>>s;n=s.length();
	for(i=0;i<n;i++)a[s[i]-'a']=1;
	for(k=0;k<26;k++)
		if(!a[k])break;
    if(k==26)cout<<"None";
    else printf("%c",k+'a');
	return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, K;
string S;
int f[301][301][301], INF = 1 << 29;

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

    cin >> S >> K;
    N = sz(S);

    rep(i, N + 1)rep(j, N + 1)rep(k, K + 1)f[i][j][k] = INF;
    f[0][N][0] = 0;

    rep(i, N) for (int j = N; j > i; --j) rep(k, K + 1) {
        int a = f[i][j][k];
        if (S[i] == S[j - 1])smin(f[i + 1][j - 1][k], a);
        if (k < K) smin(f[i + 1][j - 1][k + 1], a);
        smin(f[i + 1][j][k], a + 1);
        smin(f[i][j - 1][k], a + 1);
    }

    int mi = INF;
    rep(i, N + 1)rep(j, i + 1)rep(k, K + 1) {
        smin(mi, f[i][j][k]);
    }
    int ans = sz(S) - mi;
    cout << ans << endl;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 400

int N;
int a[MAX];

long long acc[MAX + 1];
long long memo[MAX + 1][MAX + 1];

long long dfs( int l, int r )
{
	if( l == r ) {
		return 0;
	}
	if( memo[l][r] ) {
		return memo[l][r];
	}
	long long res = INF;
	for( int i = l; i < r; i++ ) {
		res = min( res, dfs( l, i ) + dfs( i + 1, r ) + acc[r + 1] - acc[l] );
	}
	return memo[l][r] = res;
}

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

	for( int i = 0; i < N; i++ ) {
		acc[i + 1] = acc[i] + a[i];
	}

	long long ans = dfs( 0, N - 1 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    string S[H];
    REP(i, H){
        cin >> S[i];
    }

    int field[H+2][W+2] = {};

    FOR(i, 1, H){
        FOR(j, 1, W){
            if (S[i-1][j-1] == '#'){
                field[i][j] += 1;
            }
        }
    }

    int res;
    FOR(i, 1, H){
        FOR(j, 1, W){
            FOR(m, -1, 1){
                FOR(n, -1, 1){
                    if (m != 0 or n != 0){
                        res += field[i+m][j+n];
                    }
                }
            }
            if (S[i-1][j-1] == '.'){
                cout << res;
            }
            else{
                cout << '#';
            }
            res = 0;
            //cout << field[i][j] << endl;
        }
        cout << '\n';
    }
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    ll s,c;
    ll b[n];
    for(ll i=0;i<n;++i){
        b[i]=12345;
    }
    for(ll i=0;i<m;++i){
        cin >> s >> c;
        if(b[s-1] != 12345 and b[s-1] != c){
            cout<<-1<<endl;
            return 0;
        }
        b[s-1]=c;
    }
    //cout<<b[0]<<b[1]<<b[2]<<endl;
    if(n==1 and b[0]==0){
        cout<<0<<endl;
        return 0;
    }
    if(n==1 and m==0){
        cout<<0<<endl;
        return 0;
    }

    for(ll i=0;i<n;++i){
        if(i==0){
            if(b[i]==0){
                cout<<-1<<endl;
                return 0;
            }else if(b[i]==12345){
                cout<<1;
            }else{
                cout<<b[i];
            }
        }else{
            if(b[i]==12345){
                cout<<0;
            }else{
                cout<<b[i];
            }
        }
    }
    cout<<endl;
    return 0;
}

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

int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		a--;
	}
	else {
		b--;
	}

	cout << a << " " << b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    lint L, R;
    cin >> L >> R;
    lint minx = (1 << 20);
    lint z = min(L+4039, R+1);
    FOR(i, L, z) {
        FOR(j, i+1, z) {
            lint x = (i % 2019) * (j % 2019) % 2019;
            if(x < minx) minx = x;
        }
    }
    cout << minx << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import math


def solve(H: int, W: int):
    # print(int((H/2)*W) if H%2==0 else int((H//2)*W+math.ceil(W/2)))
    if H == 1 or W == 1:
        print(1)
        return
    print(math.ceil(H*W/2))
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    string s; cin>>s;
  int flagA,flagB; flagB=flagA=0;
    for (auto i : s) {
        if(i=='A')
        flagA=1;
        
        if(i=='B')
        flagB=1; 

    }
    
    if(flagB && flagA)
    cout<<"Yes";
    else
      cout<<"No";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	long long x, y;
	cin >> x >> y;
	// yがxの約数だったら存在しない
	if(x % y == 0) puts("-1");
	else {
		while(1){
			if(x % y != 0){
				cout << x << endl;
				return 0;
			} else {
				 x += x;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int INF = 1 << 30;

ll h, w;
string a[22];
int dx[4] = {0, -1, 1, 0};
int dy[4] = {1, 0, 0, -1};


int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> h >> w;
  REP(i, h) cin >> a[i];

  int ans = 0;
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) { 
      if (a[i][j] == '#') continue;
      vector<vector<int>> dist(h, vector<int>(w, INF));
      queue<pair<int,int>> q;
      dist[i][j] = 0;
      q.emplace(i, j);
      while(q.size()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        for(int d = 0; d < 4; ++d) {
          int ny = y + dy[d];
          int nx = x + dx[d];
          if(0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.') {
            if (dist[ny][nx] > dist[y][x] + 1) {
              dist[ny][nx] = dist[y][x] + 1;
              ans = max(ans, dist[ny][nx]);
              q.emplace(ny, nx);
            }
          }
        }
      }
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256