akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b;
	cin >> a >> b;
	out(a * b);

	return 0;
}

Measured memory_bytes: 3596
# ABC065_B
S = str(input())
N = len(S)

for i in range(1,N+1):
    T = S[0:-i]
    M = N-i
    if M % 2 == 1:
        pass
    elif T[0:(M//2)] != T[(M//2):M]:
        pass
    else:
        print(N-i)
        break


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

const int maxn = 110;

int n,m,x;
vector<int> a;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  cin >> n >> m >> x;
  for (int i = 0; i < m; i++) {
    int t; cin >> t;
    a.push_back(t);
  }

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

  int f = 0;
  int s = 0;
  for (int i = 0; i < m; i++) {
    if (a[i] < x) f++;
    else s++;
  }

  cout << min(f,s) << endl;

  return 0;
}


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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n = 5;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        if(a[i] == 0) cout << i + 1 << endl;
    }

}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int a[100010];
int main()
{
    ll n;
    cin >> n;
    REP(i, n)
        cin >> a[i];
    sort(a, a + n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum ^= a[i];
    }
    if(sum==0){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool is_approved = true;
    rep(i,n){
        if(a[i] % 2 != 0) continue;
        if(a[i] % 3 == 0 || a[i] % 5 == 0) continue;
        is_approved = false;
        break;
    }
    cout << (is_approved ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl; 
  return 0;
}


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

int main() {
    ll x;
    cin >> x;
    ll now = 100;
    ll n = 0;
    while(1){
        now += now*0.01;
        n++;
        if(x <= now){
            // cout << x << " " << now << endl;
            cout << n << endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	
	cin >> n;
	int ans = n;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0;i < n;i++) {
		if (a[i] == 2)continue;
		else for (int k = 2;k <= sqrt(a[i]);k++) {
			if (a[i] % k == 0) {
				ans--;break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3172
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;



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

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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);

  ll ans=0;

  rep(i,0,n)std::cin>>a[i];

  if(a[0]!=0){
    std::cout<<-1<<"\n";
    return 0;
  }

  rep(i,0,n-1){
    if(a[i+1]>a[i]+1){
      std::cout<<-1<<"\n";
      return 0;
    }

    if(a[i+1]==a[i]+1)ans++;
    else ans+=a[i+1];
  }

  std::cout<<ans<<"\n";



  return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<iostream>
using namespace std;

int main()
{
	int m,n,a;
	scanf("%d %d",&m,&n);
	a=2*n-m;
	printf("%d\n",a);
}

Measured memory_bytes: 256
#include<stdio.h>
  int main(void)
{
   int a, b, c, box;

    scanf("%d %d %d",&a,&b,&c);
    if(a > b)
    {
        box = a;
        a = b;
        b = box;
    }
    if(b > c)
    {
        box = b;
        b = c;
        c = box;
    }
    if(a > c)
    {
        box = a;
        a = c;
        c = box;
    }
    if(a > b)
    {
        box = a;
        a = b;
        b = box;
    }
    if(b > c)
    {
        box = b;
        b = c;
        c = box;
    }
    if(a > c)
    {
        box = a;
        a = c;
        c = box;
    }
    printf("%d %d %d\n",a,b,c);

}

Measured memory_bytes: 2716
<?php
fscanf(STDIN, "%d", $N);
$keta = 0;
while ($N > 0) {
    $keta++;
    if ($N > pow(26, $keta)) {
        $N -= pow(26, $keta);
    } else {
        break;
    }
}
$N--;
$ans = "";
for ($i = 0; $i < $keta; $i++) {
    $x = $N % 26;
    $ans = chr($x + ord('a')) . $ans;
    $N -= $x;
    $N /= 26;
}
echo $ans;


Measured memory_bytes: 16248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n,m,c,ans=0;
  cin >> n >> m >> c;
  vector<int> b=input(m);
  
  rep(i,n){
    vector<int> a=input(m);
    int count=0;
    rep(j,m){
      count += a[j]*b[j];
    }
    if(count+c>0){
      ans++;
    }
  }
  cout << ans << endl;
}

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


int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(bit,1<<(n-1)) {
        int i = 0;
        rep(j,n){
            if(bit>>j & 1) {
                // cout << s.substr(i,j-i+1) << endl;
                ans += stoll(s.substr(i,j-i+1));
                i = j + 1;
            } else if (j == n-1) {
                // cout << s.substr(i,j-i+1) << endl;
                ans += stoll(s.substr(i,j-i+1));
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

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

    int res = 0;
    for (int i = 1; i <= N; i++){
	int x = i;
	int sum = 0;
	for (int j = 0; j < 5; j++){
	    sum += x%10;
	    x /= 10;
	}

	if ((A <= sum) && (sum <= B)){
	    res += i;
	}
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
	n = int(input())
	R0 = int(input())
	R1 = int(input())
	difference = R1 - R0
	if R0 > R1:
		Rmin = R1
	else:
		Rmin = R0
	for i in range(n-2):
		Rn = int(input())
		if Rn - Rmin > difference:
			difference = Rn - Rmin
		if Rmin > Rn:
			Rmin = Rn
	print(difference)


Measured memory_bytes: 5612
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static long q = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
static long[,] vertexes = new long[q,2];//ここに受け取る
static long[] checkNum = new long[2];
	static void Main()
	{
    for(long i = 0; i < q; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }
    
		for(long i = 0; i < q; i++)
    {
      checkNum[0] = vertexes[i,0];
      checkNum[1] = vertexes[i,1];
      if(checkNum[0]!=checkNum[1]) Console.WriteLine(Search(0, checkNum[0]*checkNum[1]));
      else Console.WriteLine(2*checkNum[0]-2);
    }
	}

  static long Search(long min, long max)//二分探索法で最大値を求める
  {
  while (true)
    {
    //Console.WriteLine(min+" "+max);
    long mid = min + (max - min) / 2;
    if(Check(mid)) min = mid;//さらに大きくても成り立つかも
    else max = mid;

    if(max - min <= 1)
      {
      if(Check(max)) 
        {
        return max;//最大値で成り立つかの確認を優先
        }
      else
        {
        return min;
        }
    break;
      }  
    }
  }

static bool Check(long testNum)
  {
  try
    {
      checked
      {
        long test = ((testNum+2)/2)*((testNum+3)/2);
      }
    }
    catch(OverflowException ex)//オーバーフローの例外処理
    {
      return false;
    }
  
  if(((testNum+2)/2)*((testNum+3)/2) < checkNum[0]*checkNum[1]) return true;
  return false;
  }
  
}

Measured memory_bytes: 11220
#include <stdio.h>
#define MAX 10000
 
struct Node{
  int parent, left, right;
};
 
struct Node Tree[MAX];
int n, D[MAX],H[MAX];
 
void depth( int i, int k ){
  if( i == -1 )return;
  D[i] = k;
  depth( Tree[i].left, k + 1 );
  depth( Tree[i].right, k + 1 );
}
 
int height( int i ){
  int h1 = 0, h2 = 0;
  if( Tree[i].left != -1 ){
    h1 = height( Tree[i].left ) + 1;
  }
  if( Tree[i].right != -1 ){
    h2 = height( Tree[i].right ) + 1;
  }
 
  if( h1 < h2 ) return H[i] = h2;
  else return H[i] = h1;
}
 
int sibling( int i ){
  if( Tree[i].parent == -1 )return -1;
  if( Tree[Tree[i].parent].left != -1 && Tree[Tree[i].parent].left != i ){
    return Tree[Tree[i].parent].left;
  }
  if( Tree[Tree[i].parent].right != -1 && Tree[Tree[i].parent].right != i ){
    return Tree[Tree[i].parent].right;
  }
  return -1;
}
 

int main(){
  int v,l,r,root = 0,i,deg;
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    Tree[i].parent = -1;
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    Tree[v].left = l;
    Tree[v].right = r;
    if( l != -1 )Tree[l].parent = v;
    if( r != -1 )Tree[r].parent = v;
  }
 
  for( i = 0 ; i < n ; i++ ){
    if( Tree[i].parent == -1 )root = i;
  }

  depth( root, 0 );
  height( root );

  for( i = 0 ; i < n ; i++ ){
    printf("node %d: parent = %d, sibling = %d, ", i,Tree[i].parent,sibling(i));
    deg = 0;
    if( Tree[i].left != -1 )deg++;
    if( Tree[i].right != -1 )deg++;
    printf("degree = %d, depth = %d, height = %d, ", deg,D[i],H[i]);
    if( Tree[i].parent == -1 ){
      printf("root\n");
    }
    else if( Tree[i].left == -1 && Tree[i].right == -1 ){
      printf("leaf\n");
    }
    else{
      printf("internal node\n");
    }
  } 
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
bool p(int a,int b)
{
    return a>b;
}
int modpow(int a,int b,int c)
{
    if(b==0)
        return 1%c;
    int u = modpow(a,b/2,c);
    u=(u*u)%c;
    if(b&1)
        u=(u*a)%c;
    return u;
}
bool cmp(const pair<ll,ll>&q,const pair<ll,ll>&f)
{
    return q.second>f.second;
}
ll prime(ll x)
{
    if(x<2)
    {
        return false;
    }
    else
    {
        for(int i=2;i*i<=x;i++)
        {
            if(x%i==0)
            {
                return false;
            }
        }
        return true;
    }
}

int main() {
    fast();
    ll x,n=0;
    cin>>x;
    for(int i=1;i<=x;i++)
    {
        n+=(x-1)/i;
    }
    cout<<n<<endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[2001][2001];
ll MOD=1e+9+7;
int main(){
	int N,M;
	int S[10001],T[10001];
	scan(N>>M);
	rep(i,N){
		scan(S[i]);
	}
	rep(i,M){
		scan(T[i]);
	}
	rep1(x,N){
		rep1(y,M){
			if(S[x-1]==T[y-1]){
				dp[x][y]+=dp[x-1][y-1]+1;
			}
			else dp[x][y]=0;
			dp[x][y]+=(dp[x-1][y]+dp[x][y-1]-dp[x-1][y-1]+MOD)%MOD;
			dp[x][y]%=MOD;
			//printf("x:%d y:%d dp:%lld\n",x,y,dp[x][y]);
		}
	}
	prin(dp[N][M]+1);
	return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

int gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N],ma,ans,l[N],r[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ma=max(ma,a[i]);
	for(int i=1;i<=n;i++)l[i]=gcd(a[i],l[i-1]);
	for(int i=n;i>=1;i--)r[i]=gcd(a[i],r[i+1]);
	for(int i=1;i<=n;i++){
		ans=max(ans,gcd(l[i-1],r[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int dp[87], a[87], tmp[87];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) scanf("%d", &a[j]);
        for (int j = 0; j < 3; j++) tmp[j] = dp[j];
        for (int j = 0; j < 3; j++) {
            int cur = 0;
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                cur = max(cur, tmp[k]);
            }
            dp[j] = cur + a[j];
        }
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i).sort.reverse

h = Hash.new(0)
A.each{ |a| h[a] += 1 }

s = []
h.each{|k, v|
    s << k if v > 1
    s << k if v > 3
}

if s.length > 1
    puts s[0] * s[1]
else
    puts 0
end

Measured memory_bytes: 16496
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

int dp[10010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N; cin >> N;
  cout << 1000*((N+-1+1000)/1000)-N << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

using pll = pair<ll,ll>;

int main(void){
	int n;
	cin >> n;
	vector<ll> a(n),b(n);

	rep(i,n) cin >> a[i] >> b[i];
	ll ans = min(accumulate(begin(a),end(a),0LL),accumulate(begin(b),end(b),0LL));

	vector<pll> aary,bary;

	rep(i,n){
		aary.push_back(pll(a[i],i));
		bary.push_back(pll(b[i],i));
	}

	sort(begin(aary),end(aary));
	sort(begin(bary),end(bary));
	
	rep(loop,2){
		set<pll> bneed;
		vector<ll> bcsum = {0LL};

		rep(i,n){
			const ll val = bcsum.back() + bary[i].first;
			bcsum.push_back(val);
		}

		ll cur = 0LL;
		rep(i,n-1){
			cur += aary[i].first;
			const int idx = aary[i].second;
			bneed.insert(pll(b[idx],idx));
			// rest
			const int num = n - 1 - i;
			auto key = *begin(bneed);
			const int pos = getidx(bary,key);

			if(pos < num){
				chmin(ans,cur + bcsum[num]);
			} else {
				chmin(ans,cur + bcsum[num-1] + key.first);
			}
		}
		swap(a,b);
		swap(aary,bary);
	}

	cout << ans << endl;

	return 0;
}

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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	
	return 0;
}

Measured memory_bytes: 3652
import numpy as np
from bisect import bisect_left, bisect_right  # return index

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

if A.sum() < B.sum():
    print(-1)
    exit()

diff = A - B
diff = np.sort(diff).tolist()

zero_ix = bisect_left(diff, 0)
plus = diff[zero_ix:][::-1]
minus = diff[:zero_ix]
minus_sum = sum(minus)

cnt = len(minus)
if cnt == 0:
    print(0)
    exit()

for i in range(len(plus)):
    cnt += 1
    minus_sum += plus[i]
    if minus_sum >= 0:
        break

print(cnt)

Measured memory_bytes: 39884
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.LongConsumer;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextLong();
        Arrays.sort(a);

        Map<Long, Integer> map = new HashMap<>();
        for (Long l : a) map.put(l, map.getOrDefault(l, 0) + 1);

        long ans = 0;
        LongConsumer mapDec = l -> map.put(l, map.get(l) - 1);
        for (int i = n - 1; i >= 0; i--) {
            if (map.get(a[i]) == 0) continue;
            mapDec.accept(a[i]);
            long diff = 2 * Long.highestOneBit(a[i]) - a[i];
            if (map.containsKey(diff) && map.get(diff) > 0) {
                ans++;
                mapDec.accept(diff);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 108024
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2.0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
using namespace std;

/*
t回繰り返す

コストをcostと定義してまずすべての区間に電線を埋設する場合を考える（最大コスト）
その(後発電機の数-1)かい以下を繰り返す
家の位置をX[i]として，X[i] - X[i-1]の最大値の分最大コストから引く

残ったコストが答え
*/
int main() {
    int N, K; cin >> K >> N;
    int cost = 0;
    vi x(N); rep(j, N) {
        cin >> x[j];
    }
    sort(ALL(x));
    cost = x[N - 1] - x[0];
    if (N == 1) {
        cost = 0;
        cout << cost << endl;
    }
    else {
        vi diff(N - 1); 
        for (int ti = 1; ti < N; ti++) {
            diff[ti - 1] = x[ti] - x[ti - 1];
        }
        sort(ALL(diff), greater<int>());

        for (int k = 0; k < min(K - 1, N - 1); k++) {
            cost -= diff[k];
        }

        cout << cost << endl;
    }     

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define lp(it, it1, it2) for (auto it = it1; it < it2; it++)                              //loop
#define present(c, x) (c.find(x) != c.end())
using namespace std;
using namespace std::chrono;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii
int main() {
    ll n;
    cin >> n;
    vvi c(n, vi(3));
    for (int i = 0; i < n; i++) {
        for (auto &j : c[i])
            cin >> j;
    }
    vvi dp(n, vi(3));
    for (int i = 0; i < 3; i++)
        dp[0][i] = c[0][i];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + c[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + c[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i][2];
    }
    cout << *max_element(all(dp[n - 1])) << "\n";
    return 0;
}


Measured memory_bytes: 11136
class FactMod:

    def __init__(self, n, mod):
        self.mod = mod
        self.f = [1] * (n + 1)
        for i in range(1, n + 1):
            self.f[i] = self.f[i - 1] * i % mod

        self.inv = [pow(self.f[-1], mod - 2, mod)]
        for i in reversed(range(1, n + 1)):
            self.inv.append(self.inv[-1] * i % mod)
        self.inv.reverse()

    def fact(self, n):
        """
        :return: n!
        """
        return self.f[n]

    def comb(self, n, r):
        """
        :return: nCr
        """
        return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod


Q = int(input())
items = []
for i in range(Q):
    items.append(tuple(map(int, input().split())))

mod = 10 ** 6 + 3
fact_mod = FactMod(mod - 1, mod)

for x, d, n in items:
    if d == 0:
        print(pow(x, n, mod))
    elif x == 0:
        print(0)
    else:
        invd = pow(d, mod - 2, mod)

        xd = x * invd % mod
        limit = mod - xd
        if n > limit:
            print(0)
            continue

        r = xd + n - 1
        l = xd - 1
        tmp = pow(d, n, mod)
        print(fact_mod.fact(r) * fact_mod.inv[l] * tmp % mod)


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

int main(){
int n;
cin>>n;
int b[n-1];
for(int i=0;i<n-1;i++)
  cin>>b[i];
long long ans=b[0]+b[n-2];
 for(int i=1;i<n-1;i++)
    ans+=min(b[i],b[i-1]);
 cout<<ans<<endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int cnt = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(K <= A[i])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
task=[]
for _ in range(n):
  a, b=map(int, input().split())
  task.append([a,b])
task.sort(key=lambda x:x[1])

cula=0
for a, b in task:
  cula+=a
  if cula>b:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 40788
#include <iostream>
using namespace std;
int main()
{
  char a[4];
  for (int i=1;i<5;i++){
  cin >> a[i];
  }
  if(a[1]==a[2]||a[2]==a[3]||a[3]==a[4]){
  cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
import math
import collections
import fractions
import itertools

def solve():
    a, b = map(int, input().split())
    if abs(a) < abs(b):
        ans = abs(b)-abs(a)
        if a < 0:
            ans += 1
        if b < 0:
            ans += 1
        print(ans)
    else:
        ans = abs(a)-abs(b)
        if 0 < a:
            ans += 1
        if 0 < b:
            ans += 1
        print(ans)
    return 0

if __name__ == "__main__":
    solve()


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

using namespace std;

using ll = long long;

static const ll MOD = 1000000007LL;

int main(){
  string s;
  cin >> s;
  cin.ignore();

  int n;

  n = s.size();

  // DPテーブル
  // dp[i][j]は、i桁目までの余りがjであるものの数を表す
  ll dp[n + 1][13];

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

  int c; // s[i]を数値に変換、?の場合は-1
  for (int i = 0; i < n; i++){
    if(s[i] == '?'){
      c = -1;
    } else {
      c = s[i] - '0';
    }

    //cout << "c = " << c << endl;

    for(int j = 0; j < 10; j++){
      if((c == -1) || (c == j)){
        for(int k = 0; k < 13; k++){
          dp[i+1][(k * 10 + j) % 13] += dp[i][k];
          //cout << "UPDATE" << endl;
        }
      } else {
        continue;
      }
    }
    for (int j = 0; j < 13; j++){
      dp[i+1][j] %= MOD;
    }
  }

  ll res = dp[n][5];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 10624
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	println(N * N * N)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>
using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int lli;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    int smal=n+1;
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
        if(arr[i]<=smal)
        {
            cnt++;
            smal=arr[i];
        }
        
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int a[101];
signed main()
{
	int n,m;
	cin>>n>>m;
	int d=0;
	for (int i=0;i<n;i++){
		cin>>a[i];
		d+=a[i];
	}
	int y=d/(4*m);
	if (d%(4*m)==0) y--;
	int ans=0;
	for (int i=0;i<n;i++){
		if (a[i]>y)  ans++;
	}
	if (ans>=m)  cout<<"Yes";
	else  cout<<"No";
	re 0;
}

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

int main(){
  int n; long long a, b; cin >> n >> a >> b;
  long long prev; cin >> prev;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    long long k; cin >> k;
    ans += min((k - prev)*a, b);
    prev = k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S ;
  cin >> S ;
  int A =S.size() ;
    
  for(int i = 0; i < A ; i++){
    
  S.at(i) = 'x' ;
  }
  cout << S << endl;
  
}

Measured memory_bytes: 256
io = DATA.eof? ? STDIN : DATA
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
sum=[0]
max=a[0]
a.each_cons(2) do |x,y|
  sum << (max>y ? max-y : 0)
  max=[max,y].max
end
p sum.sum

__END__


Measured memory_bytes: 29812
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <climits>

using namespace std;
typedef long long ll;

#define ASIZE(arr) (sizeof(arr)/sizeof(arr[0])

//int dp[1000][1000];
//int n, W, w[1000], v[1000];
//void solve() {
//	for (int i = n - 1; i >= 0; i--)
//	{
//		for (int j = 0; j <= W; j++)
//		{
//			if (j < w[i]) {
//				dp[i][j] = dp[i + 1][j];
//			}
//			else {
//				dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
//			}
//		}
//	}
//}

vector<ll> p = { 1 }, b = { 1 };

ll solve(ll n, ll x) {
	if (n == 0)return x <= 0 ? 0 : 1;
	else if (x <= 1 + b[n - 1]) return solve(n - 1, x - 1);
	else return p[n - 1] + 1 + solve(n - 1, x - 2 - b[n - 1]);
}

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (ll i = 1; i < s.size(); i++)
	{
		if (s[i] == s[i - 1]) {
			if (s[i] == '0') {
				s[i] = '1';
			}
			else {
				s[i] = '0';
			}
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int N = s.length();
  int M = 7;
  string match = "keyence";
  bool issat = false;
  if(s==match)issat = true;
  rep(i,M){
    string t;
    t += s.substr(0,i);
    t += s.substr(i+N-M);
    if(t==match) issat = true;
  }
  YESNO(issat);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,y;
    cin>>n>>x>>y;
    ll ans[n];
    for(ll i=1;i<n;i++)
        ans[i]=0;
    for(ll i=1;i<n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {
            ll val=min(j-i,min(abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y)));
            ans[val]++;
        }
    }
    for(ll i=1;i<n;i++)
        cout<<ans[i]<<endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# Watch
#	Write a program which reads an integer S [second] and converts it to h:m:s where h, m, s denote hours, minutes (less than 60) and seconds (less than 60) respectively.
#
# Input
#	An integer S is given in a line.
#
# Output
#	Print h, m and s separated by ':'. You do not need to put '0' for a value, which consists of a digit.
#
# Constraints
#	0≤S≤86400
# Sample Input 1
#	46979
# Sample Output 1
#	13:2:59

S = int(input())
h = int(S / (60 * 60))
m = int((S - (h * 60 * 60)) / 60)
s = S % 60
print(h, m, s, sep=':')



Measured memory_bytes: 5592
#include<cstdio> // 边界条件？ 
#include<cstring> 

typedef long long LL;

const int maxn = 2e5 + 5;

const LL mod = 1e9+7;

LL last[maxn];

LL dp[maxn];

int s[maxn];

int main(){

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

	dp[0] = 1; 
	
	for(int i = 1; i <= n; i++) scanf("%d",&s[i]);

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

		dp[i] = dp[i-1];
		
		if(last[s[i]] && last[s[i]]<i-1) dp[i] = (dp[i] + dp[last[s[i]]])%mod;

		last[s[i]] = i;
	}

	printf("%lld\n",dp[n]);

	return 0;
}

Measured memory_bytes: 4096
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] H = Console.ReadLine().Split(' ');
    
    int max = 0;
    string able = "Yes";
    
    for (int i = 0; i < N; i++)
    {
      int hi = int.Parse(H[i]);
      if (hi >= max - 1) //OK
      {
        max = Math.Max(max, hi);
      }
      else
      {
        able = "No";
        break;
      }
    }
    
    Console.WriteLine(able);
    
  }
}

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

int main() {
int N;
  cin >> N;
  vector<int64_t> com(N+1);  //数字の個数
  vector<int64_t> kazu(N+1); //A1~AN
  vector<int64_t> ans(N+1);  //それぞれの数字のコンビネーション
  
  //まずは代入
  for(int i = 1; i <= N; i++){   
  	cin >> kazu[i];
    com[kazu[i]]++;
  }
  //ここでコンビネーションを一回決める
  for(int i = 1; i <= N; i++){
    int64_t kaka = com[i];
    ans[i] = kaka*(kaka-1)/2;
  }
  int64_t sum = 0;
  
  //いったん答えね
  for(int i = 1; i <= N; i++){   
  	sum += ans[i];
  }
  for(int i = 1; i <= N; i++){
  	int64_t kokodake = sum - ans[kazu[i]];
    int64_t kakaka = com[kazu[i]]-1;
    int64_t ansi = kakaka*(kakaka-1)/2;
    cout << kokodake + ansi << endl;
  }
  
}

Measured memory_bytes: 7296
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] p = new int[n];
		for (int i=0;i<n;i++) {
			p[i] = Integer.parseInt(sc.next());
		}
		int cnt = 0;
		for (int i=1;i<n-1;i++) {
			if ((p[i-1]<=p[i] && p[i]<=p[i+1]) || (p[i-1]>=p[i]) && (p[i]>=p[i+1])) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22740
X, K, D = map(int, input().split())
ans = None
abx = abs(X)
if abx/D > K:
     ans = abx - D*K
else:
    tmp = abx//D
    ans = abs(abx - D*tmp)
    if (K - tmp) % 2 == 1:
        ans = abs(ans - D)

print(ans)

Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
int mygcd(int x,int y){
  return y==0?x:mygcd(y,x%y);
}

int main(){
  int N;
  cin >> N;
  int A[N];
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
  int B[N]={A[0]};
  int C[N]={A[N-1]};
  for (int i=1;i<=N-1;i++){
    B[i]=mygcd(B[i-1],A[i]);
    C[i]=mygcd(C[i-1],A[N-i-1]);
  }
  int ans=C[N-2];
  for (int i=1;i<=N-1;i++){
    ans=max(ans,mygcd(B[i-1],C[N-2-i]));
  }
  ans=max(ans,B[N-2]);
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  long n;
  cin >> n;
  
  long mi = 1e13;
  for(long i = 1; i <= sqrt(n); i++) {
    long ans;
    long j = n/i;
    if(i*j == n)
      ans = (i-1)+(j-1);
    mi = min(mi, ans);
  }
  cout << mi << endl;
}

Measured memory_bytes: 3664
n = gets.to_i
a,b = gets.split(" ").map{|d|d.to_i}
p = gets.split(" ").map{|d|d.to_i}

p.sort!{|a,b| a<=>b}

t = Array.new(3)
t =  [p.select{|i| i <= a }.size ,p.select{|i| a < i && b >= i }.size ,p.select{|i| b < i }.size]
p t.min


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

#define    ll     long long int

ll div_ceil(ll a, ll b)
{
    ll s = a / b;
    if (a % b != 0) s++;
    return s;
}

int main( )
{
    ll a, b, x, y, n, p, q, g;
    cin >> n;
    x = 1;
    y = 1;
    while (n--) {
        cin >> a >> b;
        g = max(div_ceil(x, a), div_ceil(y, b));
        x = g * a;
        y = g * b;
    }
    cout << (x + y) << '\n';
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

type h struct {
	idx int
	v   int
}

func main() {
	var n int
	fmt.Scan(&n)

	var s string
	var p int
	hm := make(map[string][]h)

	ss := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		fmt.Scan(&p)

		tmpH := h{
			idx: i + 1,
			v:   p,
		}
		if len(hm[s]) == 0 {
			hm[s] = []h{tmpH}
			ss = append(ss, s)
		} else {
			hm[s] = append(hm[s], tmpH)
		}
	}

	sort.Strings(ss)

LOOP:
	for _, city := range ss {
		if strings.TrimSpace(city) == "" {
			continue
		}
		points, _ := hm[city]

		pl := make([]int, 1)
		pm := make(map[int]int, 1)
		for _, point := range points {
			if point.idx == 0 {
				continue LOOP
			}
			pl = append(pl, point.v)
			pm[point.v] = point.idx
		}
		sort.Sort(sort.Reverse(sort.IntSlice(pl)))
		for j := 0; j < len(points); j++ {
			fmt.Println(pm[pl[j]])
		}
	}
}


Measured memory_bytes: 640
import sys
n = int(input())
pre = input()
suf = input()
if pre==suf:
    print(n)
    sys.exit()
slicer, ans = n-1 , n*2
for xx in range(n+1):
    if suf[:slicer] in pre:
        ans = len(pre)+(len(suf)-len(suf[:slicer]))
        break
    slicer-=1
print(ans)

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

int main(){
  long long int H,W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1;
  }
  else if (H * W % 2 == 0){
    cout << H * W / 2;
  }
  else {
    cout << (H * W + 1) / 2;
  }
}
  

Measured memory_bytes: 256
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 1000000007

#n = int(input())
#b = int(input())
a,b,c,k = [int(i) for i in input().split()]
#table = [int(i)  for i in input().split()] for j in range(h)] #table[h][w]
#table = [list(input()) for n in range(r)] #table[h][w]
#s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()

#list = list(s)
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

if(k <= a):
    print(k)
elif(k <= a+b):
    print(a)
elif(k < a+b+c):
    print(a-(k-a-b))
else:
    print(a-c)

Measured memory_bytes: 27100
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
int a[1000];
int main() {
  cout << fixed << setprecision(10);
  cin >> N;
  REP(i,N)
    cin >> a[i];
  int S=0;
  REP(i,N)
    S+=a[i];
  REP(i,N)
    a[i] *= N;
  int cs=10000000;
  int ans=N+1;
  REP(j,N) {
    int i=N-1-j;
    if (abs(a[i]-S)<=cs) { 
      cs = abs(a[i]-S);
      ans=i;
    }
  }
  cout << ans <<endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n, m; cin >> n >> m;
    int ans = 0;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;

    cout << ans << endl;
}

Measured memory_bytes: 256