akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main () {
	int n, a, b;
	scanf("%d", &n);
	if(n == 1){
		puts("Hello World");
		return 0;
	}else{
		scanf("%d %d", &a, &b);
		printf("%d\n", a + b);	
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200000;
int n;
struct h{int num,cnt;}p[N];
int tmp[N];
int main()
{
ios::sync_with_stdio(false);
cin >>n;
for(int i=1;i<=n;i++)
	cin >>tmp[i];
sort(tmp+1,tmp+1+n);
int m=0;
for(int i=1;i<=n;i++)
	{
	if(p[m].num!=tmp[i])
		{
		p[++m].num=tmp[i];
		p[m].cnt=1;
		}
		else 
			{
			p[m].cnt++;
			}
	}
int ans=0;
for(int i=1;i<=m;i++)
	{
	if(p[i].num>p[i].cnt)
		ans+=p[i].cnt;
	else if(p[i].num<p[i].cnt) ans+=p[i].cnt-p[i].num;
	}
cout <<ans;
return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

//const ll INF=(ll)1e19;
const int INF=(1<<30);

vector<int> r;
vector<int> c;
int dp[105][105];


int main(){
  int n;
  cin >> n;
  REP(i,n){
    int rr,cc;
    cin >> rr >> cc;
    r.emplace_back(rr);
    c.emplace_back(cc);
  }

  REP(i,n)REP(j,n)dp[i][j]=INF;

  REP(i,n)REP(j,n){
    if(j+i >=n)continue;
    if(i==0){
      dp[j][j] = 0;
    }else{

      FOR(k,j,j+i){
        chmin(dp[j][j+i], dp[j][k] + r[j]*c[k]*c[j+i] + dp[k+1][j+i]);
      }
    }
  }

  cout << dp[0][n-1] << endl;
}



Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 

int N, M;
const int MAX_NM = 100000;
pair<ll, int> AB[MAX_NM];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second; 
    
    sort(AB, AB + N);

    ll ans = 0;
    int num = 0;
    int i = 0;
    while (num < M) {
        if (AB[i].second < M - num) {
            ans += AB[i].first * AB[i].second;
            num += AB[i].second;
            i++;
        }
        else {
            ans += AB[i].first * (M - num);
            num += M - num;
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9L+7;
int n;
vector<vector<ll>> inp;
vector<vector<ll>> dp;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    /*#ifndef ONLINE_JUDGE
    #endif*/
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        /*inp.assign(r+2,vector<ll> (c+2,0));
        dp.assign(r+2,vector<vector<ll>> (c+2,vector<ll> (4,-1)));
        */
        ll k;
        cin>>n>>k;
        ll p[n],c[n];
        for(int i=0;i<n;i++)
        {
            cin>>p[i];
            p[i]--;
        }
        for(int i=0;i<n;i++)
        {
            cin>>c[i];
        }
        ll ans=INT32_MIN;
        
        for(int i=0;i<n;i++)
        {
            ll precnt=0;
            ll cf=0;
            int s = i;
            do
            {
                precnt++;
                cf += c[s];

                s = p[s];
            } while (s != i);

            int cnt = 1;
            ll sum = 0;
            s  = i;
            do
            {
                s = p[s];
                sum += c[s];

                ans  = max(ans,max((k-cnt)/precnt*cf,0LL) + sum);

                cnt++;    
            } while (cnt<=min(k,precnt));
            
            
        }

        cout<<ans<<endl;
    }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;

	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n, m, x, y, x1[1000], y1[1000], i, a, b;
    
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for(i=0;i<n;i++) scanf("%d",&x1[i]);
    for(i=0;i<m;i++) scanf("%d",&y1[i]);
    
    a=x1[0];
    for(i=1;i<n;i++){
        if(a<x1[i]) a=x1[i];
    }
    b=y1[0];
    for(i=1;i<m;i++){
        if(b>y1[i]) b=y1[i];
    }
    if((b>x)&&(a<y)&&((b-a)>0)){
        printf("No War\n");
        return 0;
    }
    printf("War\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> m[100001];
	for(int i = 0; i < M; i++){
		int a,b;
		cin >> a >> b;
		m[a].push_back(b);
	}
	for(int i = 1; i <= N; i++){
		sort(m[i].begin(), m[i].end());
	}
	
	int ans = 0;
	int leftCount = 0;
	int right = N+1;
	for(int i = 1; i <= N-1; i++){
		if(m[i].size() > 0){
			leftCount++;
			right = min(right, m[i][0]);
		}
		if(leftCount > 0 && right == i+1){
			ans++;
			right = N+1;
			leftCount = 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5760
fn main() {
    proconio::input! {
        n: usize,
        mut ls: [usize; n],
    }
    ls.sort();
    let mut count = 0usize;
    for (i, l) in ls.iter().enumerate().skip(2) {
        for j in 1..i {
            for k in 0..j {
                if ls[j] + ls[k] > *l && ls[j] != ls[k] && ls[j] != *l && ls[k] != *l {
                    count += 1;
                }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2192
#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() {
  ll n,d;
  cin >> n >> d;
  int res=0;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    if (x*x+y*y<=d*d) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main(){
	double num;
	while(scanf("%lf",&num),num!=-1.0){
		num *= 16;
		int integer = (int)num;
		if(num != integer)puts("NA");
		else{
			char ans[32]={0};
			int cnt = 0;
			while(cnt < 13){
				ans[cnt] = (integer%2)+48;
				integer /= 2;
				if(cnt == 3){
					ans[++cnt] = '.';
				}
				++cnt;
			}
			reverse(ans,ans+13);
			rep(i,13)printf("%c",ans[i]);
			puts("");
		}
	}
    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

typedef long long lint;

lint gcd(lint a, lint b) { return b != 0 ? gcd(b, a % b) : a; }

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	
	while (cin >> n, n) {
		vector< lint > d(n), v(n);
		
		cin >> d[0] >> v[0];
		
		lint dd = d[0], vv = v[0];
		
		for_(i,1,n) {
			cin >> d[i] >> v[i];
			lint _lcm_ = lcm(d[i] * vv, v[i] * dd);
			dd = _lcm_ / v[i];
		}
		
		for_(i,0,n) cout << dd * v[i] / (vv * d[i]) << endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,a0) memset(a,a0,sizeof(a))
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<ll,ll> pii;
int mod=(0?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
int a,b,v,w,t;
signed main(){
	cin>>a>>v>>b>>w>>t;
	int dis=abs(a-b);
	if(v<=w)cout<<"NO"<<endl;
	else cout<<(dis<=t*(v-w)?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 - (y2 - y1); //4点を通り、x, ys軸に平行な四角形を考える
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    for (int i = 0;; i++) {
        if (i * i > n) {
            int j = i - 1;
            cout << j * j << endl;
            break;
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	int a, b, n;
	cin >> a >> b >> n;
	int ans = 0;
	if(n < b)
		ans = max(ans, (a*n)/b - a*(n/b));
	else
		ans = max(ans, (a*(b-1))/b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict    as M
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BS.lines <$> BS.getContents
  print $ solve n as

solve :: Int -> [Int] -> Int
solve _ as = length . filter odd . M.elems $ M.fromListWith (+) [(a, 1) | a <- as]

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 17660
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int a,b;
  a = atoi(s.substr(0,2).c_str());
  b = atoi(s.substr(2,2).c_str());
  if(1 <= b && b <= 12){
    if(1 <= a && a <= 12){
      printf("AMBIGUOUS\n");
      return 0;
    }else{
      printf("YYMM\n");
      return 0;
    }
  }else{
    if(1 <= a && a <= 12){
      printf("MMYY\n");
      return 0;
    }else{
      printf("NA\n");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int D;
cin >> D;
vi c(26);
rep(i,26) cin >> c[i];
vvi s(D,vi(26));
rep(d,D) rep(i,26) cin >> s[d][i];

int cur = 0;
vi last(26);
rep(d,D) {
    int res = -INF;
    int p = 0;
    rep(i,26) {
        int up = s[d][i];
        int old = last[i];
        last[i] = d;
        int down = 0;
        rep(j,26) {
            down += c[i] * (d-last[i]);
        }
        last[i] = old;
        if(chmax(res,up-down)) p = i;
    }
    last[p] = d;
    cout << p+1 << endl;
}

return 0;
}

Measured memory_bytes: 3692
def examA():
    L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = I()

    ans = L[K-1]
    print(ans)
    return

def examB():
    H, W = LI()
    if H==1 or W==1:
        print(1)
        return
    ans = H*W//2 + (H*W)%2
    print(ans)
    return

def examC():
    a,b,c = LI()
    if c-(a+b)<=0:
        print("No")
        return
    judge = (c-a-b)**2-4*a*b
    if judge>0:
        print("Yes")
    else:
        print("No")
    return

def examD():
    def bfs(N):
        W = [0]*(5*10**6)
        L = [""]*(5*10**6)
        que = deque()
        que.append(0)
        L[0] = "a"
        W[0] = 0
        flag = True
        ne = 0
        while(flag):
            now = que.popleft()
            nowW = W[now]
            if len(L[now])==N:
                flag = False
                break
            for i in range(W[now]+2):
                ne += 1
                W[ne] = max(nowW,i)
                que.append(ne)
                L[ne] = L[now] + alphabet[i]
        return L
    N = I()
    D = bfs(N)
    for ans in D:
        if not ans:
            break
        if len(ans)<N:
            continue
        print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examD()

"""

"""

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> h(H);
  vector<string> w(W);
  
  for(int i=0; i<W; i++){
    w.push_back("#");
  }
  w.push_back("##");
  
  string sum;
  for(int i=0; i<w.size(); i++){
    sum += w.at(i);
  }
  cout << sum << endl;
  
  for(int i=0; i<H; i++){
    cin >> h.at(i);
  }
  
  string sum1;
  for(int i=0; i<H; i++){
    sum1 += h.at(i);
    
    if(sum1.size() == W){
      cout << "#" << sum1 << "#" << endl;
      sum1 = "";
    }
    
  }
  cout << sum << endl;
}


Measured memory_bytes: 3676
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let R = get!(i64);
    let G = get!(i64);

    let ans = 2 * G - R;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

/////////////         modの計算

int mod = 1000000007;

ll mod_adjust(ll a) {//	余りをとる(0～mod-1に調整する)
	if (a > mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_add(int a, int b) {//	足し算
	ll k = mod_adjust((ll)a); k += mod_adjust((ll)b);
	k = mod_adjust(k);
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	return mod_add(a, -b);
}

int main() {
	int N, K; cin >> N >> K;
	mod = K;
	ll* a = new ll[N];
	map<ll, set<ll>> mp;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i] = (a[i] - 1) % K;
	}
	
	for (int i = 1; i < N; i++) {
		a[i] = (a[i - 1] + a[i]) % K;
	}

	set<ll> s; s.insert(-1);
	mp.insert(make_pair(0, s));
	for (int i = 0; i < N; i++) {
		auto itr = mp.find(a[i]);
		if (itr == mp.end()) {
			set<ll> t; t.insert(i);
			mp.insert(make_pair(a[i], t));
		}
		else {
			itr->second.insert(i);
		}
	}
	ll ans = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		set<ll> x = itr->second;
		auto itr1 = x.begin();
		auto itr2 = x.begin();
		itr2++;
		ll c = 1;
		while (itr2 != x.end()) {
			while (*itr2 - *itr1 >= K) { itr1++; c--; }
			ans += c;
			itr2++; c++;
		}
	}

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

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

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

    for (ll a = -1000; a < 1000; a++) {
        for (ll b = -1000; b < 1000; b++) {
            if (pow(a, 5) - pow(b, 5) == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 4080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();

		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}

		int ans = 0;

		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < m; j++) {
				sum += b[j] * sc.nextInt();
			}
			sum += c;
			if (sum > 0) {
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
   int n,x,t;
   cin>>n>>x>>t;

   cout<<((n+x-1)/x)*t<<endl; 
}


Measured memory_bytes: 3628
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)
from pprint import pprint


def solve(N: int, A: "List[int]"):
    memo = [{} for _ in range(N + 1)]
    def rec(idx, rest, can_use=True):
        k = (rest, can_use)
        if rest * 2 >= N - idx + 2:
            return 0
        if rest == 0:
            return 0
        if k in memo[idx]:
            return memo[idx][k]

        ret = 0
        if not can_use:
            ret = rec(idx + 1, rest)
        elif rest * 2 > (N - idx):
            ret = A[idx] + rec(idx + 1, rest - 1, False)
        else:
            a = A[idx] + rec(idx + 1, rest - 1, False)
            b = rec(idx + 1, rest)
            ret = max(a, b)
        memo[idx][k] = ret
        return ret
    ret = rec(0, N // 2)
    print(ret)
    return

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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 361624
#!/usr/bin/env python3
input()
(*a, ) = map(int, input().split())
d = (-1, 0, 1)
ans = [0] * (10**5 + 1)
for i in a:
    for j in d:
        if 0 <= i + j <= 10**5:
            ans[i + j] += 1
print(max(ans))


Measured memory_bytes: 87444
L = [list(map(int,input().split())) for i in range(3)]

a = []

ans = "YES"
for i in range(3):
    a.append(L[i][0])
    a.append(L[i][1])

for i in range(1,5):
    if a.count(i) >= 3:
        ans = "NO"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

const int MAX = 1100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    COMinit();
    ll N,K;cin>>N>>K;
    vector<ll> info(N);
    rep(i,N)cin>>info[i];
    sort(info.begin(),info.end());
    ll ans=0;
    rep(i,N){
        ll s=COM(N-i-1,K-1),t=COM(i,K-1);
        ans+=(t-s)%MOD*(info[i]%MOD);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


int main()
{
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int ans = 0;

    rep(i,N)
    {
        if( A[i] == B[i] && A[i] == C[i] )continue;
        else if( A[i] != B[i] && B[i] != C[i] && A[i] != C[i] ) ans += 2;
        else ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str,ptr;


 cin>>n;
 
 n--;

      ans=n*(n+1);
      
      ans/=2;
      
      cout<<ans<<endl;






}



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

int main() {
	string s, t, res = "UNRESTORABLE";
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for (int i = n - m; i >= 0; i--) {
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (s[i + j] == t[j] || s[i + j] == '?')
				continue;
			ok = false;
			break;
		}
		if (ok) {
			for (int j = 0; j < m; j++) {
				s[i + j] = t[j];
			}
			for (int j = 0; j < n; j++) {
				if (s[j] == '?')
					s[j] = 'a';
			}
			res = s;
			break;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {

  int n;

  long long int sum;


  cin >> n;

  sum=0;

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

    long long int val;

    cin >> val;

    sum+=val;

  }

  cout << sum/n << endl;

  return 0;

}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

int dp[100005];
int v[100005], n;
bool mark[100005];

int f(int i) {
	if(i == n-1) return 0;
	if(i >= n) return 1e9;
	if(mark[i]) return dp[i];
	mark[i] = true;
	return dp[i] = min(f(i+1) + abs(v[i+1] - v[i]), f(i+2) + abs(v[i+2] - v[i]));
}

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

	for(int i = 0; i < n; i++)
		scanf("%d", &v[i]);
	printf("%d\n", f(0));
    
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define lld long long
int ispal(string s){
	int n=s.length();
	int st=0;
	int en=n-1;
	while(st<en){
		if(s[st]!=s[en])return 0;
		st++,en--;
	}
	return 1;
}
int main()
{
   string s; cin>>s;
   int n=s.length();
   int k=(n-1)/2;
   string bb=s.substr(0,k);
   string tt=s.substr(k+1);
   if(ispal(s)&&ispal(bb)&&ispal(tt))cout<<"Yes";
   else cout<<"No";
}

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

int collatz(int a){
    if(a%2==0){
        return a/2;
    }
    else{
        return 3*a+1;
    }
}

int main() {
    int s;
    cin>>s;
    map<int, int> amap;
    int ans;
    amap[s]++;
    for(int i=0;i<=1000000;++i){
        s = collatz(s);
        if(amap[s]>0){
            ans = i+2;
            break;
        }
        amap[s]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//2018.09.16 20min 5WA

#include <iostream>
using namespace std;

int main() {

    char x,y;
    cin >> x >> y;

    if(x<y) cout << '<' << endl;
    else if(x>y) cout << '>' << endl;
    else cout << '=' << endl;

    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll w,h,n;
  cin>>w>>h>>n;
  vector<ll> x(n),y(n),a(n);
  rep(i,n) cin>>x[i]>>y[i]>>a[i];
  ll h_max=h,h_min=0,w_max=w,w_min=0;
  rep(i,n){
    if(a[i]==1) w_min=max(w_min,x[i]);
    if(a[i]==2) w_max=min(w_max,x[i]);
    if(a[i]==3) h_min=max(h_min,y[i]);
    if(a[i]==4) h_max=min(h_max,y[i]);
  }
  cout<<max(w_max-w_min,(ll)0)*max(h_max-h_min,(ll)0)<<endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
using namespace std;

ll dp[1001][1001];

ll solve(ll n, ll k, ll m) {
  dp[0][0] = 1;
  for(int i=0;i<=n;++i) {
    for(int j=1;j<=k;++j) {
      if (i<j) {
        dp[i][j] = dp[i][j-1];
      }
      else {
        dp[i][j] = (dp[i][j-1] + dp[i-j][j]) % m;
      }
    }
  }
  return dp[n][k];
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<((n<k)?0:solve(n-k,k,mod))<<endl;
  return 0;
}


Measured memory_bytes: 7464
#include <iostream>
#define ll unsigned long long
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    ll n,k;

    cin>>n>>k;

    if(n%k == 0)
    {
        cout<<0<<endl;
        return 0;
    }

    n = n %k ;

   ll a = n-k;
   ll b = k-n;

    if(a<0)
    a*=-1;

    if(b<0)
    b*=-1;
    cout<<min(a,min(n,b))<<endl;

    return 0;




}


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


void solve(long long N, long long K, std::vector<long long> D){
    while(1) {
        bool isFind = false;
        for (auto i=D.begin(); i!=D.end(); i++) {
            string N_str = to_string(N);
            string i_str = to_string(*i);
            if (N_str.find(i_str.c_str()) != string::npos) {
                isFind = true;
                break;
            }
        }
        if (isFind == false) {
            cout << to_string(N) << endl;
            break;
        }
        N++;
    }
}

// Generated by 1.1.7.1 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(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 3756
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Map;
import java.util.LinkedList;

import static java.lang.StrictMath.min;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int w=sc.nextInt();
        int[] a=new int[n+1];
        int[] v=new int[n+1];
        int sum=0;
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
            v[i]=sc.nextInt();
            sum=sum+v[i];
        }
        long[] dp=new long[sum+1];
        Arrays.fill(dp,(long)1e18);
        dp[0]=0;

        for(int i=1;i<=n;i++){
            for(int j=sum;j>=v[i];j--){
                dp[j]=Math.min(dp[j],dp[j-v[i]]+a[i]);
            }
        }

        int ans=0;
        for (int i=0;i<=sum;i++){
            if (dp[i]<=w)ans=Math.max(i,ans);
        }
        System.out.println(ans);
    }
}



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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll d,t,s;
	cin>>d>>t>>s;
	ll ans = (d+s-1)/s;
	cout<<(ans<=t ? "Yes\n":"No\n");
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s;
    cin>>s;
    ll n=s.length();
    rep (i,0,n)
    {
        cout<<"x";
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  public struct arch{
  }
 
  public static void Main (string[] args) {
    var N = long.Parse(Console.ReadLine());
    var list = Console.ReadLine().Split(' ').Select(long.Parse);
    var ans = new List<long>();

    for(var i = list.Min(); i <= list.Max(); i++){
      ans.Add(list.Select(e => (e - i) * (e - i)).Sum());
    }

    Console.WriteLine(ans.Min());
 
  }
  
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n;
    cin >> n;
    cout << ((n % 10 == 9 || n / 10 == 9) ? "Yes" : "No") << endl;
}


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

int main() {
    string W;
    cin >> W;
    map<char, int> words;

    for(auto WI : W) {
        words[WI]++;
    }

    bool btf = true;
    for(auto WI : W) {
        if(words[WI] % 2 == 1) {
            btf = false;
            break;
        }
    }

    if(btf) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace  std;

llint n;
llint a[405], b[405];
bool haveA[405][405], haveB[405][405];
llint sum[405][405];
llint dp[405][405][405], dpsum[405][405];

const int FACT_MAX = 2005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint get(llint sum[405][405], llint sx, llint sy, llint tx, llint ty)
{
  if(sx > tx || sy > ty) return 0;
  llint ret = sum[tx][ty]  + sum[sx-1][sy-1];
  ret += mod - (sum[sx-1][ty] + sum[tx][sy-1])%mod, ret %= mod;
  return ret;
}

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

  make_fact();

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) cin >> b[i];

  reverse(a+1, a+n+1);
  reverse(b+1, b+n+1);

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
      if(a[i] == b[j]) sum[i][j]++;
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = i; j <= n; j++) haveA[j][a[i]] = true;
    for(int j = i; j <= n; j++) haveB[j][b[i]] = true;
  }

  for(int j = 1; j <= n; j++){
    for(int k = 1; k <= n; k++){
      if(!haveA[j-1][b[k]] || !haveB[k-1][a[j]]) continue;
      llint num = get(sum, 1, 1, j-1, k-1);
      if(num <= 0) continue;
      dp[1][j][k] = num * 2 % mod;
    }
  }

  for(int i = 2; i <= n/3; i++){
    for(int j = 1; j <= n; j++){
      for(int k = 1; k <= n; k++){
        dpsum[j][k] = dpsum[j-1][k] + dpsum[j][k-1] + dp[i-1][j][k], dpsum[j][k] %= mod;
        dpsum[j][k] += mod - dpsum[j-1][k-1], dpsum[j][k] %= mod;
      }
    }

    for(int j = 1; j <= n; j++){
      for(int k = 1; k <= n; k++){
        if(!haveA[j-1][b[k]] || !haveB[k-1][a[j]]) continue;
        llint num = get(sum, 1, 1, j-1, k-1);
        if(num-2*(i-1) <= 0) continue;
        llint tmp = get(dpsum, 1, 1, j-1, k-1);
        tmp *= num-3*(i-1), tmp %= mod;
        tmp *= comb(3*(i-1)+2, 2) * 2 % mod, tmp %= mod;
        dp[i][j][k] = tmp;
      }
    }

  }
  cout << dp[n/3][n][n] << endl;

  return 0;
}


Measured memory_bytes: 175232
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
	int a,b;
	cin >> a >> b;
	if (a <= b){
		cout << a << "\n";
	}else
		cout << a - 1 << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if(S=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(S=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }


}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    s = input()
    r = s.count("R")
    g = s.count("G")
    b = s.count("B")
    ans = r * g * b
    for diff in range(1, 1 + (n - 1) // 2):
        for first in range(n - diff * 2):
            i = s[first]
            j = s[first + diff]
            k = s[first + diff * 2]
            if i != j and j != k and k != i:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9196
import java.util.*;

public class Main
{

    private final static int MOD = 1_000_000_007;

    public static int gcd(int a, int b) { 
        // Everything divides 0  
        if (a == 0) 
          return b; 
        if (b == 0) 
          return a; 
       
        // base case 
        if (a == b) 
            return a; 
       
        // a is greater 
        if (a > b) 
            return gcd(a-b, b); 
        return gcd(a, b-a); 
    }
    
    public static long mod(long a, long b) {
        return ((a % b) + b ) % b;
    }

    public static int mod (int a, int b) {
        return ((a % b) + b ) % b;
    }
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
	int N = in.nextInt();
	int M = in.nextInt();
	int K = in.nextInt();
	in.nextLine();
	long[] A = new long[N], B = new long[M];
	for (int i = 0; i < N; i++) {
	    A[i] = in.nextLong();
	    if (i > 0) A[i] += A[i-1];
	}
	in.nextLine();
	for (int i = 0; i < M; i++) {
	    B[i] = in.nextLong();
	    if (i > 0) B[i] += B[i-1];
	}
	int res = 0;
	for (int i = 0, j = M-1; i < N; i++) {
	    if (A[i] > K) break;
	    while (j > -1 && A[i] + B[j] > K) j--;
	    res = Math.max(res, i+j+2);
	}
	for (int i = M-1; i > -1; i--) {
	    if (B[i] <= K) {
		res = Math.max(res, i+1);
		break;
	    }
	}
	System.out.println(res);
        in.close();
    }


			       
}


Measured memory_bytes: 63868
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    int r=II();
    if(r<1200) cout << "ABC\n";
    else if(r<2800) cout << "ARC\n";
    else cout << "AGC\n";
	
	return 0;
}



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

#define REP(i, N) for(int i = 0; i < N; ++i)
#define FOR(i, M, N) for(int i = M; i < N; ++i)

using namespace std;

int main() {
	string trip;
	cin >> trip;
	bool N = false, W = false, S = false, E = false;
	if (count(trip.begin(), trip.end(), 'N') > 0)N = true;
	if (count(trip.begin(), trip.end(), 'S') > 0)S = true;
	if (count(trip.begin(), trip.end(), 'W') > 0)W = true;
	if (count(trip.begin(), trip.end(), 'E') > 0)E = true;
	if (!N && S)cout << "No" << endl;
	else if (N && !S) cout << "No" << endl;
	else if (!W && E) cout << "No" << endl;
	else if (W && !E) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256