akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int MAX_N = 200005;
int Nn;
ll cntN = 0,cntZ = 0,cntP = 0;
vector<ll> N,P;
ll A[MAX_N];

ll f(ll x)
{
	ll res = 0,y;
	if (x == 0)
	{
		return cntN * cntP;
	}
	else if (x < 0)
	{
		rep(i,cntN)
		{
			y = x / N[i];
			res += P.end() - upper_bound(P.begin(),P.end(),y);
		}
		return res;
	}
	else
	{
		res += cntN * cntP + (cntN+cntP)*cntZ + (cntZ*(cntZ-1))/2;
		ll temp = 0, cnt = 0;
		rep(i,cntP)
		{
			y = (x + P[i] - 1) / P[i];
			if (P[i] < y) cnt++;
			temp += lower_bound(P.begin(),P.end(),y) - P.begin();
		}
		temp = (temp - cnt) / 2;
		res += temp;
		temp = 0,cnt = 0;
		rep(i,cntN)
		{
			y = (x - N[i] - 1) / N[i];
			if (N[i] > y) cnt++;
			temp += N.end() - upper_bound(N.begin(), N.end(),y);
		}
		temp = (temp - cnt) / 2;
		res += temp;
		return res;
	}
}

ll f2(ll x)
{
	ll res = 0;
	rep(i,Nn)
	{
		if (A[i] < 0)
		{
			int l = -1, r = Nn;
			while(l+1 < r)
			{
				int c = (l+r)/2;
				if (A[i] * A[c] < x) r = c; else l = c;
			}
			res += Nn-r;
		}
		else
		{
			int l = -1, r = Nn;
			while(l+1 < r)
			{
				int c = (l+r)/2;
				if (A[i] * A[c] < x) l = c; else r = c;
			}
			res += l+1;
		}
		if (A[i] * A[i] < x) res--;
	}
	res /= 2;
	return res;
}

int main()
{
	ll K;
	cin >> Nn >> K;
	rep(i,Nn)
	{
		cin >> A[i];
		if (A[i] > 0)
		{
			 cntP++;
			 P.push_back(A[i]);
		}
		else if (A[i] < 0)
		{
			 cntN++;
			 N.push_back(A[i]);
		}
		else
		{
			 cntZ++;
		}
	}

	sort(A,A+Nn);
	sort(P.begin(),P.end());
	sort(N.begin(),N.end());
	ll l = -ll(1e18) - 1, r = ll(1e18) + 1, m;
	while(l+1 < r)
	{
		m = (l+r)/2;
		//cout << m << " " << f2(m) << endl;
		if (f2(m) < K) l = m;
		else r = m;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n,m,p;
  while(cin>>n>>m>>p) {
    if(n == 0) return 0;
    int x[n];
    double sum = 0;
    FOR(i,0,n) {
      cin >> x[i];
      sum += x[i];
    }
    sum *= 100;
    sum = sum * (100 - p) / 100;
    if(x[m-1] == 0) sum = 0; 
    else sum /= x[m-1];
    cout << int(sum) << endl;
  }
  return 0;
}

Measured memory_bytes: 3016
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
//#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm(x,mod - 2)

const int MAXN = 1;
const int INF = 2e9;
const int G = 3;
const double PI = acos(-1);
//const int mod = 1e9 + 7;
//const int mod = 998244353;

int n;
char s[10];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> s + 1;
	if(s[2] == 'B') cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);


int main(){
	ll n;
	cin>>n;
	ll count[n+1];
	fo(i,n+1) count[i]=0;
	ll a[n+1][n];
	ll tmp;
	fo(i,n){
		fo(j,n-1){
			cin>>tmp;
			a[i+1][j]=tmp;
		}

	}
	unordered_map<ll,ll> mp;
	ll days=0;
	ll happen=false;
	ll node,check;
	bool there[n+1];
	fo(i,n+1) there[i]=false;
	while(true){
		happen=false;
		fo(j,n+1) there[j]=false;
		FOR(i,1,n){
			if(there[i]) continue;
			if(count[i]==n-1) continue;
			node=a[i][count[i]];
			//dbg2(i,node);
			if(a[node][count[node]]==i&&(!there[i])&&(!there[node])){
				count[node]++;
				count[i]++;
				happen=true;
				there[i]=true;
				there[node]=true;
			}

		}
		if(happen){
				days++;
			} 
		else break;


	}

    bool can=true;
	FOR(i,1,n){
		if(count[i]==n-1) ;
		else can=false;

	}
	if(can) cout<<days<<endl;
	else cout<<-1<<endl;


}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <functional>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define INT_MAX 2147483647
#define ll long long

#define MOD 1000000007

ll max(ll a, ll b) { return (a < b) ? b : a; }


// DP !!
int main() {
    int n;
    cin >> n;

    vector<double> p(n+1);

    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    cout << fixed << setprecision(10);
    vector<vector<double>> dp(n + 1);
    for (int i = 0; i <= n; i++) {
        dp[i].resize(n + 1);
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i])   + dp[i - 1][j - 1] * p[i];
        }
    }

    int j = n / 2 + 1;

    double res = 0;
    for (int i = j; i <= n; i++) {
        res += dp[n][i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<pair<int, int>> odd(1e5), even(1e5);
    REP(i, 1e5){
        odd[i].first = 0;
        even[i].first = 0;
        odd[i].second = i + 1;
        even[i].second = i + 1;
    }

    REP(i, n){
        int inp; cin >> inp;
        if((i + 1) % 2 != 0) odd[inp].first++;
        else even[inp].first++;
    }
    whole(sort, odd, greater<>());
    whole(sort, even, greater<>());
    int sum = 0;
    if(odd[0].second == even[0].second){
        if(odd[0].first > even[0].first) sum = odd[0].first + even[1].first;
        else if(odd[0].first < even[0].first) sum = odd[1].first + even[0].first;
        else if(odd[0].first == even[0].first){
            if(odd[1].first > even[1].first) sum = odd[1].first + even[0].first;
            else sum = odd[0].first + even[1].first;
        }
    }
    else sum = odd[0].first + even[0].first;

    cout << n - sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n;
    cin>>n;
    n=1000-n%1000;
    if (n==1000)
    {
    	n=0;
	}
	cout<<n<<endl;
}

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

ll N, A[25], B[25], S[25];

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

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (ll i = 0; i < N; i++) {
		cin >> B[i];
		S[i] = A[i] - B[i];
	}
	sort(S, S+N);
	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		if (S[i] > 0) ans += S[i];
	}
	cout << ans << "\n";

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

// Pという変数型を定義
typedef struct pp
{
    char name[100];
    int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a,int b){
    // ?条件演算子　if 分を簡単に書いている
    return a<b ? a:b;
}

int main(){
    int elaps =0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);

    for( i=1 ; i<=n; i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;

    while(head !=tail){
        u=dequeue();
        c=min(q,u.t); // q or u.t時間だけ処理を行う
        u.t-=c; //残り時間
        elaps+=c; //経過時間
        if(u.t >0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}





Measured memory_bytes: 12844
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
    int A,B,K;
    cin >> A>>B>>K;

    int count = 0, ans;
    for (int i = 100; count!=K; i--) {
        if (A%i==0&&B%i==0) {
            count++;
            ans = i;
        }
    }

    cout << ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct SegmentTree {
// private:
//     int n;
//     vector<ll> node;

public:
    ll n;
    vector<ll> node;
    SegmentTree(vector<ll> v) {
        ll sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, ll(0));
        for(ll i=0; i<sz; i++) node[i+n-1] = v[i];
        for(ll i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    void update(ll x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    ll getmax(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


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

    // vector<ll> dp(N+1);
    SegmentTree dp( vector<ll>(N+1, ll(0)));
    dp.update(h[0], a[0]);
    for(ll i=1; i<N; i++) {
        ll tmp_max = dp.getmax(1, h[i]);
        dp.update(h[i], tmp_max + a[i]);
    }

    cerr << "debug" << endl;
    for(auto x: dp.node) cerr << x << " "; cerr << endl;

    ll ans = dp.getmax(1, N+1);
    cout << ans << endl;

    return 0;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string S;
cin>>S;
rep(i,S.length()-1){
    if(S[i]==S[i+1]){
        cout<<"Bad"<<endl;
        return 0;
    }
}
cout<<"Good"<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int x[5];
    for(int i=0;i<5;i++){
        cin >> x[i];
        if(x[i]==0){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0;
  int res = x;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'I') {
      ++x;
      res = max(res, x);
    } else if (S[i] == 'D') {
      --x;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
    	Scanner sn = new Scanner(System.in);
      int n = sn.nextInt();
      int data[] = new int[n];
      for(int i = 0; i < n; i++) {
      	 data[i] = sn.nextInt();
      }
      int a = 0;
      int b = 0;
      int c = 0;
      int res = 0;
      for(int i = 0; i < n ; i++) {
        a = data[i];
        for(int j = i + 1; j < n; j++) {
          b = data[j];
          for(int k = j + 1; k < n; k++) {
           c = data[k];
          	if( (a + b > c)  && (b  + c > a)  && (a + c > b) && (a !=b) && (a!=c)&& (b!=c)) {
       			res++; 	
        	}
          }
        }
      }
      System.out.println(res);
    }
}

Measured memory_bytes: 36556
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    n = len(s)
    a = [0]
    now = 0
    for si in s:
        if si == '<':
            now += 1
        else:
            now = 0
        a.append(now)
    b = [0]
    now = 0
    for si in s[::-1]:
        if si == '>':
            now += 1
        else:
            now = 0
        b.append(now)
    b = b[::-1]
    ans = sum([max(a[i], b[i]) for i in range(n+1)])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32704
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
long long mod = 1e9 + 7;
long long d[103][103];

void warshall_floyd(int n) { // nは頂点数
	for (int i = 0; i < n; i++)      // 経由する頂点
		for (int j = 0; j < n; j++)    // 開始頂点
			for (int k = 0; k < n; k++)  // 終端
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
typedef pair<long long, long long>p;
typedef pair<p, long long> pai;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int a, b, c;
	vector<pai> edge;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = INT_MAX/3;
		}
	}
	for (int i = 0; i < n; i++) {
		d[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
		edge.push_back(pai(p(a - 1, b - 1),c));
	}
	warshall_floyd(n);
	int ans = 0;
	for (int z = 0; z < edge.size(); z++) {
		int u = edge[z].first.first;
		int v = edge[z].first.second;
		int c = edge[z].second;
		int judge = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (d[i][j] == d[i][u] + d[v][j] + c || d[i][j] == d[i][v] + c + d[u][j]) { judge = 0; break; }
			}
		}
		ans += judge;
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
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; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)
const long long INF = 1LL << 60;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b-1)/b*c;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<long long> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    for (auto x : abc)
    {
        if (x % 2 == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << abc[0] * abc[1] << endl;
}

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

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    char c = S[0];
    int x = 0, j = 0, ans = 0;
    for (int i = 1; i < N; i++) {
        if (c != S[i]) {
            x++;
            c = S[i];
            ans += j;
            j = 0;
        } else {
            j++;
        }
    }
    ans += j;
    for (int i = 0; i < K; i++) {
        if (x >= 2) {
            x -= 2;
            ans += 2;
        } else if (x == 1) {
            x -= 1;
            ans += 1;
        } else {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int t_value = A;
		int a_value = C;
		while(true) {
			a_value -= B;
			if(a_value <= 0) {
				System.out.println("Yes");
				break;
			}
			t_value -= D;
			if(t_value <= 0) {
				System.out.println("No");
				break;
			}
		}

	}
}


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

int main(){
    ll N, D, X;
    cin >> N >> D >> X;
    ll ans = X;
    rep(i, 0, N){
        ll a;
        cin >> a;
        ll day = (D - 1) / a;
        ans += day + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll exp(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }
    return a * exp(a, b - 1);
}

int main()
{
    int N, K;
    cin >> N >> K;
    if (K == 1)
    {
        cout << exp(N, 3) << endl;
    }
    else if (K % 2 == 0)
    {
        int num = 0;
        rep(1, i, N + 1)
        {
            if (i % K == K / 2)
            {
                num++;
            }
        }
        cout << exp(N / K, 3) + exp(num, 3) << endl;
    }
    else
    {
        cout << exp(N / K, 3) << endl;
    }
}


Measured memory_bytes: 256
import collections

N = int(raw_input().replace("\n", ""))

a_list = map(int, raw_input().replace("\n", "").split(" "))
even_list = a_list[::2]
odd_list = a_list[1::2]

len_vec = N / 2

even_c = collections.Counter(even_list)
odd_c = collections.Counter(odd_list)

even_c_most_common = even_c.most_common()
odd_c_most_common = odd_c.most_common()

even_first_value, even_first_count = even_c_most_common[0]
odd_first_value, odd_first_count  = odd_c_most_common[0]
#(even_first_value, even_first_count), (even_second_value, even_second_count) = even_c.most_common()[:2]
#(odd_first_value, odd_first_count), (odd_second_value, odd_second_count) = odd_c.most_common()[:2]

if even_first_value == odd_first_value and len(even_c) == 1 and len(odd_c) == 1:
    cost = len_vec
elif even_first_value != odd_first_value:
    cost =  (even_first_count + odd_first_count)
elif len(even_c) == 1 and len(odd_c) > 1:
    odd_second_value, odd_second_count = odd_c_most_common[1]
    cost = len_vec + odd_second_count
elif len(odd_c) == 1 and len(even_c) > 1:
    even_second_value, even_second_count = even_c_most_common[1]
    #cost = len_vec + odd_second_count
    cost = len_vec + even_second_count
else: # ryouhou no first ga onaji de hutatuijou arutoki
    odd_second_value, odd_second_count = odd_c_most_common[1]
    even_second_value, even_second_count = even_c_most_common[1]
    cost = max(even_first_count+odd_second_count, even_second_count+odd_first_count)

print(2* len_vec - cost)

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n,k;cin>>n>>k;
    int cnt=0;
    while(n){
        n /= k;
        ++cnt;
    }
    cout << cnt;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  int n, k, q; cin >> n >> k >> q;
  Vll a(n+2);
  rep(i, n) cin >> a[i+1];


  auto f = [&] (ll x) {
    if (x < 0) return false;

    int res = 0;
    rep2(i, 1, n+1) {
      ll &y = a[i];
      ll z = y + x;

      V idx;
      rep(j, n+2) if (a[j] < y) idx.push_back(j);

      int now = 0;
      rep(j, idx.size()-1) {
        int cnt = 0;
        rep2(l, idx[j]+1, idx[j+1]) if (a[l] <= z) ++cnt;
        now += min(cnt, max(idx[j+1] - idx[j] - k, 0));
      }
      chmax(res, now);
    }
    return (res >= q);
  };

  ll ok = ll(2e10) + 5;
  ll ng = -1;
  while (llabs(ok - ng) > 1) {
    ll md = (ok + ng) / 2;
    if (f(md)) ok = md;
    else ng = md;
  }

  ll ans = ok;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
N, X = map(int,input().split())
L = list(map(int,input().split()))
D = [0 for i in range(N+1)]
for i in range(N):
    D[i+1]=D[i]+L[i]
cnt = 0
for i in range(N+1):
    if D[i]<=X:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

m,n = getMN()
MOD = 1000000007
anums = getlist()
bnums = getlist()

anums.sort(reverse=True)
bnums.sort(reverse=True)
ans = 1
r_index = 0
d_index = 0
flag = True
for i in range(m*n):
    ans = ans % MOD
    num = m * n - i
    if r_index == m and d_index == n:
        ans *= num
        flag = False
    if flag:

        #print("num = {}, ans = {}".format(num,ans))
        #print("r = {}, d = {}, i = {}".format(r_index, d_index,i))
        in_r = num in anums
        in_d = num in bnums
        if in_r:
            if in_d:
                r_index += 1
                d_index += 1
            else:
                ans = ans * d_index
                r_index += 1
        else:
            if in_d:
                ans = ans * r_index
                d_index += 1
            else:
                if r_index * d_index < i:
                    import sys

                    ans = 0
                    flag = False
                else:
                    import sys
                    #print("koko", i, file=sys.stderr)
                    andayo = (ans * (r_index*d_index -i ))
                    #ans = ans * (r_index*d_index -i )
                    ans = andayo
                    #print("ans", ans)
ans = ans%MOD

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  string s; cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
  
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int k;
    cin >> k;
    int ans = 1;
    ll s = 7;
    while((s%k != 0) && (ans <= 10000000)){
        s *= 10;
        s += 7;
        s %= k;
        ans++;
    }

    if(ans == 10000001)puts("-1");
    else cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

uint tzcnt(uint x) {
    x = ~x & (x - 1);
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

bool IsPN[100000 + 1];
int NL2017Sum[100000 + 1];

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

    vector<int> PN = {};

    for (int i = 2; i <= 100000; ++i) {
        for (int j = 0; j < PN.size(); ++j) {
            if (i % PN[j] == 0) goto not_prime;
        }

        PN.push_back(i);
        IsPN[i] = true;

    not_prime:;
    }

    for (int i = 1; i <= 100000; i += 2) {
        NL2017Sum[i] = NL2017Sum[i + 1] = NL2017Sum[i - 1] + (IsPN[i] && IsPN[(i + 1) / 2] ? 1 : 0);
    }

    int Q;
    cin >> Q;

    vector<int> ans;
    ans.reserve(Q);

    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;

        ans.push_back(NL2017Sum[r] - NL2017Sum[l - 1]);
    }

    for (int a : ans) {
        out(a);
    }

    int aaa;
    cin >> aaa;
}

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

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

    bool dp[100001] = {0}; // 最適に行動した時に先手が勝つならtrue, 後手ならfalse
    for(int i = 0; i < a[0] ; i++) dp[i] = false;

    for(int i = a[0]; i <= K; i++){
        dp[i] = false;
        for(int j = 0; j < N; j++){
            if(i - a[j] >= 0 && dp[i - a[j]] == false){
                dp[i] = true;
                break;
            }
        }
    }
    if( dp[K] ) cout << "First\n";
    else cout << "Second\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

char itoc(const char i){
	return 'A' + i;
}

int main(){
	int N;
	cin >> N;
	cout << "AB" << itoc(N/1000+2) << endl;
}

Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    val c = (0 until 26).map { sc.next().toInt() }
    val s = (0 until d).map {
        (0 until 26).map { sc.next().toInt() }
    }
    println(problemintroduction_to_heuristics_contest(d, c, s))
}

fun problemintroduction_to_heuristics_contest(
    d: Int,
    c: List<Int>,
    s: List<List<Int>>
): String {
    val ans = IntArray(d) { 1 }
    return ans.joinToString("\n")
}

Measured memory_bytes: 47976
import sys
import bisect
import heapq

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline

def main():
    n,l = map(int,read().split())
    li = []
    for i in range(n):
        li.append(input())
    li.sort()
    for s in li:
        print(s,end="")
    print()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint x, n;
set<llint> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> n;
	llint p;
	for(int i = 1; i <= n; i++){
		cin >> p;
		S.insert(p);
	}
	
	llint ans = -200;
	for(int i = -200; i <= 300; i++){
		if(S.count(i)) continue;
		if(abs(i-x) < abs(ans-x)) ans = i;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 
    int n;
    cin>>n;

    vector<tuple<string ,int, int> > tuples(n);
    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin>>s>>p;
        tuples.at(i) = make_tuple(s, 100-p, i+1);
    }

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

    for (int i = 0; i < n; i++) {
        string s;
        int p;
        int num;
        tie(s,p,num)=tuples.at(i);
        cout<<num<<endl;
    }

    return 0; 
} 


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	ll a, b, va = 0, vb = 0;
	cin >> a >> b;
	if (a == b) {
		printf("%lld\n", a);
		return 0;
	}
	a--;
	if (a % 2 == 0)va = a ^ (a / 2 % 2);
	else va ^= ((a + 1) / 2 % 2);
	if (b % 2 == 0)vb = b ^ (b / 2 % 2);
	else vb ^= ((b + 1) / 2 % 2);
	printf("%lld\n", va^vb);
	if (a == 0) {
		printf("%lld\n", vb);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x,t;
	cin>>n>>x>>t;
	int k = ceil(n*1.0/x);
	cout<<k*t<<endl;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;   int n = s.length();
    
    for (int i = 0; i < n; i++) {
        if (i+1 < n && s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if (i+2 < n && s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3740
import math


X, K, D = map(int, input().split())


Y = abs(X) // D

Mm = abs(X) - Y*D
Mp = (Y+1)*D - abs(X)

if (Mm <= Mp):
    M0 = Mm
    M1 = Mp
    Z = Y
else:
    M0 = Mp
    M1 = Mm
    Z = Y + 1

if (K < Z):
    print(abs(X) - K*D)
else:
    if ((K - Z) % 2 == 0):
        print(M0)
    else:
        print(M1)

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



int main(){
    int q;  cin >> q;
    vector<int> a(q), b(q);
    int n=0;
    for(int i=0; i<q; i++){
        cin >> a.at(i) >> b.at(i);
        n = max(n, b.at(i));
    }
    vector<bool> isPrime(n+1);
    for(int i=0; i<=n; i++)  isPrime.at(i)=true;
    isPrime.at(1) = false;
    for(int i=2; i<=n; i++){
        if(!isPrime.at(i)) continue;

        for(int j=2*i; j<=n; j+=i)
            if(isPrime.at(j)) isPrime.at(j) = false; 
    }
    vector<ll> cnt(n+1);
    int bef=0;
    for(int i=3; i<=n; i++){
        if(!isPrime.at(i) || !isPrime.at((i+1)/2))   cnt.at(i) = cnt.at(i-1);
        else cnt.at(i) = cnt.at(i-1)+1;
    }
    for(int i=0; i<q; i++)
         cout << cnt.at(b.at(i)) - cnt.at(a.at(i)-1) << endl;
   
}


Measured memory_bytes: 2176
n, quantum = gets.chomp.split.map(&:to_i)
queue = []
n.times{
    name, sec = gets.chomp.split
    queue.push [name, sec.to_i]
}

time = 0
until queue.empty?
    process = queue.shift
    # p process
    if process[1] <= quantum
        # p "?¶???????"
        time += process[1]
        puts "#{process[0]} #{time}"
    else
        # p "?¶??????????"
        time += quantum
        queue.push [process[0], process[1] - quantum]
        # p "?????¨#{process[1] - quantum}"
    end
end

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    llong n;
    cin >> n;
    vector<llong> cap;
    rep(i, 5) {
        llong c;
        cin >> c;
        cap.push_back(c);
    }

    llong index = 0;
    llong minc = cap[0];
    rep(i, 5) {
        if (cap[i] < minc) {
            minc = cap[i];
            index = i;
        }
    }

    if (minc >= n) {
        cout << 5 << endl;
    } else {
        llong ans = ceil((double)n / minc) + index + (5 - 1 - index);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 2005
#define M 200005
#define seed 23333

using namespace std;
const int Mo=(int)1e9+7;
int i,j,m,n,p,K,f[N*2][N*2],ans,k;
void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}
int main()
{
		scanf("%d%d%d",&n,&m,&K);
		f[0][0]=1;
		for (i=1;;++i)
		{
			if (i*(K-1)>(n+m-1)) break;
			for (j=0;j<=(K-1)*(i-1)&&j<=n;++j)
				if (f[i-1][j])
				{
					for (k=1;k<K&&j+k<=n;++k)
					{
							int now=j+k;
							if (i*(K-1)-now<=m-1&&now%(K-1)==n%(K-1)&&(i*(K-1)-now)%(K-1)==(m-1)%(K-1)) 
							jia(ans,f[i-1][j]);
					}
					for (k=0;k<K&&j+k<=n;++k)
						jia(f[i][j+k],f[i-1][j]);
				}
		}
		printf("%d\n",ans);
}


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

int f(int x){
	return x * x;
}

int main()
{
	int d;
	while (cin >> d){
		int s = 0;
		for (int i = 1; i * d < 600; i++){
			s += f(d * i) * d;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        int t;
        cin >> t;
        v[t-1] = i + 1;
    }
    for (int i = 0; i < n; i++)
        cout << v[i] << ' ';
    return 0;
}  


Measured memory_bytes: 1280
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N+1);
    REP(i,N){
        int a,b;
        cin >> a >> b;
        A[i]=a;
        A[i+1]=b;
    }

    int ans=0;
    vector<vector<int>> dp(N,vector<int>(N,inf));
    REP(i,N) dp[i][i]=0;

    for(int i=1;i<N;i++){
        for(int left=0;left<N-i;left++){
            int right = left+i;
            for(int k=0;k<i;k++){
                int mid = left+k;
                chmin(dp[left][right], dp[left][mid] + A[left]*A[mid+1]*A[right+1] + dp[mid+1][right] );
            }
        }
    }
    ans = dp[0][N-1];
    cout << ans << endl;
}


Measured memory_bytes: 3208
H,W = map(int,input().split())

ans = 1e19
##縦方向の探索
for i in range(1,H):
    tate = W*i##上から横に切る
    ##横に切る
    if i < H-1:
        mini = W*((H-i)//2)##分割したやつ
        ##print(tate,mini,H*W-mini-tate)
        ans = min(ans,max(tate,mini,H*W-mini-tate)-min(tate,mini,H*W-mini-tate))

    ##縦に切る
    mini = (H-i)*(W//2)
    ##print(tate,mini,H*W-mini-tate)
    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))

##横方向の探索
for i in range(1,W):
    yoko = H*i
    if i < W-1:
        mini = H*((W-i)//2)
        ##print(yoko,mini,H*W-mini-yoko)
        ans = min(ans,max(yoko,mini,H*W-mini-yoko)-min(yoko,mini,H*W-yoko-mini))
    mini = (W-i)*(H//2)
    ##print(yoko,mini,H*W-yoko-mini)
    ans = min(ans,max(yoko,mini,H*W-yoko-mini)-min(yoko,mini,H*W-yoko-mini))

print(ans)

Measured memory_bytes: 9164
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
//#define ForJ(n) for(int j=0;j<n;j++)
//#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

signed  main(){
    int a,b;
    cin>>a>>b;
    if(a>=13){
        Pr(b)
    }else if(6<=a&&a<=12){
        Pr(b/2)
    }else{
        Pr(0)
    }
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

void nie(){
  cout << "-1\n";
  exit(0);
}

const int MAX = 1e5+1;
int n;
vector<int> d[MAX],d2[MAX];
int cz[MAX],sx[MAX],sy[MAX];
bool dfs(int x){
  if(cz[x])return 0;
  cz[x] = 1;
  for(int el:d[x]){
    if(sy[el] == -1 || dfs(sy[el])){
      sy[el] = x;
      sx[x] = el;
      return 1;
    }
  }
  return 0;
}
PII out[MAX];
int ilout = 0;
void buduj(int x){
  for(int el:d2[x]){
    if(!cz[el]){
      cz[el] = 1;
      ilout ++;
      out[el] = {x, sx[el]};
      buduj(sx[el]);
    }
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n-1){
    int pom;
    cin >> pom;
    d[i].resize(pom);
    R(j,pom){
      cin >> d[i][j];
      d[i][j]--;
      d2[d[i][j]].PB(i);
    }
  }
  R(i,n){
    sx[i] = -1;
    sy[i] = -1;
  }
  int res = 0;
  bool x = 1;
  while(x){
    x = 0;
    R(i,n)cz[i] = 0;
    R(i,n)if(sx[i] == -1){
      if(dfs(i)){
        res ++;
        x = 1;
      }
    }
  }
  R(i,n-1){
    debug(sx[i]);
  }
  if(res != n-1)nie();
  R(i,n)cz[i] = 0;
  R(i,n){
    if(sy[i] == -1){
      buduj(i);
    }
  }
  if(ilout!=n-1)nie();
  R(i,n-1){
    cout << out[i].FI + 1 << " " << out[i].SE + 1 << "\n";
  }
}


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

string s;
int a['z' - 'a'];

int main() {
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		a[s[i] - 'a']++;
	}

	string ans = "yes";
	for (int i = 0; i < 'z' - 'a'; i++) {
		if (a[i] > 1) {
			ans = "no";
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256