akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    ll N,C,K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep (i,N){
        cin >> T[i];
    }
    sort(T.begin(),T.end());
    int ans=0,now=0;
    while (now<N){
        ll lim=T[now]+K;
        int lb=-1,ub=N;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if (T[mid]<=lim){
                lb=mid;
            }
            else {
                ub=mid;
            }
        }
        int x=lb-now+1;
        if (x<=C){
            ans++;
            now=ub;
        }
        else {
            ans++;
            now+=C;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define infl 1e18+5
#define mninfl -1e18-5
#define Mod 1000000007
#define newmod  998244353
int ah=911382323;
int bh=972663749;
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const long double pi=acos(-1);
//looping
#define int long long
#define For(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' ';  cout<<endl
#define pv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";  cout<<endl
#define pm(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}cout<<endl
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}
#define deb(x) cerr << #x << " = " << x << endl;
#define deb2(x,y)  cerr << #x << " = " << x <<"   "<< #y << " = " << y << endl;
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define all(v) (v).begin(),(v).end()
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef vector < pair <int, int> > vpii;
typedef pair<int,int>  pii;
/*/----------------------------Code begins----------------------------------/*/
int32_t main(){
fio;
int k,a,b;
cin>>k>>a>>b;
int x=a/k,y=b/k;
if(x==y&&a%k!=0)
cl("NG");
else cl("OK");
}




























Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s,t;
    cin>>s;
    cin>>t;
    int n=sz(s),ans=0;
    for (int i=0;i<n;++i)
        if (s[i]!=t[i])
            ++ans;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    set<string> s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 19204
#include <iostream>
using namespace std;
int main(){
  while(1){
  int n,k[100005],ans=0;
cin>>n;
if(n==0){break;}
for(int i=0;i<n/4;++i){
cin>>k[i];
ans+=k[i];
}
cout<<ans<<endl;
}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++)
  {
    for(int j=i;j<s.size();j++)
	{
      if(s.substr(0,i)+s.substr(j)=="keyence")
	  {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3580
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve(a):
    for j in range(k):
        el = [0] * n
        er = [0] * n
        for i in range(n):
            el[max(i - a[i], 0)] += 1
            er[min(i + a[i], n-1)] += 1
        a = [0]*n
        a[0] = el[0]
        all_n = True
        for i in range(1, n):
            a[i] = a[i-1] + el[i] - er[i-1]
            all_n &= a[i] == n
        if all_n:
            print(*a)
            return
    print(*a)
    return







n, k = RA()
a = RA()
solve(a)

Measured memory_bytes: 174988
class UnionFind
    attr_accessor :par
    def initialize(n)
        @par = Array.new(n){ |i| i }
    end

    def root(x)
        return x if par[x] == x
        par[x] = root(par[x])
    end

    def unite(x, y)
        rx = root(x)
        ry = root(y)
        par[rx] = ry unless rx == ry
    end

    def same(x, y)
        rx = root(x)
        ry = root(y)
        rx == ry
    end
end

N, M = gets.split.map(&:to_i)
pos = Array.new(N)
gets.split.each_with_index do |x, i|
    pos[x.to_i - 1] = i
end

uf = UnionFind.new(N)

M.times do
    x, y = gets.split.map(&:to_i)
    uf.unite(x - 1, y - 1)
end

c = 0
pos.each_with_index do |v, i|
    c += 1 if uf.same(v, i)
end

puts c


Measured memory_bytes: 24068
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static class Pair implements Comparable<Pair>{
		int count, key;
		
		public Pair(int count, int key){
			this.count = count;
			this.key = key;
		}

		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.count, o.count);
		}
	}
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			PriorityQueue<Pair> queue = new PriorityQueue<Pair>();
			int[] counts = new int[200000 + 1];
			for(int i = 0; i < N; i++){ counts[sc.nextInt()]++; }
			
			for(int i = 0; i < counts.length; i++){
				if(counts[i] == 0){ continue; }
				
				queue.add(new Pair(counts[i], i));
			}
			
			long answer = 0;
			while(queue.size() > K){
				//System.out.println(queue.peek().count);
				answer += queue.poll().count;
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 45396
n=int(input())
m=n

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


a=factorization(n)
#print(a)

def makearray(l):
    arr=[]
    for i in range(len(l)):
        for j in range(1,l[i][1]+1):
            arr.append(l[i][0]**j)
    arr.sort()
    return arr

b=makearray(a)
#print(b)
cnt=0

for i in b:
    if n%i==0:
        cnt+=1
        n//=i
        #print(i)
        #print('a')

if m==1:
    print(0)
else:
    print(cnt)

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

int main() { /* ここに書く */
  
  string S;
  
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;}
  
  else{
    cout << "No" << endl;}
    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int d = 0;
    FOR(i,0,s.size()){
        d += s[i]-'0';
    }
    int n = stoi(s);
    if(n%d == 0){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
      	int cnt = 0;
      for(int i=A; i<=B; i++){
		if(i%K == 0){
			cnt = cnt+1;
			}
		}
        if (cnt >= 1 ) {
            System.out.println("OK");
        }
        else {
            System.out.println("NG");
        }
        scan.close();
    }
}

Measured memory_bytes: 35748
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		for(var a=0;a>=0;a++){
			string[] str = Console.ReadLine().Split();
			int H = int.Parse(str[0]);
			int W = int.Parse(str[1]);
			if(H==0){
				break;
			} else {
				for(var i=0;i<H;i++){
					string s = "";
					for(var j=0;j<W;j++){
						s += "#";
					}
					Console.WriteLine(s);
				}
				Console.WriteLine("");
			}
		}
	}
}


Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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





///////////////////////////

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};


ll N;

vector<ll> a;

ll count(ll x) {//中央値x以上のものをカウント
	vector<ll> c(N + 1);

	c[0] = N+1;//c[i]の値を正にしたい

	repn(i, N) {
		if (a[i] >= x) { c[i] = c[i-1] + 1; }
		else { c[i] = c[i-1] - 1; }
	}

	Segment_Tree<ll> sg(2 * N + 1, [](ll a, ll b) {return a + b; },0);

	ll ret = 0;

	rep(i, N+1) {
		ll t = sg.query(1, c[i]+1);
		ret += t;
		
		ll s = sg.query(c[i], c[i] + 1);
		sg.update(c[i], s + 1);
	}

	return ret;

}



int main() {
	cin >> N;
	a.assign(N + 1,0);
	repn(i, N) cin >> a[i];

	ll le = -INF;
	ll ri = INF;

	ll K = (N*(N + 1) / 2 + 1) / 2;

	while (ri - le > 1) {
		ll m = (le + ri) / 2;

		ll C = count(m);

		//cout << m <<" "<< C << endl;

		if (C >= K) {le = m; }
		else { ri = m; }
	}

	cout << le;



	system("PAUSE");

}


Measured memory_bytes: 6244
a, b, c, d = map(int, input().split())
a = a-1

_c = c
_d = d
while _d % _c != 0:
	_d, _c = _c, _d % _c
cd = (c * d) // _c

_a = (a//c) + (a//d) - (a//cd)
_b = (b//c) + (b//d) - (b//cd)
ans = (b - a) - (_b - _a)

print(ans)


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int64> ls(n), rs(n), ds(n);
  for (int i = 0; i < n; i++) {
    cin >> ls[i] >> rs[i];
    ds[i] = rs[i] - ls[i];
  }

  multiset<int64> l_set;
  multiset<int64> r_set;
  int64 l_base = 0;
  int64 r_base = 0;
  int64 c = 0;

  l_set.insert(ls[0]);
  r_set.insert(ls[0]);

  for (int i = 1; i < n; i++) {
    l_base -= ds[i];
    r_base += ds[i - 1];

    int64 l_max = *l_set.rbegin() + l_base;
    int64 r_min = *r_set.begin() + r_base;
    if (DEBUG) {
      cout << "l_max: " << l_max << " r_min: " << r_min << endl;
    }
    if (ls[i] < l_max) {
      l_set.insert(ls[i] - l_base);
      l_set.insert(ls[i] - l_base);

      l_set.erase(prev(l_set.end()));
      r_set.insert(l_max - r_base);

      c += l_max - ls[i];
    } else if (r_min < ls[i]) {
      r_set.insert(ls[i] - r_base);
      r_set.insert(ls[i] - r_base);

      r_set.erase(r_set.begin());
      l_set.insert(r_min - l_base);

      c += ls[i] - r_min;
    } else {
      l_set.insert(ls[i] - l_base);
      r_set.insert(ls[i] - r_base);
    }
    if (DEBUG) {
      cout << "i: " << i << " c: " << c << endl;
    }
  }

  cout << c << endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
int a[5010];
int b[5010];
short dp[5010][5010];
vector<short> pre[5010];
vector<short> suf[5010];
int main(){
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		b[N-1-i]=a[i];
	}
	dp[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			if(dp[i][j]){
				dp[i+1][j]=1;
				if(j+a[i]<=K)dp[i+1][j+a[i]]=1;
			}
		}
	}
	pre[0].pb(0);
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			if(dp[i+1][j])pre[i+1].pb(j);
		}
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			if(dp[i][j]){
				dp[i+1][j]=1;
				if(j+b[i]<=K)dp[i+1][j+b[i]]=1;
			}
		}
	}
	for(int i=0;i<N-1;i++){
		for(int j=0;j<=K;j++){
			if(dp[i+1][j])suf[N-2-i].pb(j);
		}
	}
	suf[N-1].pb(0);
	int ans = 0;
	for(int i=0;i<N;i++){
		/*for(int j=0;j<pre[i].size();j++){
			printf("%d ",pre[i][j]);
		}
		printf(": ");
		for(int j=0;j<suf[i].size();j++){
			printf("%d ",suf[i][j]);
		}
		printf("\n");*/
		for(int j=0;j<pre[i].size();j++){
			int t = K-a[i]-pre[i][j];
			int idx = lower_bound(all(suf[i]),t)-suf[i].begin();
			if(idx<(int)suf[i].size()&&pre[i][j]+suf[i][idx]<K){
				ans++;
				break;
			}
		}
	}
	cout << N-ans << endl;
	return 0;
}

Measured memory_bytes: 185472
N = int(input())
S = input()

mod = 10 ** 9 + 7

if S[0] == "W" or S[-1] == "W":
    print(0)
    exit()

ans = 1
prev_s = S[0]
prev_t = True
t_sum = 1
f_sum = 0
for i in range(1, 2*N-1):
    if S[i] == prev_s:
        t = not prev_t
    else:
        t = prev_t

    if t:
        t_sum += 1
    else:
        ans *= (t_sum - f_sum)
        ans %= mod
        f_sum += 1
    prev_s = S[i]
    prev_t = t

if t_sum != N:
    ans = 0

for i in range(1, N+1):
    ans *= i
    ans %= mod

print(ans)

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=1234567890123;
int main()
{
  ll i,n,k;
  cin>>n>>k;
  ll arr[n],dp[n];
  
  for(i=0;i<n;i++)
  {cin>>arr[i];dp[i]=bg;}
  dp[0]=0;
  for(i=0;i<n;i++)
  {
    for(ll j=1;j<=k;j++)
    if(i+j<n)
       dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//const long long int MOD=1000000007;
const int MOD=1000000007;
//const long long int MOD=998244353;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K>>M;
	vector<vector<vector<long long int>>>dp(N+1,vector<vector<long long int>>(N+1,vector<long long int>(1024)));
	dp[0][0][0]=1;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=i;j++){
			if(i==j&&i==N)break;
			for(int k=0;k<1024;k++){
				if(i<N){
					int bef=MOD;
					for(int l=0;l<10;l++){
						if((k>>l)%2==0){
							bef=l+1;
							break;
						}
					}
					if(bef<=K){
						int bi=k;
						bi<<=1;
						bi&=1023;
						dp[i+1][j][bi]+=dp[i][j][k];
						dp[i+1][j][bi]%=M;
					}
				}
				if(i>j){
					int rbef=MOD;
					int ubef=MOD;
					if(!j){
						rbef=0;
					}
					else{
						for(int l=0;l<10;l++){
							if((k>>l)&1){
								rbef=l+1;
								break;
							}
						}
					}
					int cnt=0;
					for(int l=0;l<10;l++){
						if((k>>l)%2==0){
							cnt++;
							if(cnt==i-j){
								ubef=l+1;
								break;
							}
						}
					}
					if(rbef<=K&&ubef<=K){
						int bi=k;
						bi<<=1;
						bi|=1;
						bi&=1023;
						dp[i][j+1][bi]+=dp[i][j][k];
						dp[i][j+1][bi]%=M;
					}
				}
			}
		}
	}
	long long int ans=0;
	for(int i=0;i<1024;i++){
		ans+=dp[N][N][i];
		ans%=M;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 85744
#include <bits/stdc++.h>
using namespace std;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define buli(x) (__builtin_popcountll(x))
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 1e-7
#define fcin ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;

char s[1111111];

int main() {
	gs(s);
	int n = strlen(s);
	int ini=n;
	rep(i,0,n){
		if(s[i]=='C'){ini=i;break;}
	}	
	rep(i,ini+1,n)if(s[i]=='F'){
		puts("Yes");return 0;
	}
	puts("No");
}


















Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
    int n;
    string str;
    cin >> n;
    cin >> str;
    if(str.size()&1)
    {
        cout << "No";
        return 0;
    }
    
    for(int i=0 ; i<n/2 ; i++)
    {
        if(str[i] != str[n/2 + i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main(int argc, char *argv[])
{
    int n;
    cin >> n;

    vector<long long> a(n), b(n);
    for(int i = 0; i < n; ++i) 
    {
        cin >> a[i] >> b[i];
    }
 
    long long num = 0;
    for(int i = n - 1; i >= 0; --i)
    {
        a[i] += num;
        num += (b[i] - a[i] % b[i]) % b[i];
    }
    
    cout << num << endl;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  rep(sv,n) {
    vector<int> dist(n,INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];
      if (v-1 >= 0) push(v-1, d+1);
      if (v+1 < n) push(v+1, d+1);
      if (v == x) push(y, d+1);
      if (v == y) push(x, d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /=2;
  for (int i = 1; i <= n-1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <map>
#include <fstream>
using namespace std;

typedef long long int ll;
#define FOR(i, a, b) for(int i = a; i < b; i++)

const int N = 1000;

bool Color[N];

int main()
{
	int n, k;

	cin >> n >> k;

	ll ans = k;
	FOR(i, 1, n) {
		ans *= (k - 1);
	}

	cout << ans << endl;

	return 0;
}

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


void solve(std::string b){
  if(b == "A"){
    cout << "T" << endl;
  } else if(b == "T"){
    cout << "A" << endl;
  } else if(b == "G"){
    cout << "C" << endl;
  } else {
    cout << "G" << endl;
  }
  return;
}

// Generated by 1.1.3 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(){
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


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

int main() {
	int H, W; cin >> H >> W;
    char a[60][60];
	string S;
	for(int i=1; i<=H; ++i){
	    cin >> S;
	    for(int j=1; j<=W; ++j){
	        a[i][j]=S[j-1];
	    }
	}
	bool flag=true;
	for(int i=1; i<=H; ++i){
	    for(int j=1; j<=W; ++j){
	        if(a[i][j]=='#'){
	            if(a[i-1][j]!='#' && a[i+1][j]!='#'){
	                if(a[i][j-1]!='#' && a[i][j+1]!='#'){
	                    flag=false; 
	                    break;
	                }
	            }
	        }
	    }
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
using ll = long long;
int getdegit(ll);
int sum_degit(ll);
int main(int argc, char const *argv[]) {
  ll n;
  cin>>n;
  int degit=getdegit(n);
  int first_number=n/pow(10,degit-1);
  int sum1=(first_number-1)+9*(degit-1);
  int sum2=sum_degit(n);
  if(sum1>sum2){
    cout<<sum1<<endl;
  }else{
    cout<<sum2<<endl;
  }
  return 0;
}

int getdegit(ll n){
  int count=0;
  while(n!=0){
    n=n/10;
    count++;
  }
  return count;
}

int sum_degit(ll n){
  int sum=0;
  while(n!=0){
    sum+=n%10;
    n=n/10;
  }
  return sum;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K; cin >> N >> K;
    ll ans = 0;
    REP(i, K + 1, N) {
        ans += min(N, (N / i) * (i - K) + max(0LL, (N % i + 1) - K));
        //cout << i << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;

int a[maxn],b[maxn];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
	  cin>>a[i];
	for(int i=1;i<=n;++i)
	  cin>>b[n-i+1];
	int s=0,t=-1;
	for(int i=1;i<=n;++i)
	  if(a[i]==b[i])
	  {
	  	  if(!s) s=i;
	  	  t=i;
	  }     
	int l=1,r=n;  
	for(int i=s;i<=t;++i)
	  {
	  	  if(a[l]^b[i]&&b[l]^b[i]) swap(b[i],b[l++]);
	  	  else if(a[r]^b[i]&&b[r]^b[i]) swap(b[i],b[r--]);
	  	  else {cout<<"No";exit(0);}
	  }  
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;++i)
	  cout<<b[i]<<" ";
	return 0;    
}


Measured memory_bytes: 5204
#include<stdio.h>
int main(void)
{
	int n,m,A[100001],B,C[100001],sum=1,sum1=0,i;
	scanf("%d%d",&n,&m);
	for(i=1;i<n;i++){
		C[i]=0;
	}
	for(i=1;i<n;i++){
		scanf("%d",&A[i]);
		C[i+1]=C[i]+A[i];
	}
	for(i=1;i<=m;i++){
		scanf("%d",&B);
		if(sum<sum+B){
			sum1+=C[sum+B]-C[sum];
		}
		else{
			sum1+=C[sum]-C[sum+B];
		}
		sum+=B;
		sum1%=100000;
	}
	printf("%d\n",sum1);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,ans(0);
  cin >> n;
  
  vector<long>a(n);
  for(long i = 0;i<n;i++){
    a.at(i) = i + 1;
    if(a.at(i) % 3 == 0 || a.at(i) % 5 == 0);
    else{
     ans += a.at(i); 
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

int N;
vector<int> a;

// 区間i,jが残っているときのX-Y
lint dp[3001][3001];
bool df[3001][3001];

lint f(int l, int r)
{
    if (l > r) return 0;
    if (df[l][r]) return dp[l][r];

    df[l][r] = true;
    bool turn = ((N - (r - l)) % 2 == 1);
    dp[l][r] = turn ? max(f(l + 1, r) + a[l - 1], f(l, r - 1) + a[r - 1])
                    : min(f(l + 1, r) - a[l - 1], f(l, r - 1) - a[r - 1]);
    return dp[l][r];
}

void resolve()
{
    cin >> N;
    RPT0(i, N)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    RPT1(i, N) RPT1(j, N) df[i][j] = false;
    lint ans = f(1, N);
    cout << ans << endl;
}

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


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K < A) {cout << K << endl;}
  else if (K < (A + B)) {cout << A << endl;}
  else {cout << A - (K - A - B) << endl;}
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define INF 1<<21
int main()
{
	long long int min,n,u,k,v,c,dist[100][100],s,cost[100],t[100],l=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dist[i][j]=INF;
			cost[i]=INF;
			t[i]=-1;
		}
	}
	min=INF;
	dist[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>u;
		cin>>k;
		for(int i=1;i<=k;i++)
		{
			cin>>v>>c;
			dist[u][v]=c;
		}
	}
	s=0;
	cost[s]=0;
	while(l!=n)
	{
		for(int i=0;i<n;i++)
		{
			if(dist[s][i]!=INF)
			{
				if(cost[s]+dist[s][i]<cost[i])
				{
					cost[i]=cost[s]+dist[s][i];
				}
				
			}
		}
		t[s]=1;
		for(int i=1;i<n;i++)
		{
			if(cost[i]<min&&t[i]==-1)
			{
				min=cost[i];
				s=i;
			}
		}
		min=INF+1;
		l++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<i<<" "<<cost[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n+2);
    rep(i,n){
        cin >> a[i+1];
    }
    a[0] = 0;
    a[n+1] = 0;
    ll t = 0;
    rep(i,n+1){
        t += abs(a[i]-a[i+1]);
    }
    rep(j,n){
        int i = j+1;
        cout << t +abs(a[i-1]-a[i+1]) - abs(a[i]-a[i-1]) -abs(a[i]-a[i+1]) << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    string a, b;
    cin >> a >> b;
    int k = 0;
    
    for(int i = 0; i < a.size(); i++){
    	if(a[i] == b[i]) k++;
	}
		cout << k << endl;
		
	
}

Measured memory_bytes: 3596
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
ans=0
cnt={}
for i in range(n):
  if s[i] in cnt:
    cnt[s[i]]+=1
  else:
    cnt[s[i]]=1
print(sum(cnt[key]*(cnt[key]-1)//2 for key in cnt))


Measured memory_bytes: 19404
$n=<>;
$f[$_]=[glob<>]for 1..$n;
$p[$_]=[glob<>]for 1..$n;
$s=-5e9;
for$i(1..1023){
	$c=0;
	for$j(1..$n){
		$a=grep$f[$j][$_]&&$i>>$_&1,0..9;
		$c+=$p[$j][$a];
	}
	$s=$s<$c?$c:$s;
}
print$s;

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			String S="";
			if((S=Console.ReadLine())==null)break;
			Sol mySol =new Sol(int.Parse(S));
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		List<int> L=new List<int>();
		for(int i=0;i<32;i++){
			if((N&(0x1<<i))!=0)L.Add(0x1<<i);
		}
		for(int i=0;i<L.Count;i++){
				Console.Write(i==0?"{0}":" {0}",L[i]);
		}
		Console.WriteLine("");
	}
	int N;
	public Sol(int i){
		N=i;
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5700
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
// ベクトルの回転
P rotate(const P &p, double ang) {
  return p * P(cos(ang), sin(ang));
}
// pからみてangだけqを回転
P rotate(const P &p, const P &q, double ang) {
  return p+rotate(q-p,ang);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};

// 原点周りの直線の回転
L rotate(const P &p, const L &l, double ang) {
  return L(rotate(p, l[0], ang),rotate(p, l[1], ang));
}

int main() {
  int n,d;
  while(cin>>n>>d,n||d) {
    L now(P(0,0),P(0,1));
    REP(i,n) {
      double l, r, t;
      cin>>l>>r>>t;
      l = l/180*PI;
      r = r/180*PI;
      P left = now[0]+rotate((now[1]-now[0])*P(d,0),PI/2);
      P right = now[0]+rotate((now[1]-now[0])*P(d,0),-PI/2);
      //cout << "l & r : " << left << "," << right << endl;
      if (l==r) {
        P tmp = l*t*(now[1]-now[0]);
        now[0] += tmp;
        now[1] += tmp;
      } else if (l*r>=0) {
        P p = (-r*left+l*right)/(l-r); // center
        double th;// rotation angle
        if (abs(left-p)<EPS) {
          th = r*t/abs(right-p);
        } else {
          th = abs(l)*t/abs(left-p);
          if (l>r) th *= -1;
        }
        //cout << p << " " << th << endl;
        now = rotate(p,now,th);
      } else {
        P p = (abs(r)*left+abs(l)*right)/(abs(l)+abs(r)); // center
        double th = -l*t/abs(left-p);
        // cout << p << " " << th << endl;
        now = rotate(p,now,th);
      }
      //cout << now[0] << " " << now[1] << endl;
    }
    //cout << n << " " << d<< endl;
    printf("%.5f\n", now[0].real());
    printf("%.5f\n", now[0].imag());
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H , W;
  cin >> H >> W;
  int sec = 0;
  int ans = inf;
  sec = H * W;
  if(sec % 3 == 0) {
    ans = 0;
  }
  if(H >= 3) {
    int minUnit = H / 3;
    int maxUnit = minUnit + (H % 3 != 0);
    int tmp = min(ans , W * (maxUnit - minUnit));
    ans = min(ans , tmp);
  
  }  
  if(W >= 3) {
    int minUnit = W / 3;
    int maxUnit = minUnit + (W % 3 != 0);
    int tmp = min(ans , H * (maxUnit - minUnit));
    ans = min(ans , tmp);

  }
  for(int i = 1; i <= W; i++) {
    int A = i * H;
    int unit1 = H/2;
    int unit2 = H - unit1;
    int B = unit1 * (W - i);
    int C = unit2 * (W - i);
    int tmp = max(A,max(B,C)) - min(A,min(B,C));
    if(tmp >= 0) {
    ans = min(ans , tmp);
    }
  }
  for(int i = 1; i <= H; i++) {
    int A = i * W;
    int unit1 = W/2;
    int unit2 = W - unit1;
    int B = unit1 * (H - i);
    int C = unit2 * (H - i);
    int tmp = max(A,max(B,C)) - min(A,min(B,C));
    if(tmp >= 0) {
    ans = min(ans , tmp);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3700
S = input()
K = int(input())
all_same = False
for i, (s, t) in enumerate(zip(S, S[1:])):
    if s != t:
        break
else:
    all_same = True

if all_same:
    ans = (K * len(S)) // 2
else:
    first, last = 0, 0
    if S[0] == S[-1]:
        for j, t in enumerate(reversed(S)):
            if t != S[0]: break
        first, last = i+1, j
        S = S[i+1:-j]        
    seq = []
    temp = 1
    for s, t in zip(S, S[1:]):
        if s == t: temp += 1
        else:
            if temp != 1: seq.append(temp)
            temp = 1
    if temp != 0:
        seq.append(temp)
    ans = first // 2 + last // 2 + ((first + last)//2) * (K-1)
    for se in seq:
        ans += (se // 2) * K
print(ans)

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

int main(int argc, char const *argv[])
{
	string a, b; cin >> a >> b;
	string t = a + b;
	// cout << t << endl;
	int d = stoi(t);

	rep(i, 1000) {
		if (i * i == d)  {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	char s[105];
	while(~scanf("%s",s)){
		scanf("%s",s + 1);
		scanf("%s",s + 2);
		s[3] = '\0';
		puts(s);
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
ll A, B, C, res, f[200001], inv[200001];

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	cin >> N >> A >> B >> C;
	A *= modinv(100 - C);
	B *= modinv(100 - C);
	A %= mod;
	B %= mod;
	f[0] = inv[0] = 1;
	for (int i = 1; i <= 200000; ++i) {
		f[i] = f[i - 1] * i%mod;
		inv[i] = modinv(f[i]);
	}
	for (int i = 0; i < N; ++i) {
		res += pw(A, N)*pw(B, i) % mod*f[N + i - 1] % mod*inv[N - 1] % mod*inv[i] % mod *(N + i);
		res %= mod;
	}
	for (int i = 0; i < N; ++i) {
		res += pw(A, i)*pw(B, N) % mod*f[N + i - 1] % mod*inv[N - 1] % mod*inv[i] % mod *(N + i);
		res %= mod;
	}
	res *= 100 * modinv(100 - C) % mod;
	res %= mod;
	cout << res << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll q;cin>>q;
    priority_queue<ll,vl> pq1;
    priority_queue<ll,vl,greater<ll>> pq2;
    ll sum1=0;
    ll sum2=0;
    rep(i,q){
        ll type;cin>>type;
        if(type==1){
            ll a,b;cin>>a>>b;
            sum2+=b;
            pq1.push(a);pq2.push(a);
            ll c1=pq1.top(),c2=pq2.top();
            pq1.pop();pq2.pop();
            if(c1>c2){
                sum1+=c1-c2;
                pq1.push(c2);pq2.push(c1);
            }
            else{
                pq1.push(c1);pq2.push(c2);
            }
        }
        else{
            ll c1=pq1.top();
            cout<<c1<<" "<<sum1+sum2<<endl;
        }
    }
    return 0;
}

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


int main(){
    string s;
    cin>>s;
    int num_win=0,num_lost=0;

    for(int i=0;i<(int)s.size();++i){
        if(s[i]=='o') ++num_win;
        else ++num_lost;
    }
    if(num_win>=8) cout<<"YES"<<endl;
    else{
        if(8-num_win<=15-(int)s.size()) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
template<class _T> _T MAX(_T p1,_T p2){return (p2<p1)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
typedef vector<int> VI;
typedef vector<VI> VVI;
#define pb                  push_back

const int inf = 1<<29;

void solve(VVI vi, int n){
    REP(k,n)REP(i,n)REP(j,n){
        vi[i][j] = MIN(vi[i][j], vi[i][k]+vi[k][j]);
    }
    int res = inf, idx = -1;
    REP(i,n){
        int total = 0;
        REP(j,n) total += vi[i][j];
        if(res > total){
            idx = i;
            res = total;
        }
    }
    cout << idx << " " << res << endl;
}

int main(void){
    int n;
    while(cin >> n && n){
        VVI vi(10, VI(10, inf));
        int m = 0;
        REP(i,n){
            int a,b,c;
            cin >> a>>b>>c;
            vi[a][b] = MIN(vi[a][b], c);
            vi[b][a] = MIN(vi[b][a], c);
            m = MAX(m, MAX(a,b));
        }
        m++;
        REP(i,m) vi[i][i] = 0;
        solve(vi, m);
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }

  // int result = 1;
  // for (int i = 0; i < N - 1; i++) {
  //   result += (int) pow(10, i + 1);
  // }

  int result = 0;
  result += pow(10, N - 1);

  bool tmp = false;
  for (int i = 0; i < M; i++) {
    tmp = false;
    for (int j = 0; j < i; j++) {
      if(s.at(i) == s.at(j)) {
        tmp = true;
        break;
      }
    }
    if(tmp) {
      continue;
    }
    if (s.at(i) == 1) {
      result += (c.at(i) - 1) * (int) pow(10, N - s.at(i));
    }
    else {
      result += c.at(i) * (int) pow(10, N - s.at(i));
    }
  }

  if (N == 1 && M == 0) {
    result = 0;
  }

  for (int i = 0; i < M; i++) {
    for (int j = i + 1; j < M; j++) {
      if (s.at(i) == s.at(j) && c.at(i) != c.at(j)) {
        result = -1;
      }
    }
  }

  for (int i = 0; i < M; i++) {
    if (N != 1 && s.at(i) == 1 && c.at(i) == 0) {
      result = -1;
    }
  }

  cout << result << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    string S,T;
    cin>>S;
    T=S.substr(0,N/2);
    if(S==T+T){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

int main()
{
  long long int K, N;
  cin >> K >> N;
  
  long long int first, prev;
  cin >> first;
  
  long long int maxi = 0;
  
  prev = first;
  for(int i=1; i<N; i++)
  {
    int xx;
    cin >> xx;
    maxi = max(maxi, xx - prev);
    prev = xx;
  }
  maxi = max(maxi, first + K-prev);
  cout << K-maxi;
}

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

int main(){
    int i,a,b,c,d;
    string s ;
    
    for(i = 0; ; i++){
        
        cin >> a >> b >> c;
        if(a == -1 && b == -1 && c == -1) break;
    
        if(a+b >= 80) s = "A";
            else if(a+b >= 65) s = "B";
        if(a+b < 65 && a+b >= 50)s = "C";

        if(a+b < 50 && a+b >= 30){ 
            if(c >= 50) s = "C";
                else s ="D";
        }
        if(a+b < 30) s = "F";
        if(a == -1 | b == -1) s = "F";
    
    cout << s << endl;
    }
}


Measured memory_bytes: 3172