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

const int MARGIN = 5;

struct{
	string name;
	int time;
}typedef Process;


class ProcessQueue{
private:
	Process* queueArr;
	int currTop;
	int currLimit;
	int MAX;

public:
	ProcessQueue(int n);
	Process pop();
	void enQueue(Process p);
	int getSize();

private:
	int toI(int i,bool isPositive);
};

ProcessQueue::ProcessQueue(int n){
	currTop = 0;
	currLimit = 0;
	MAX = n + MARGIN;
	queueArr = new Process[n + MARGIN];
}

Process ProcessQueue::pop(){
	if(currTop == currLimit){
		Process error;
		error.name = "error";
		error.time = 0;
		return error;
	}
	Process curr = queueArr[currTop];
	currTop = toI(currTop,true);
	return curr;
}

void ProcessQueue::enQueue(Process p){
	if(currTop == toI(currLimit,true))
		return;
	queueArr[currLimit] = p;
	currLimit = toI(currLimit,true);
}

int ProcessQueue::getSize(){
	return (currLimit >= currTop) ? currLimit - currTop : MAX - (currTop - currLimit);
}

int ProcessQueue::toI(int i,bool isPositive){
	if(i == MAX - 1 && isPositive)
		return 0;
	if(i == 0 && !isPositive)
		return MAX - 1;
	return (isPositive) ? i + 1 : i - 1;
}

void simurateRoundRobin(ProcessQueue* quu,int q){
	int total = 0;
	while(quu->getSize() > 0){
		Process p = quu->pop();
		p.time -= q;
		if(p.time > 0){
			quu->enQueue(p);
			total += q;
		}else{
			int resultTime = p.time + q;
			total += resultTime;
			cout << p.name << " " << total << endl;
		}
	}
}

int main(){
	int n,q;
	cin >> n;
	cin >> q;
	ProcessQueue queueArr(n);
	for(int i = 0; i < n;i++){
		Process p;
		cin >> p.name;
		cin >> p.time;
		queueArr.enQueue(p);
	}
	simurateRoundRobin(&queueArr,q);
	return 0;
}


Measured memory_bytes: 6312
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int N;
int L[8];
int A, B, C;

int dfs(int k, int a, int b, int c) {
    if (k == N) {
        if (a == 0 || b == 0 || c == 0) return 1e9;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int ans = 1e9;
    ans = min(ans, dfs(k + 1, a, b, c));
    ans = min(ans, dfs(k + 1, a + L[k], b, c) + (a > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b + L[k], c) + (b > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b, c + L[k]) + (c > 0 ? 10 : 0));

    return ans;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

dp = [0]*n
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), \
                dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])


Measured memory_bytes: 13928
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
long long n,m,i,j,k,s,x[1010],y[1010],z[1010],d[1010][1010][8]={};
int main(){
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  for(i=0;i<1005;i++){
    for(j=0;j<1005;j++){
      if(i+j==0)continue;
      for(k=0;k<8;k++)d[i][j][k]=-1e15;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
      for(k=0;k<8;k++){
	s=0;
	s+=x[i]*((k&1)?1:-1);
	s+=y[i]*((k&2)?1:-1);
	s+=z[i]*((k&4)?1:-1);//if(j==0&&i==0)printf("%lld\n",s);
	d[i+1][j  ][k]=MAX(d[i+1][j  ][k],d[i][j][k]  );
	d[i+1][j+1][k]=MAX(d[i+1][j+1][k],d[i][j][k]+s);
      }
    }
  }
  s=0;
  for(i=0;i<8;i++)s=MAX(d[n][m][i],s);
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 63616
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    a[i] = temp;
  }

  sort(a.begin(), a.end(), greater<int>());

  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += a[i];
  }

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

Measured memory_bytes: 256
import Control.Monad

main = do
  s <- getLine
  let [h,w] = map (read ::String->Int) $ words s in
    if h /= 0 && w /= 0 then do
      forM_ [1..h] $ \ i ->
        putStrLn $ take w $ cycle (if (i `mod` 2) == 1 then "#." else ".#")
      putStrLn ""
      main
    else
      return ()

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
  return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->



int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif


   int w,a,b;
   cin>>w>>a>>b;

   if(a>b) swap(a,b);

   ll ans = 0;

  if((w+a >= b)){
    ans = 0;
  }

   else
   {
     ans = abs(w+a-b);
   }

   cout<<ans<<endl;

}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a%2==1&&b%2==1&&c%2==1){
  out(min(a,min(b,c))*mid(a,b,c));
  }
  else
    out(0);
}

Measured memory_bytes: 3772
using System;
using System.IO;
using System.Linq;

namespace C
{
	internal class Program
	{
		static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };

		public static void Main(string[] args)
		{
			var line1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var n = line1[0];
			var m = line1[1];
			if (n >= m)
			{
				Console.WriteLine(0);
				return;
			}

			var xn = Console.ReadLine().Split().Select(int.Parse).ToArray();

			Array.Sort(xn);

			var dn = new int[m - 1];
			for (var i = 0; i < m - 1; i++) { dn[i] = xn[i + 1] - xn[i]; }

			Array.Sort(dn);

			var result = 0;
			for (var i = 0; i < m - n; i++) { result += dn[i]; }

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 19808
from sys import stdin
from itertools import combinations_with_replacement

s = stdin.readline().rstrip()
if s == "KIHBR":
    print("YES")
    exit()
li = [0,4,6,8]
lin = list(combinations_with_replacement(li, 4))
for i in lin:
    akiba = ["","K","I","H","","B","","R",""]
    for j in i:
        akiba[j] = "A"
    if "".join(akiba) == s:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n;
	while (cin >> n, n) {
		string a[1000];
		rep(i, n) {
			cin >> a[i];
			int cnt = 0;
			while (a[i][cnt] == '.')cnt++;
			cnt--; if (cnt < 0)continue;
			a[i][cnt] = '+';
			int now = i-1;
			while (a[now][cnt] == '.') {
				a[now][cnt] = '|';
				now--;
			}
		}
		rep(i, n) {
			int len = a[i].length();
			rep(j, len) {
				if (a[i][j] == '.')a[i][j] = ' ';
				cout << a[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
from collections import deque


def input():
    return sys.stdin.readline()[:-1]


def main():
    S = input()
    Q = int(input())
    que = deque(S)
    rev = 0
    for i in range(Q):
        q = input()
        if q[0] == '1':
            # que.reverse()
            rev += 1
        else:
            _, f, c = q.split()
            if rev % 2 == 0:
                if f == '1':
                    que.appendleft(c)
                else:
                    que.append(c)
            else:
                if f == '1':
                    que.append(c)
                else:
                    que.appendleft(c)
    if rev % 2 == 1:
        que.reverse()
    print("".join(list(que)))


if __name__ == "__main__":
    main()


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

template<class T>
T gcd(T a, T b) {
	if (a == 0) return b;
	return gcd(b % a, a);
}

int main() {
	ll a, b; cin >> a >> b;
	ll n = gcd(a, b);

	int res = 1;
	for (ll i = 2; i * i < n; i++) {
		if (n % i != 0) continue ;
		res++;
		while (n % i == 0)
			n /= i;
	}

	if (n != 1) res++;
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
pair<pair<string,int>,int> a[101];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n;
	cin>>n;
	fo(i,0,n){
		string s;
		int t;
		cin>>s>>t;
		a[i]=mp(mp(s,-t),i);
	}
	sort(a,a+n);
	fo(i,0,n)cout<<a[i].se+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//




int main(void)
{
        ll N,C;
        cin >> N >> C;
        vector<ll> x(N+2), v(N+2);
        for(ll i = 1; i <= N; i++)
        {
                cin >> x[i] >> v[i];
        }
        x[0] = 0;
        x[N+1] = C;

        vector<vector<ll>> dp(2, vector<ll>(100010,0));
        ll maxcal = 0;

        ll cal = 0;
        for(ll i = 1; i <= N; i++)
        {
                cal += x[i-1] - x[i];
                cal += v[i];
                dp[0][i] = max(dp[0][i-1], cal);
        }

        cal = 0;
        for(ll i = N; i >= 1; i--)
        {
                cal += x[i] - x[i+1];
                cal += v[i];
                dp[1][i] = max(dp[1][i+1], cal);
        }

        for(ll i = 0; i <= N; i++)
        {
                ll sum = 0;
                sum += dp[0][i];
                sum -= x[i];
                sum += dp[1][i+1];
                maxcal = max(maxcal, sum);

                sum = 0;
                sum += dp[1][i+1];
                sum -= C;
                sum += x[i+1];
                sum += dp[0][i];
                maxcal = max(maxcal, sum);
        }

        cout << maxcal << endl;
        return 0;
}


Measured memory_bytes: 4096
s=input()
flag=0
a,b=-1,-1
if len(s)==2:
    if s[0]==s[1]:
        a,b=1,2
else:
    for i in range(len(s)-2):
        if s[i]==s[i+1] or s[i+1]==s[i+2] or s[i]==s[i+2]:
            a,b=i+1,i+3
            break
print(a,b,sep=' ')

            
    

                


Measured memory_bytes: 3188
/*
name:       Egyptian Tourist
PlatForm:   CodeForces/SPOJ...etc
LANG:       C++
DIV:        Training
TIME:       *
RATE:       *
*/

/*
Time Consumed:*
Problem Topics: *
*/

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

//-------------------------------------------------------//
#define rep(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define repr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define lp(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define lpr(i,n) for (int i = (n) - 1; ~i; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
//-------------------------------------------------------------------------------------//

#define clr(ar, val) memset(ar, val, sizeof(ar))
//----------------------------------------------//

#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#define PI 3.1415926535897932385
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define bit(n) (1<<(n))
#define Last(i) ( (i) & (-i) )
#define all(v) ((v).begin()), ((v).end())
#define sq(x) ((x) * (x))
#define INF INT_MAX
#define Ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

//-------------------------------------------------------------//
#ifndef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 << std::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
#define _ist_ cout << "\nSTART OF INPUT DISPLAYING CHECK\n";
#define _iend_ cout << "\nEND OF INPUT DISPLAYING CHECK\n";
//------------------------------------------------------------//
#define mod (int)(1e9 + 7)
//#define N (int)2e5 + 5
#define N (int)1e5 + 5
//----------------------------------//
typedef pair<int, char> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
//---------------------------------//
template<class T, class T2>
T _f_pow(T a, T2 b)
{
    T res = 1LL;
    //a%=mod;
    while (b > 0)
    {
        if (b & 1)
            res = (res*a);//res = (res * a)%mod;
        a = (a * a);
        //a%=mod;
        b >>= 1;
    }
    return (res);
}
template<class T>
T gcd(T a, T b)
{
    while(a && b)
        if(a > b)
            (a%=b);
        else(b%=a);

    return a + b;
}
template<class T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}

int main()
{
    Ios;
    //inn;outt;
    //auto tt = clock();
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    if(arr[0] == 5 && arr[1] == 5 && arr[2] == 7)
        puts("YES");
    else
        puts("NO");
    //cout << (double(clock() - tt)/CLOCKS_PER_SEC * 1.00) << endl;
    //system("sleep 50");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main()
{
    int n,d,x;
    cin >> n;
    cin >> d >> x;
    int arr[n];
    int sum=0;
    for (int i=0; i < n; i++) {
        cin >> arr[i];
        int a = 0;
        for (int j=1; j <= d; (j = a*arr[i] + 1)) {
            sum++;
            a++;
        }
    }
    int ans;
    ans = x + sum;
    cout << ans << endl;
    return 0;
}

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

int n, arr[20];

int dfs(int m, int d){
    if(m == n) return abs(d);
    int pat1 = dfs(m + 1, d + arr[m]);
    int pat2 = dfs(m + 1, d - arr[m]);
    return min(pat1, pat2);
}

int main(){
    while(scanf("%d", &n) && n){
        for(int x = 0; x < n; x++){
            scanf("%d", arr+x);
        }
        printf("%d\n", dfs(0, 0));
    }
    return 0;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(20);
	ll i,n,x,ans=1,s=0,t;
	cin>>n>>x;
	for (i=0;i<n;i++){
		cin>>t;
		s+=t;
		ans+=(s<=x)?1:0;
	}
	cout<<ans;
	return 0;
}

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

#define MOD 1000000007
#define MAX_P 1000005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}


//INSERT ABOVE HERE
signed main(){
  init(MOD);
  Int n,m,k;
  cin>>n>>m>>k;
  Int s=n+m+k;
  vector<Int> po(s+1,1);
  for(Int i=0;i<s;i++) po[i+1]=po[i]*3%MOD;
  
  vector<Int> dp(s+1,0);
  dp[0]=1;
  for(Int i=0;i<s;i++){
    dp[i+1]+=dp[i]+MOD-mod_comb3(i,m,MOD);
    dp[i+1]+=dp[i]+MOD-mod_comb3(i,k,MOD);
    dp[i+1]%=MOD;
  }
  
  Int ans=0;
  for(Int i=n;i<=s;i++){
    Int res=mod_comb3(i-1,n-1,MOD);
    res=res*po[s-i]%MOD;
    res=res*dp[i-n]%MOD;
    ans+=res;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int n;
bool vis[303][303][303];
double dp[303][303][303];

double call(int a,int b,int c){
    if(a==0 and b==0 and c==0) return 0.0;
    if(vis[a][b][c]==1) return dp[a][b][c];
    vis[a][b][c]=1;
    double ex=n;
    if(a) ex+=call(a-1,b,c)*a;
    if(b) ex+=call(a+1,b-1,c)*b;
    if(c) ex+=call(a,b+1,c-1)*c;
    return dp[a][b][c]=ex/(double)(a+b+c);
}

int main()
{
    cin >> n;
    int a=0,b=0,c=0;
    FOR(i,1,n){
        int tmp;
        cin >> tmp;
        if(tmp==1) a++;
        else if(tmp==2) b++;
        else if(tmp==3) c++;
    }
    cout << fixed << setprecision(12) << call(a,b,c);
}


Measured memory_bytes: 244096
#include <iostream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
using namespace std;

long long nC2(int num) {
   return (num * (num -1)) / 2;
}
string sortString(string str) {
  sort(str.begin(), str.end());
  return str;
}

int main(void) {
  int N;
  unordered_map<string, int> um;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S;
    string _S = sortString(S);
    um[_S]++;
  }

  long long cnt = 0;
  for(auto itr = um.begin(); itr != um.end(); ++itr) {
     long long num = itr->second;
     cnt += num * (num - 1) / 2;
  }
   
  cout << cnt;
  return 0;
}

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


void solve(long long A, long long B){
  cout << (B % A == 0 ? A + B : B - A) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
    int t=1;
   // cin>>t;
    while(t--)
    {
        int n,mp;
        cin>>n>>mp;
       // unordered_map<int,int> m;
       if(n%2==0) n--;
        int l=(n-1)/2;
        int start=1;
        int it=1;
        //n++;
        while(mp>0)
        {
            cout<<start<<" "<<(start+l)<<endl;
            start=(start+l+it)%n;
            l--;
            it++;
        
            mp--;


        }
    }

}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    if(N%111 == 0) cout << N << endl;
    else{
        cout << (N/111 + 1)*111 << endl;
    }
}

Measured memory_bytes: 256
//====================================
//======================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               200010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                              (1e9)+1000
#define        eps                             1e-9
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline long double dxt(){long double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
#ifdef sayed
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::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) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int ar[N];
int main(){
    #ifdef sayed
    //freopen("out.txt","w",stdout);
    // freopen("in.txt","r",stdin);
    #endif
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    ll a = lxt() ;
    ll b = lxt();
    ll c =1;
    while(1) {
        a=a*2LL;
        if(a>b) break;
         c++;
    }
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)

using namespace std;

int main(void){
    string s,t;
    cin >> s >> t;
    ll cnt = 0;
    rep(i,s.size()) if (s[i] != t[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3468
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		Long A = sc.nextLong();
		Long B = sc.nextLong();
		Long X = sc.nextLong();
		
		// 割り切れる個数の算出
		Long count0toB = B / X + 1L;
		Long count0toA = 0L;
		if(A > 0){
			count0toA = (A-1) / X + 1L;
		}
		Long countAtoB = count0toB - count0toA;
		
		// 出力
		System.out.println(countAtoB);
	}

}


Measured memory_bytes: 23764
function Main(inputs) {
　const inputlines = inputs.split("\n");
　const firstline = inputlines[0].split(" ");
　const votevalues = inputlines[1].split(" ").map(x => parseInt(x, 10));
　const standard = 1 / (4 * firstline[1]);
　let yes = 0; 
  
　let totalvotes  = function(arr) {
　　　let sum = 0;
　　　arr.forEach(function(elm) {
　　　sum += elm;
    	　});
    	　return sum;
　};
  
　const currentstandard = totalvotes(votevalues) * standard;
  
　for (let i = 0; i < votevalues.length; i++){
　　if(votevalues[i] >= currentstandard){
　　　yes++;
　　　if(yes == firstline[1]){
　　　　console.log("Yes");
　　　　break;
　　　}
　　}
　}
　if(yes != firstline[1]){
　　console.log("No");
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  double a, b;
  cin >> a >> b;
  double x=(a+b)/2;
  int y=(a+b)/2;
  double z=x-y;
  if (z>0){
    x++;
  }
  x = static_cast<int>(x);
  cout << x << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A,B int
	fmt.Scan(&A,&B)
	
	judge := "No"
	for i := 1; i <= 3; i++ {
		if A * B * i % 2 != 0 {
			judge = "Yes"
		}
	} 
	fmt.Println(judge)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 1e5 + 5;

int n,k,q;
int a[maxn];

inline void Solve (){
	//int maxium = *max_element(a + 1,a + n + 1);
	for(int i = 1; i <= n; i++){
		if(a[i] - q + k <= 0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
	}
}

inline void Input (){
	n = read<int>();
	k = read<int>();
	q = read<int>();
	for(int i = 1; i <= q; i++){
		int x;
		x = read<int>();
		a[x]++;
	}
}

int main(){
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

vector<vector<pair<int,int>>> G(100009);
ll d[100009];

void bfs(int s) {
    
    mem(d,-1);
    d[s] = 0;
    
    queue<int> q;
    q.push(s);
    
    while( !q.empty() ){
        
        int u = q.front(); q.pop();
        //cout1(u);
        for(int v=0; v<G[u].size(); v++){
            pair<int,int> t = G[u][v];
            if(d[t.first]!=-1) continue;
            d[t.first] = d[u] + t.second;
            q.push(t.first);
        }
    }
}

int main() {
    int N, Q, K;
    cin >> N;
    
    rep(i,N-1){
        int a, b, c; scnd3(a,b,c);
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    
    cin >> Q >> K;
    bfs(K);
    
    rep(i,Q){
        int x, y; scnd2(x,y);
        cout1(d[x]+d[y]);
    }
}

Measured memory_bytes: 8820
import sys
s = input()
while True:
  if s[-5:] == 'dream':
    s = s[:-5]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  else:
    print('NO')
    sys.exit()
  if s == '':
    print('YES')
    sys.exit()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 
int main()
{
    arena
    set<ll> s;
    for(ll i=1;i<=9;i++)
    {
        for(ll j=1;j<=9;j++)
        {
            s.insert(i*j);
        }
    }
    
    ll n;
    cin>>n;
    if(s.find(n)!=s.end())
    cout<<"Yes";
    else
    cout<<"No";
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) 
    cin >> a.at(i);
 
  bool start = true;
  for (int i = 0; i < n; i++) {
    if (a.at(i) == 0) {
      cout << 0 << endl;
      start = false;
    }
  }
  
  if (start) {
    long long res = a.at(0);
    for (int i = 1; i < n; i++) {
      if (res > LLONG_MAX / a.at(i)) {
        res = -1;
        break;
      }
      else {
        res *= a.at(i);
        if (res > 1000000000000000000) {
          res = -1;
          break;
        }
      }
    }
    cout << res << endl;
  }
 
  return 0;
}


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

int main()
{
    int H,W;

    while(cin>>H>>W)
    {
        if(H==0 && W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3032
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

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

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

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

void solve(){
	ll n;
	cin >> n;

	vector<ll> a(n, 0);
	for (ll i = 0; i < n;i++){
		cin >> a[i];
	}
	ll ans = 0;
	for (ll i = 1; i < n; i++)
	{
		if(a[i-1]>a[i]){
			ans += (a[i-1] - a[i]);
			a[i] = a[i - 1];
		}
	}

		cout << ans << endl;
}

int main(){
	
	solve();
	
    return 0;
}



Measured memory_bytes: 4796
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp std::make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::min;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cill(n);
    cill(q);
    co(n * q);
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3640
num = int(input())
building = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
line = "####################"
while num > 0:
  b, f, r, v = map(int,input().split())
  building[b-1][f-1][r-1] += v
  num -= 1
for i in range(4):
  for j in range(3):
    building[i][j] = " " + " ".join(map(str,building[i][j]))

for i in range(4):
  [print(j) for j in building[i]]
  if i < 3:
    print(line)


Measured memory_bytes: 5612
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll pos[200010];

int main()
{
	int n;cin >> n;
	
	REP(i,n)
	{
		ll tmp;cin >> tmp;
		pos[tmp] = i;
	}
	
	set<ll> s;
	
	s.insert(-1);
	s.insert(n);
	
	ll ans = 0;
	
	for(ll i = 1;i <= n;i++)
	{
		auto it = s.upper_bound(pos[i]);
		ll r = *it;
		ll l = *(--it);
		
		ans += i * (r - pos[i]) * (pos[i] - l);
		
		s.insert(pos[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    if(N % 10 == 7 || (N / 10) % 10 == 7 || (N / 100) % 10 == 7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
S=input()
print("YES" if sum([1 if S[:i] == "keyence"[:i] and S[i - 6:] == "keyence"[i - 6:] else 0 for i in range(1, 7)] + [1 if S[:7] == "keyence" or S[-7:] == "keyence" else 0]) > 0 else "NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n = s.size();
    int cnt=0;
  if(n%2==0)
    {
        for(int i=0,j=n-1;i<n/2;i++,j--)
        {
            if(s[i]!=s[j])cnt++;

        }
    }
    else
    {
        for(int i=0,j=n-1;i<=n/2;i++,j--)
        {
            if(s[i]!=s[j])cnt++;
        }
    }

    cout<<cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[100000];
int main()
{
  int n;
  ll ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s,s+n);
  int ind=0;
  while(ind < n)
  {
    string t = s[ind];
    ll cnt = 1;
    ind++;
    while(ind < n && s[ind] == t)
    {
      cnt++;
      ind++;
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n;
    std::cin>>n;

    std::vector<long long> v;
    v.push_back(2);
    v.push_back(1);
    for(int i = 2;i <= n;i++){
        v.push_back(v[i - 2] + v[i - 1]);
    }

    std::cout<<v.back()<<std::endl;
    return 0;
}

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

using namespace std;

#define ll long long

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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	vector<int> sorted = arr;
	sort(sorted.begin(), sorted.end());

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (arr[i] != sorted[i])
		{
			cnt++;
		}

		if (cnt > 2)
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

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

template<class T> inline bool chmax(T &a, T b)
{
    if(a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vector<pll> wvs;
    for(int i=0; i<n; i++)
    {
        ll w, v;
        cin >> w >> v;
        wvs.emplace_back(w, v);
    }

    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    for(int i=1; i<=n; i++)
    {
        pll wv = wvs.at(i-1);
        for(int j=0; j<=W; j++)
        {
            chmax(dp.at(i).at(j), dp.at(i-1).at(j));
            if(j - wv.first >= 0)
            {
                chmax(dp.at(i).at(j), dp.at(i-1).at(j-wv.first) + wv.second);
            }
        }
        // for(auto &n : dp.at(i)) cout << setw(3) << n << ' ';
        // cout << '\n';
    }
    cout << dp.at(n).at(W) << '\n';

    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	set<int> st1{1,3,5,7,8,10,12};
	set<int> st2{4,6,9,11};
	set<int> st3{2};
	int x,y;
	cin >> x >> y;
	if(st1.count(x)==1&&st1.count(y)==1)
		cout << "Yes" << endl;
	else if(st2.count(x)==1&&st2.count(y)==1)
		cout << "Yes" << endl;
	else if(st3.count(x)==1&&st3.count(y)==1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3616