akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    //cout << 300 * 300 * 300 * 300 * 300 - 299 * 299 * 299 * 299 * 299 << endl;

    int n;
    cin >> n;
    vector<P>vec;
    for (int i = -300; i <= 300; i++) {
        vec.push_back({ i * i * i * i * i,i });
    }
    rep(i, vec.size()) {
        rep(j, vec.size()) {
            if (vec[i].first - vec[j].first == n) {
                cout << vec[i].second << " " << vec[j].second << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>

using namespace std; 

int main(void) {
	string str;
	long long num;
	priority_queue<long long> pq;
	while (cin >> str, str != "end") {
		if (str == "insert") {
			cin >> num;
			pq.push(num);
		}
		else {
			cout << pq.top() << endl;
			pq.pop();
		}
	}
	return 0;
}



Measured memory_bytes: 11164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> plp;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//--------------------------------//
 
int main() {
	int r, g;
	cin >> r >> g;
	
	cout << 2 * g - r << endl;
	return 0;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Thursday, January 31, 2019
12:50 AM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
	for (int i = 0; i < v.size(); ++i)
		os << v[i] << " ";
	return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v)
{
	for (auto it : v)
		os << it << " ";
	return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v)
{
	os << v.ff << " " << v.ss;
	return os;
}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 100005;
int n, k;
vi moves;
int dp[N][3];
int mini, maxi;

int winner = 1;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

bool inrange(int x)
{
	if (x > mini && x < maxi)
		return true;
	return false;
}

bool solve(int n, int p)
{
	if(n<0) return 1;
	if (n < mini)
	{
		//return dp[n][p] = 0;
		return 0;
	}
	if (dp[n][p] != -1)
		return dp[n][p];
	
	for (int i = 0; i < moves.size(); i++)
	{
		if (n - moves[i] == 0)
		{
			return dp[n][p] = 1;
		}
		if (p == 1)
		{
			if (solve(n - moves[i], 2) == 0)
			{
				return dp[n][p] = 1;
			}
		}
		else if (p == 2)
		{
			if (solve(n - moves[i], 1) == 0)
			{
				return dp[n][p] = 1;
			}
		}
	}
	return dp[n][p] = 0;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif

	time_t t1, t2;
	t1 = clock();

	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	mini = inf;
	maxi = -1;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		moves.pb(x);
		mini = min(mini, x);
		maxi = max(maxi, x);
	}

	if (solve(k, 1))
	{
		cout << "First" << endl;
	}
	else
		cout << "Second" << endl;

	t2 = clock();
	cerr << endl
		 << t2 - t1 << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
int N,A;
ll dp[51][51][2501];

int main() {
  cin >> N >> A;

  dp[0][0][0] = 1;
  
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;

    for(int j = 0; j <= i; j++) {
      for(int k = 0; k  < 2501; k++) {
	if(dp[i][j][k]){
	dp[i+1][j][k] += dp[i][j][k];
	dp[i+1][j+1][k+x] += dp[i][j][k];
	}
      }
    }
  }
  ll ans = 0;
  for(int j = 1; j <= N; j++) {
    ans += dp[N][j][j*A];
  }
  cout << ans << endl;
}
  
    
  


Measured memory_bytes: 48128
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc =  np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
  cc += c
  av = s[d] - sum( cc ) + cc
  av2 = av + cc*min((D-d-1),3)
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      cc[t] = 0
      v += av[t]
      print(t+1)
      break
#
#print( v )


Measured memory_bytes: 27288
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
string S;
cin>>S;
f=0;
for(auto h : S)
if(h=='R')f=1;
if(S=="RRR")f=3;
if(S=="RRS" || S=="SRR" )f=2;
cout<<f<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	double A, B;
	cin >> A >> B;
	double aa = ceil(A / 0.08);
	double bb = ceil(B / 0.1);
	int ans = max(aa, bb);

	if (floor((double)ans * 0.08) == A && floor((double)ans * 0.1) == B) {
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())
    
    num = []
    red = []
    for i in range(N+1):
        num.append(1)
        red.append(0)
    red[1] = 1
    
    for _ in range(M):
        x, y = map(int, input().split())
        if red[x] == 1:
            red[y] = 1
        num[x] -= 1
        num[y] += 1
        if num[x] == 0:
            red[x] = 0
    
    return sum(red)

print(solve())

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

#define ll long long
#define MOD 1000000007


int main(){
    ll n;
    cin>>n;
    vector<ll> trans(5);
    
    ll mi=999999999999999;
    for(int i=0;i<5;i++){
        cin>>trans.at(i);
        mi = min(trans.at(i),mi);
    }
    
    ll v;
    if(n%mi==0){
        v =n/mi;
    }else{
        v =(n/mi)+1;
    }
    
    cout<<5+(v-1)<<endl;
    
    
}



Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,n;
    cin >> h >> n;
    vector<int> A(n);
    rep(i,0,n) cin >> A[i];
    rep(i,0,n){
        h-=A[i];
    }
    if(h>0) cout << "No" ENDL;
    else cout << "Yes" ENDL;
    
    return 0;
}

Measured memory_bytes: 3712
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,K=map(int,input().split())
    A=list(map(int,input().split()))

    ma=max(A)

    from functools import reduce
    from fractions import gcd

    g=reduce(gcd,A)
    if K%g==0 and K<=ma:
        print('POSSIBLE')
    else: print('IMPOSSIBLE')

resolve()

Measured memory_bytes: 77820
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n][3];
	int ans[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}

	ans[0][0] = a[0][0];
	ans[0][1] = a[0][1];
	ans[0][2] = a[0][2];

	for(int i=1;i<n;i++)
	{
		ans[i][0] = a[i][0] + max(ans[i-1][1] , ans[i-1][2]);
		ans[i][1] = a[i][1] + max(ans[i-1][0] , ans[i-1][2]);
		ans[i][2] = a[i][2] + max(ans[i-1][0] , ans[i-1][1]);	
	}
	cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> minvec(vector<int> v1, vector<int> v2){
  if(v1.back() < v2.back()){
	return v1;
  }else{
	return v2;
  }
}

vector<int> maxvec(vector<int> v1, vector<int> v2){
  if(v1.back() < v2.back()){
	return v2;
  }else{
	return v1;
  }
}

int main(void){
  int n;
  int i,j;
  vector<int> q;
  //vector<int> out[2];
  int tmp;
  bool isok = true;
  int a=0, b=0;
  cin >> n;
  for(i=0;i<n;i++){
	for(j=0;j<10;j++){
	  cin >> tmp;
	  q.push_back(tmp);
	}

	for(j=0;j<10;j++){
	  if(q[j] > max(a, b)){
		max(a,b) == a ? a = q[j] : b = q[j];
	  }else if(q[j] < min(a,b)){
		cout << "NO" << endl;
		isok = false;
		break;
	  }else{
		min(a,b) == a ? a = q[j] : b = q[j];
	  }
	}

	if(isok) cout << "YES" << endl;
	isok = true;
	q.clear();
	a = 0; b = 0;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define PI atan(1.0)*4

int main() {
	int a,b;
//cout<<PI<<endl;
	while(a=in()){
		int i;
		double d;
		double r=360;
		double aa=0;
		for(i=0;i<a-1;i++){
			cin>>d;
			r-=d;
//cout<<sin(d/180*PI);
			aa+=sin(d/180*PI);
//cout<<aa<<endl;
		}
		aa+=sin(r/180*PI);
		cin>>b;
		r=360;
		double bb=0;
		for(i=0;i<b-1;i++){
			cin>>d;
			r-=d;
			bb+=sin(d/180*PI);
		}
		bb+=sin(r/180*PI);
//cout<<aa<<" "<<bb<<endl;
		if(fabs(aa-bb)<=1e-9){
			cout<<0<<endl;
		}else if(aa>bb){
			cout<<1<<endl;
		}else{
			cout<<2<<endl;
		}
	}
	return 0;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<string> W(N) ; 
  
  for(int i = 0 ; i < N ; i++ ){
    cin >> W.at(i) ; 
  }
  
  for(int i = 0 ; i < N ; i++){
    for(int j = i+1 ; j < N ; j++ ){
      if( W.at(i) == W.at(j)) {
        cout << "No" << endl ; return 0 ; 
      }
    }
  }
  
  for(int i = 0 ; i < N-1 ; i ++){
    if(W.at(i).back() != W.at(i+1).front() ){
      cout << "No" << endl ; return 0 ;
    }
  }
  
  cout << "Yes" << endl ;
  
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

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

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  ll a, b, h; cin >> a >> b >> h;
  outl((a + b) * h / 2)
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;

    bool easy = true;
    for (int i = 0; i < S.size(); i++) {
        if ((i & 1) == 1) {
            if (S[i] == 'R') {
                easy = false;
                break;
            }
        }
        else {
            if (S[i] == 'L') {
                easy = false;
                break;
            }
        }
    }

    cout << (easy ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    if(a > b) cout << a-1 << endl;
    else  cout << a << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int M, K, N;
int main(){
	cin >> M >> K;
	N = (1<<M);
	if(K >= N){
		cout << -1 << endl;
		return 0;
	}
	if(M == 0){
		cout << "0 0" << endl;
		return 0;
	}
	if(M == 1){
		if(K == 1) cout << -1 << endl;
		else{
			cout << "1 0 0 1" << endl;
		}
		return 0;
	}
	for(int i=0; i<N; i++){
		if(i == K) continue;
		cout << i << " ";
	}
	cout << K << " ";
	for(int i=N-1; i>=0; i--){
		if(i == K) continue;
		cout << i << " ";
	}
	cout << K << endl;
}

Measured memory_bytes: 1792
from collections import deque


def solve():
    H, W = map(int, input().split())
    S = [[0 for i in range(W)] for j in range(H)]
    visited = [[-1 for i in range(W)] for j in range(H)]
    # print(visited)

    for h in range(H):
        a = input()
        for w in range(W):
            if a[w] == '#':
                S[h][w] = -1

    directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    ans = -1

    for h in range(H):
        for w in range(W):
            if S[h][w] == -1:
                continue

            visited[h][w] = 0
            queue = deque([[h, w]])
            while queue:
                y, x = queue.popleft()
                for dir in directions:
                    next_y = y + dir[0]
                    next_x = x + dir[1]
                    if next_y >= 0 and next_x >= 0 and next_y < H and next_x < W and S[next_y][next_x] == 0 and visited[next_y][next_x] == -1:
                        visited[next_y][next_x] = visited[y][x] + 1
                        queue.append([next_y, next_x])

            for row in visited:
                ma = max(row)
                ans = max(ans, ma)

            visited = [[-1 for i in range(W)] for j in range(H)]

    print(ans)


solve()


Measured memory_bytes: 45148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll r,g,b,n;
    sc(r,g,b,n);
    int ans = 0;
    FORE(i,0,3005){
        FORE(x,0,3005){
            ll nd = n-i*r-x*g;
            ans += nd >= 0 && (nd%b == 0);
        }
    }
    cout << ans;
}



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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

using namespace std;


struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) { }
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x;
			cnt--;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int find(int x) {
		return par[x] < 0 ? x : par[x] = find(par[x]);
	}
	int size(int x) {
		return -par[find(x)];
	}
	int size() {
		return cnt;
	}
};


int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n+10);
	VI p(n);
	REP(i, n)cin >> p[i];
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		uf.unite(x, y);
	}
	int ans = 0;
	REP(i, n) {
		if (uf.same(i, p[i]-1))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)
	r := regexp.MustCompile("(^[^k].+keyence$|^k.*eyence$|^ke.*yence$|^key.*ence$|^keye.*nce$|^keyen.*ce$|^keyenc.*e$|^keyence.*$)")
	if r.MatchString(S) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			var a = firstLine[0];
			var b = firstLine[1];
			var c = firstLine[2];
			var d = firstLine[3];

			while(a > 0 && c > 0)
			{
				a -= d;
				c -= b;
			}

			Console.WriteLine(c <= 0 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 19016
N = int(input())
# N=map(int,input().split())
# A=list(map(int,input().split()))
# B=list(map(int,input().split()))

n = N // 1000 
if N % 1000 == 0:
    print((1000*n)-N)
else:
    print((1000*(n+1))-N)



Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define LL long long int
using namespace std;	
LL i,j,n,a,b,h[100010],mx=-1,high,low,mid,cnt;
int main(void)
{

	cin>>n>>a>>b;
	for(i=0;i<n;i++) cin>>h[i],mx=max(mx,h[i]);
	low=0,high=mx/b+1;
	while(low<=high) {
		mid=(low+high)/2;
		cnt=0;
		for(i=0;i<n;i++) {
			if(h[i]-b*mid>0) cnt+=(h[i]-b*mid+a-b-1)/(a-b);
		}
		//cout<<"low = "<<low<<" mid = "<<mid<<" high = "<<high<<" cnt = "<<cnt<<endl;
		if(cnt>mid) low=mid+1;
		else high=mid-1;
	}
	cout<<low<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
using namespace std;

int main() {
	int N,K; cin >> N >> K;
	int x[110];
	int sum = 0;
	
	for (int i = 0; i < N; ++i) cin >> x[i];
	for (int i = 0; i < N; ++i) {
		sum += min(abs(2 * x[i]), abs(2 * (K - x[i])));	
	}
	cout << sum << endl;
}


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

long long dp[101][4][4][4];
const long long mod = 1E9 + 7;

int main(void)
{
	int N;
	cin >> N;

	// A : 0
	// G : 1
	// C : 2
	// T : 3

	// seed
	dp[0][3][3][3] = 1;
	// len文字目
	for (int len = 0; len < N; len++) {
		// 3つ前の文字
		for (int c3 = 0; c3 < 4; c3++) {
			// 2つ前の文字
			for (int c2 = 0; c2 < 4; c2++) {
				// 1つ前の文字
				for (int c1 = 0; c1 < 4; c1++) {
					if (dp[len][c3][c2][c1] == 0)
						continue;

					// 末尾に加える文字
					for (int c0 = 0; c0 < 4; c0++) {
						// 条件を満たさない
						// ... 0 1 2
						if (c2 == 0 && c1 == 1 && c0 == 2) continue;
						// ... 0 2 1
						if (c2 == 0 && c1 == 2 && c0 == 1) continue;
						// ... 1 0 2
						if (c2 == 1 && c1 == 0 && c0 == 2) continue;
						// ... 0 ? 1 2
						if (c3 == 0 && c1 == 1 && c0 == 2) continue;
						// ... 0 1 ? 2
						if (c3 == 0 && c2 == 1 && c0 == 2) continue;

						dp[len + 1][c2][c1][c0] += dp[len][c3][c2][c1];
						dp[len + 1][c2][c1][c0] %= mod;
					}
				}
			}
		}
	}

	long long ans = 0;
	for (int c3 = 0; c3 < 4; c3++) {
		for (int c2 = 0; c2 < 4; c2++) {
			for (int c1 = 0; c1 < 4; c1++) {
				ans += dp[N][c3][c2][c1];
				ans %= mod;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

import math
ans = []
if M == 1:
    ans.append((1, 2))
else:
    m0 = (1, M+1)
    m1 = (M+2, 2*M+1)
    for _ in range(math.ceil(M/2)):
        if m0[0] < m0[1]:
            ans.append(m0)
        if m1[0] < m1[1]:
            ans.append(m1)
        m0 = (m0[0]+1, m0[1]-1)
        m1 = (m1[0]+1, m1[1]-1)

for a in ans:
    print(a[0], a[1])


Measured memory_bytes: 74480
using System;
 
public class abcA
{
	public static void Main()
	{
		string[] str = Console.ReadLine().Split(' ');
		int a, b;
        a = int.Parse(str[0]);  
        b = int.Parse(str[1]);
 
        if (a + b < 10) {
        	Console.Write(a + b);
        } else {
        	Console.Write("error");
        }
	}
}

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

long long int f(long long int b, long long int n){
    if(n<b){
        return n;
    }
    return f(b,n/b) + n%b;
}

int main() {

    long long int n,s;

    cin >> n >> s;

    if(n==s){
        cout << n+1 << endl;
        return 0;
    }

    if(n < s){
        cout << -1 << endl;
        return 0;
    }

    for(int i=2; i <= static_cast<int>(sqrt(n)); i++){
        long long int b = f(i,n);
        if(b == s){
            cout << i << endl;
            return 0;
        }
    }

    vector<long long int> Candidate;

    for(long long int i=1; i*i <= n; i++){
        if((n-s)%i == 0){
            Candidate.push_back((n-s)/i + 1);
        }
    }

    long long int ans = 1LL<<60;

    for(auto i : Candidate){
        long long int b = f(i,n);
        if(b == s){
            ans = min(ans,i);
        }
    }

    if(ans != 1LL<<60){
        cout << ans << endl;
        return 0;
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define pr1(x) cout<<"[" << #x << ": " << x << "] \n";
#define pr2(x, y) cout<<"[" << #x << ": " << x <<", "<< #y << ": " << y <<"] \n";
#define mod 1000000007
#define int long long
#define sz(v) (int)(v).size()

void solve() {
        int n; cin >> n;
        int s= 7;
        for (int i = 1; i<= 1e6; i++) {
                if (s% n== 0) {
                        cout << i<< "\n";
                        return;
                }
                s%= n;
                s= s* 10+ 7;
        }
        cout << "-1\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		long long Y, M, D;
		cin >> Y >> M >> D;
		long long ANS = 0;
		for (int j = Y + 1; j <= 999; j++) {
			if (j % 3 == 0) ANS += 200;
			else ANS += 195;
		}
		for (int j = M + 1; j <= 10; j++) {
			if (Y % 3 == 0 || j % 2 == 1) ANS += 20;
			else ANS += 19;
		}
		if (Y % 3 == 0 || M % 2 == 1) ANS += 20 - D + 1;
		else ANS += 19 - D + 1;
		cout << ANS << endl;
	}
}


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

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  if(A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			int x;
			cin >> x;
			a[i].push_back(x);
		}
	}
	
	ll ans = LLONG_MAX;
	for (int bit = 0; bit < (1<<n); bit++) {
		vector<int> lv(m);
		ll total = 0;
		int flag = 1;
		for (int i = 0; i < n; i++) {
			if (bit & (1<<i)) {
				total += c[i];
				rep(j, m) {
					lv[j] += a[i][j];
				}
			}
		}
		rep(j, m) {
			if (lv[j] < x)
				flag = 0;
		}
		if (flag == 1)
			ans = min(ans, total);
	}
	if (ans == LLONG_MAX)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int a, b;
    cin>>a>>b;
    int ans=1;
    int cnt=0;
    while(ans<b){
        ans+=a-1;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;

}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(ALL(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LLONG_MAX)
# define LINT_MIN (LLONG_MIN)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define Cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define Cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define Cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class Type> void Print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void Print(vector<vector<Type>> &df) { for (auto& vec : df) { Print(vec); } }
void Debug() { cerr << endl; }
template <class Head, class... Tail> void Debug(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(tail) != 0) cerr << " "; Debug(forward<Tail>(tail)...); }
template <class Type> void Debug(vector<Type> &vec) { for (auto& a : vec) { cerr << a; if (&a != &vec.back()) cerr << " "; } cerr << endl; }
template <class Type> void Debug(vector<vector<Type>> &df) { for (auto& vec : df) { Debug(vec); } }

int main()
{
    Cin(int, A, B);
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main() {

    int arr[5];
    scanf("%d %d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3], &arr[4]);

    int mysum = 0;
    int mindata = 10;

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

        if (arr[i] % 10 == 0) {

            mysum += arr[i];

        } else {

            mysum += ((arr[i] / 10) + 1)*10;

            mindata = (mindata > arr[i] % 10) ? arr[i] % 10 : mindata;

        }

    }

    mysum -= 10;
    mysum += mindata;

    printf("%d", mysum);

    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
w=[0]
for i in l:
    w.append((i+w[-1])%m)
ans=0
d={}
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
for i in d:
    ans+=d[i]*(d[i]-1)
print(ans//2)

Measured memory_bytes: 63768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;

//Union-Findライブラリ.1は後で修正すること.
class UF{
public:
    int par[1];
    int ran[1];

    void init(int n){
        for(int i = 0;i < n;i++){
            par[i] = i;
            ran[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(ran[x] < ran[y])par[x] = y;
        else{
            par[y] = x;
            if(ran[x] == ran[y])ran[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};
int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    for(int i = 0;i < n;i++){
        double pp;
        cin >> pp;
        p[i] = pp;
    }

    double mx = -1;

    double now_sum = 0;
    for(int i = 0;i < k;i++){
       now_sum += (p[i] + 1)/2; 
    }

    mx = now_sum;
    for(int i = k;i < n;i++){
        now_sum -= (p[i - k] + 1)/2;
        now_sum += (p[i] + 1)/2;
        mx = max(mx,now_sum);
    }

    printf("%.15lf\n",mx);
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int s,z,h,b;
    cin>>s;
    z=s/3600;
    h=s%3600/60;
    b=s%3600%60;
    cout<<z<<":"<<h<<":"<<b<<"\n";
   return(0);
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	ll n,m;
	cin>>n>>m;
	vector<string> s(n);
	for(ll i=0;i<n;++i)
	{
		cin>>s[i];
	}

	ll dp[n][m];

	dp[0][0]=(s[0][0]=='.'?0:1);
	for(ll i=0;i<n;++i)
	{
		for(ll j=0;j<m;++j)
		{
			if(i==0)
			{
				if(j!=0)
				{	
					dp[i][j]=dp[i][j-1];
					if(s[i][j]=='#')
						dp[i][j]+=(!(s[i][j]==s[i][j-1]));
				}
			}

			else if(j==0)
			{
				dp[i][j]=dp[i-1][j];
				if(s[i][j]=='#')
					dp[i][j]+=(!(s[i][j]==s[i-1][j]));
			}
			else
			{
				ll val1=dp[i][j-1];
				if(s[i][j]=='#')
					val1+=(!(s[i][j]==s[i][j-1]));
				ll val2=dp[i-1][j];
				if(s[i][j]=='#')
					val2+=(!(s[i][j]==s[i-1][j]));
				dp[i][j]=min(val1,val2);
			}
		}
	}
	cout<<dp[n-1][m-1];

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int r;
    cin >> r;

    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0, C =0, K =0;
    cin >> N >> C >> K;

    vll T(N);
    REP(i,N) cin >> T[i];
    sort(ALL(T));

    ll bus = 1,num=0,time=T[0]+K;

    REP(i,N){
      if(num<C&&T[i]<=time) num++;
      else{bus++; num=1;time=T[i]+K;}
    }
    //本文
    //出力
    cout << bus << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 4008
N, K = map(int, input().split())

n = 0
x = 0

while True:
    x = K**n
    if x > N:
        n -= 1
        break
    n += 1

ans = []

for i in range(n, -1, -1):
    if K**i < N:
        ans.append(N//(K**i))
        N = N % (K**i)
    else:
        ans.append(0)

print(len(ans))


Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

int main () {
	int N;
	vector <ll> v;
	ll ans = 0;
	cin >> N;
	for (int i=0; i<N; i++) {
		ll tmp;
		cin >> tmp;
		ans = ans ^ tmp;
		v.push_back (tmp);
	}
	for (int i=0; i<N; i++) {
		cout << (ans^v[i]) << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 5292
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  string S; cin >> S;
  ll K; cin >> K;

  if (S.length() == 1){
    cout << K / 2 << endl;
    return 0;
  }

  vector <ll> Count;
  ll now = 1;
  for (int i = 1; i < S.length(); i++){
    if (S[i] == S[i - 1]){
      now++;
    }else{
      Count.push_back(now);
      now = 1;
    }
  }
  if (now > 1) Count.push_back(now);


  if (Count.size() == 1){
    cout << Count[0] * K / 2 << endl;
    return 0;
  }
  ll ans = 0;
  for (int i = 0; i < Count.size(); i++){
    ans += Count[i] / 2;
  }
  ans *= K;

  if (S[0] == S[S.length() - 1] && Count[0] % 2 != 0 && Count[Count.size() - 1] % 2 != 0){
    ans += K - 1;
  }
  cout << ans << endl;
  
  

  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
namespace remoon {
    #define re register
    #define de double
    #define le long double
    #define ri register int
    #define ll long long
    #define sh short
    #define ui unsiged int
    #define ull unsigned long long
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define tpr template <typename ra>
    #define rep(iu, st, ed) for(ri iu = st; iu <= ed; iu ++)
    #define drep(iu, ed, st) for(ri iu = ed; iu >= st; iu --)	
    #define gc getchar
    inline int read() {
        int p = 0, w = 1; char c = gc();
        while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
        while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
        return p * w;
    }
    int wr[50], rw;
    #define pc(iw) putchar(iw)
    tpr inline void write(ra o, char c = '\n') {
        if(!o) pc('0');
        if(o < 0) o = -o, pc('-');
        while(o) wr[++ rw] = o % 10, o /= 10;
        while(rw) pc(wr[rw --] + '0');
        pc(c);
    }
    tpr inline void cmin(ra &a, ra b) { if(a > b) a = b; }
    tpr inline void cmax(ra &a, ra b) { if(a < b) a = b; } 
    tpr inline bool ckmin(ra &a, ra b) { return (a > b) ? a = b, 1 : 0; }
    tpr inline bool ckmax(ra &a, ra b) { return (a < b) ? a = b, 1 : 0; }
}
using namespace std;
using namespace remoon;

namespace mod_zone {
    int mod = 0;
    inline void inc(int &a, int b) { a += b; if(a >= mod) a -= mod; }
    inline void dec(int &a, int b) { a -= b; if(a < 0) a += mod; }
    inline int Inc(int a, int b) { return (a + b >= mod) ? a + b - mod : a + b; }
    inline int Dec(int a, int b) { return (a - b < 0) ? a - b + mod : a - b; }
    inline int mul(int a, int b) { return 1ll * a * b % mod; }
    inline int fp(int a, int k) {
        int ret = 1;
        for( ; k; k >>= 1, a = mul(a, a))
        if(k & 1) ret = mul(ret, a);
        return ret;
    }
}
using namespace mod_zone;

#define sid 400050

int n, ans;
int A[sid], B[sid], a[sid], b[sid];

inline int qry(int v) {
	return lower_bound(b + 1, b + n + 1, v) - b;
}

int main() {
	n = read();
	rep(i, 1, n) A[i] = read();
	rep(i, 1, n) B[i] = read();
	rep(i, 0, 28) {
		rep(j, 1, n) {
			a[j] = A[j] & ((1 << i + 1) - 1);
			b[j] = B[j] & ((1 << i + 1) - 1);
		}
		sort(a + 1, a + n + 1);
		sort(b + 1, b + n + 1);
		int sum = 0;
		rep(j, 1, n) {
			sum += qry(2 * (1 << i) - a[j]) - qry(1 * (1 << i) - a[j]);
			sum += qry(4 * (1 << i) - a[j]) - qry(3 * (1 << i) - a[j]);;
		}
		if(sum & 1) ans += (1 << i);
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 5632
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int p1 = a-b;
        int p2 = a+b;
        int p3 = a*b;
        System.out.println(Math.max(p1, Math.max(p2,p3)));
    }
}


Measured memory_bytes: 23764