akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int l;
#define fastIO              ios::sync_with_stdio(false), cin.tie(0)
#define pf                  push_front
#define pb                  push_back
#define popb                pop_back()
#define popf                pop_front()
#define loop(i,n)           for(int i=0;i<n;i++)
#define lop(i,n)           for(int i=1;i<n;i++)
#define loops(i,x,n)        for(int i=x;i<n;i++)
#define loopr(i,n)          for(int i=n-1;i>=0;i--)
#define loopt(i,n)          for(int i=1;i<=n;i++)
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define INT_BITS 32
#define  st                  l t; cin>>t;
#define  sn                  l n; cin>>n;
#define  unordered_map<l,l>  u;
#define MOD1 1000000007
char c[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
l gcd(l a,l b)
{
    return b==0?a:gcd(b,a%b);
}
int maxSubArray(vector<int>& nums) {
        int msf = INT_MIN,meh = 0;
        for(int i=0;i<nums.size();i++)
        {
            meh = meh + nums[i];
            if(meh<nums[i])
                meh = nums[i];
            if(msf<meh)
                msf = meh;
        }
        return msf;
}
l binaryToDecimal(l n)
{
    l num = n;
    l dec_value = 0;
    l base = 1;

    l temp = num;
    while (temp) {
        l last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = base * 2;
    }

    return dec_value;
}
/*void bt(int s,int e,int *tree,int ind )
{
    if(s==e)
    {}
}*/
l sum(l a,l b)
{
    return a+b;
}
l frog(l h[],l n)
{
   l dp[n];
   dp[0] = 0;
   dp[1] = abs(h[0]-h[1]);
   for(l i=2;i<n;i++)
   {
       l a = dp[i-1] + abs(h[i]-h[i-1]);
       l b = dp[i-2] + abs(h[i]-h[i-2]);
       dp[i] = min(a,b);
   }
return dp[n-1];
}
int main()
{
    fastIO;
    l  n;
    cin>>n;
    l a[n];
    l h[n];
    loop(i,n)
    cin>>h[i];
    cout<<frog(h,n)<<"\n";

    return 0;
}


Measured memory_bytes: 1792
sub f{my($a,$b)=@_;($a,$b)=($b,$a)if($a>$b);($a,$b)=($b%$a,$a)while($a);return$b;}<>=~/ (.+) (.+) /;$X=abs$2-$`;$Y=abs$'-$1;print$X&&$Y?$X+$Y-&f($X,$Y):0;

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

using namespace std;

int a[222];
int main() {
	int n, p = 1e9 + 7;
	string s;
	cin >> n >> s;
	for (auto c : s)
		a[c]++;
	long r = 1;
	for (int i = 'a'; i <= 'z'; i++)
		(r *= a[i] + 1) %= p;
	cout << (r + p - 1) % p << endl;
	return 0;
}


Measured memory_bytes: 512
#include <array>
#include <cmath>
#include <iostream>

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

    constexpr int size        = 200000;
    long long int dp[size][2] = {{0}};

    long long int tmp;
    std::cin >> tmp;
    dp[1][1] = tmp;
    std::cin >> tmp;
    dp[2][0] = std::max(tmp, dp[1][1]);

    if (num >= 3)
    {
        std::cin >> tmp;
        dp[3][0] = std::max(dp[2][0], tmp);
        dp[3][1] = dp[1][1] + tmp;
    }

    for (int i = 4; i <= num; ++i)
    {
        std::cin >> tmp;
        if (i % 2 == 1)
        {
            dp[i][0] = std::max(dp[i - 2][0] + tmp, dp[i - 1][0]);
            dp[i][1] = dp[i - 2][1] + tmp;
        }
        else
        {
            dp[i][0] = std::max(dp[i - 2][0] + tmp, dp[i - 1][1]);
        }
    }

    std::cout << dp[num][0] << std::endl;
}


Measured memory_bytes: 6316
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
ll absll(ll a) { return a < 0 ? -a : a; }

// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n); REP(i, n) cin >> a[i];

    // accumulation
    cout <<
        accumulate(ALL_OF(a), 0LL, [](ll stack, ll &ai) -> ll { return stack + absll(ai); })
        - count_if(ALL_OF(a), [](ll &ai) -> bool { return ai < 0; }) % 2
            * 2 * absll(*min_element(ALL_OF(a), [](ll &x, ll &y) -> bool { return absll(x) < absll(y); }))
    << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
long long a[55];
int main(){
	long long k;
	scanf("%lld",&k);
	int n=50;
	for (int i=0;i<n;i++) a[i]=49;
	for (int i=0;i<n;i++) a[i]+=k/(LL)n;
	for (int i=0;i<(k%n);i++){
		a[i]+=n;
		for (int j=0;j<n;j++){
			if (j!=i) a[j]--;
		}
	}
	printf("%d\n",n);
	for (int i=0;i<n;i++){
		printf("%lld ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
class Dice(object):
    def __init__(self):
        self.upside = 1
        self.frontside = 2
        self.rightside = 3
        self.backside = 5
        self.leftside = 4
        self.downside = 6
		
    def throwDice(self,dir):
        up = self.upside
        front = self.frontside
        left = self.leftside
        if dir == "S":
            self.frontside = up
            self.backside = 7-up
            self.downside = front
            self.upside = 7-front
			
        elif dir == "N":
            self.frontside = 7-up
            self.backside = up
            self.downside = 7-front
            self.upside = front
 		
        elif dir == "E":
            self.rightside = up
            self.leftside = 7-up
            self.upside = left
            self.downside = 7-left
		
        elif dir == "W":
            self.rightside = 7-up
            self.leftside = up
            self.upside = 7-left
            self.downside = left
	
    def getUpside(self):
        return self.upside
		
n = list(map(int,input().split()))
com = list(input())

dice = Dice()
for i in range(len(com)):
    dice.throwDice(com[i])

print(n[dice.getUpside()-1])

	
	
	

Measured memory_bytes: 7788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    if (i != j && j != k
                            && l[i] < l[j] && l[j] < l[k]
                            && l[i] + l[j] > l[k]) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35956
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int N; cin >> N;
  vector<long long int> l(N+1);
  
  l[0] = 2;
  l[1] = 1;
  for (long long int i = 2; i <= N; i++) {
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[N] << endl;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
L=list(map(int,input().split()))
Z=[0]*(N+1)
for i in range (M):
	for j in range (N):
		if L[i]==j:
			Z[j]=1
print(min(sum(Z[0:X+1]),sum(Z[X:N+1])))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

s = input()

cand = ['dream', 'dreamer', 'erase', 'eraser']

q = ['']

while len(q) != 0:
    front = q.pop(0)

    for c in cand:
        start = len(front)
        end = len(front) + len(c)
        if end <= len(s) and s[len(front):len(front) + len(c)] == c:
            next_elm = front + c
            if next_elm == s:
                print('YES')
                sys.exit(0)
            q.append(next_elm)

print('NO')


Measured memory_bytes: 9452
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    for(;b<=a;ans++,b*=2);
    for(;c<=b;ans++,c*=2);
    cout<<(ans<=k?"Yes":"No")<<endl;
}


Measured memory_bytes: 3632
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if(a % 3 && b % 3 && (a + b) % 3){
        std::cout << "Impossible" << std::endl;
    }
    else{
        std::cout << "Possible" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>

using namespace std;

double sq(double x){return x*x;}

int t[10][10];

int main(){
	int x,y,s;
	while(~scanf("%d,%d,%d",&x,&y,&s)){
		if(s == 1){
			for (int i = 0; i < 10; i++)
			{
				for (int j = 0; j < 10; j++)
				{
					if(abs(i-x) + abs(j-y) <= 1) t[i][j]++;
				}
			}
		} else if(s == 2){
			for (int i = 0; i < 10; i++)
			{
				for (int j = 0; j < 10; j++)
				{
					if(abs(i-x) <=1 && abs(j-y) <= 1) t[i][j]++;
				}
			}
		} else if(s == 3){
			for (int i = 0; i < 10; i++)
			{
				for (int j = 0; j < 10; j++)
				{
					if(abs(i-x) + abs(j-y) <= 2) t[i][j]++;
				}
			}
		}
	}

	int no = 0, big = 0;
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			if(t[i][j] == 0) no++;
			big = max(big,t[i][j]);
		}
	}

	printf("%d\n%d\n",no,big);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int R, G;

	cin >> R >> G;

	cout << 2*G-R << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M, u, v;
vector<lint> to[100000];
vector<lint> rev[100000];
lint dp[100000];
lint prv[100000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	vector<lint> indegree(N);
	REP(i, N + M - 1) {
		cin >> u >> v; u--; v--;
		to[u].push_back(v);
		rev[v].push_back(u);
		indegree[v]++;
	}

	stack<lint> st;
	REP(i, N) if (indegree[i] == 0) st.push(i);

	vector<lint> sorted;

	while (!st.empty()) {
		lint curr = st.top(); st.pop();
		sorted.push_back(curr);
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			indegree[next]--;
			if (indegree[next] == 0) st.push(next);
		}
	}

	lint idxed[100000];
	REP(i, N) {
		idxed[sorted[i]] = i;
	}

	REP(i, N) {
		if (SZ(rev[i]) == 0) cout << 0 << endl;
		else {
			lint maxv = -1, maxidx = -1;
			REP(j, SZ(rev[i])) {
				lint pe = rev[i][j];
				if (maxv < idxed[pe]) {
					maxv = idxed[pe];
					maxidx = pe;
				}
			}
			cout << maxidx + 1 << endl;
		}
	}
}


Measured memory_bytes: 16444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long memoMae = 2;
		long memoAto = 1;
		long memoKotae = 0;
		for (int i = 0; i < N - 1; i++) {
			memoKotae = memoMae + memoAto;
			memoMae = memoAto;
			memoAto = memoKotae;
		}
		if (N == 0) {
			System.out.println(2);
		} else if (N == 1) {
			System.out.println(1);
		} else {
			System.out.println(memoKotae);
		}
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main()
{
    int i, j;
    
    for (i = 1; i <= 9; i++)
    {
        for (j = 1; j <= 9; j++)
        {
            printf("%dx%d=%d\n", i, j, (i*j) );    
        }
    }
    
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int main(void){
  char s[100000];
  int i,a[26]={0};
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    a[s[i]-97]++;
  }
  for(i=0;i<26;i++){
    if(a[i]==0) {printf("%c",i+97);return 0;} 
  }
  printf("None");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
   int n , m;
   cin >> n >> m;
   int i;
   double l = m;
   int arr[n];
   double sum = 0;
   for(i=0;i<n;++i){
   		cin >> arr[i];
   		sum+=arr[i];
   }
   double  k = ceil(sum/(4*l));
   sort(arr, arr+n, greater<int>());
   for(i=0;i<m;i++){
   		if(arr[i]<k){
   			cout << "No";
   			return 0;
		   }
   }
   cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, a, b, c, d;

int bs(int lb, int ub)
{
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        if(mid * c - (N - 1 - mid) * d <= b - a){
            lb = mid;
        }
        else{
            ub = mid;
        }
    }
    return lb * d - (N - 1 - lb) * c;
}

signed main()
{
    cin >> N >> a >> b >> c >> d;
    if(b - a <= bs(0, N)){
        printf("YES\n");
        return 0;
    }
    printf("NO\n");

    return 0;
}
/*



*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n;
    cin>>n;
    vector<pair<int,int> > v;
    f(i,n){
        int p;
        cin>>p;
        v.pb(mp(p,i+1));
    }
    sort(all(v));
    f(i,v.size())cout<<v[i].S<<" ";

}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 2544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

    int M = max({A, B, C});
    int S = A + B + C;
    int res=0;
    if (M % 2 == S % 2){
        res = (3*M - S) / 2;
    }
    else{
        res = (3*(M+1) -S) / 2;     
    }

    cout << res << endl;
}


Measured memory_bytes: 256
O = input()
E = input()
ans=""
if len(O)==len(E):
  for i in range(len(O)):
      ans+=O[i]+E[i]
    
      
if len(O)>len(E):
  for i in range(len(E)):
    ans+=O[i]+E[i]
  ans+=O[len(O)-1]
  
print(ans)
  
      

Measured memory_bytes: 8936
#include <stdio.h>
int main()
{
    char s[10];
    int i;
    int count=0;
    scanf("%s",s);
    for(i=0;i<3;i++)
    {
        if(s[i]=='o')
            count++;
    }
    printf("%d",700+count*100);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define MAX 305
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,ans,a[MAX<<1];
int cnt1,cnt2,f[MAX<<1][MAX][MAX];
int S[MAX<<1];
bool vis[MAX<<1],book[MAX<<1];
int main()
{
	n=read();
	for(int i=1;i<=n+n;++i)a[i]=read();
	for(int i=1;i<=n+n;i+=2)
		if(a[i]==-1&&a[i+1]==-1)++cnt1;
		else if(a[i]>0&&a[i+1]>0)vis[a[i]]=vis[a[i+1]]=true;
		else ++cnt2,book[(~a[i])?a[i]:a[i+1]]=true;
	for(int i=n+n;i;--i)if(!vis[i])S[++m]=i;
	f[0][0][0]=1;
	for(int i=1;i<=m;++i)
		for(int j=0;j<=cnt1+cnt2;++j)
			for(int k=0;k<=cnt2;++k)
			{
				if(!f[i-1][j][k])continue;
				if(!book[S[i]])
				{
					add(f[i][j+1][k],f[i-1][j][k]);
					if(j)add(f[i][j-1][k],f[i-1][j][k]);
					if(k)add(f[i][j][k-1],1ll*k*f[i-1][j][k]%MOD);
				}
				else
				{
					add(f[i][j][k+1],f[i-1][j][k]);
					if(j)add(f[i][j-1][k],f[i-1][j][k]);
				}
			}
	ans=f[m][0][0];for(int i=1;i<=cnt1;++i)ans=1ll*ans*i%MOD;
	printf("%d\n",ans);
	return 0;
}


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string

#define sz(x) x.size()
#define INF LONG_MAX
#define IINF LLONG_MAX
#define PI (2.0*acos(0.0))

#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);

#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Rof(i, j, k) for(int i = j; i >= k; i--)
#define all(x) x.begin(),x.end()
#define asort(x) sort(all(x));
#define dsort(x) sort(all(x), greater<int>())
#define unq(x) x.erase(unique(x.begin(),x.end()),x.end())

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;

LL gcd(LL a,LL b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}

LL bigmod(LL base, LL power, LL mod)
{
    if(power==0) return 1;
    else if(power%2==1)
    {
        LL value1 = base % mod; LL value2 = (bigmod(base,power-1,mod))%mod;
        return (value1*value2)%mod;
    }
    else
    {
        LL value1 = (bigmod(base,power/2,mod))%mod;
        return (value1*value1)%mod;
    }
}

int main()
{
    //A
    int n;
    sfi(n);
    int a,b;
    sfi2(a,b);
    int aa = a;
    if(n==1) printf("OK");
    else
    {
        int divi = a / n;
        a = n * divi;

        while(true)
        {
            if(a%n==0 and a>=aa and a<=b)
            {
                cout<<"OK";
                break;
            }
            if(a>b)
            {
                cout<<"NG";
                break;
            }
            a = a + n;
        }
    }



    //B
    /*LL n;
    sfl(n);

    LL pre = 100;

    int count = 0;
    while(true)
    {
        if(pre>=n)
        {
            cout<<count;
            break;
        }
         pre = pre + (pre/100);
         count++;
    }*/


    //C

}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    cout << ((
        c[0][0] + c[1][1] == c[0][1] + c[1][0]
        && c[1][1] + c[2][2] == c[1][2] + c[2][1]
        && c[2][2] + c[0][0] == c[2][0] + c[0][2]
    ) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,i,p=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    c%i;
    if(c%i==0){p++;}}


  printf("%d\n",p);
  return 0;
}

Measured memory_bytes: 596
import math
N,D,A = map(int,input().split())
l = []
for i in range(N):
  l.append(list(map(int,input().split())))
l.sort()  
lx = []
lc = []
for i in l:
  X,H = i[0],i[1]
  lx.append(X)
  lc.append(math.ceil(H/A))

migi = []
m = 0
i = 0
while i <= N-1:
  if lx[m] - lx[i] > 2*D:
    migi.append(m)
    i += 1
  elif m != N-1:
    m += 1
  elif m == N-1:
    migi.append(-1)
    i += 1 

cnt = 0
dam = [0 for i in range(N)]
for i in range(N):
  if dam[i] < lc[i]:
    c = lc[i] - dam[i]  
    dam[i] += c
    if migi[i] >= 0:
      dam[migi[i]] -= c
    cnt += c
  if i <=N-2:
    dam[i+1] += dam[i]   
print(cnt)

Measured memory_bytes: 78332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define ll long long
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int n,s[105],sum=0;
  cin>>n;
  rep(i,n)cin>>s[i];
  sort(s,s+n);
  rep(i,n)sum+=s[i];
  if(sum%10!=0){
    cout<<sum<<endl;
  }else{
    bool ok=true;
    rep(i,n){
      if((sum-s[i])%10!=0){
	sum-=s[i];
	ok=false;
	break;
      }
    }
    if(ok){
      rep(i,n){
	sum-=s[i];
	if(sum%10!=0)break;
      }
    }
    cout<<sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> hate(10, false);
  for (int i = 0; i < (int)K; ++i) {
    int D;
    cin >> D;
    hate[D] = true;
  }

  function<bool(int)> ok = [&](int n) {
    if (n == 0) return true;
    if (hate[n % 10]) return false;
    return ok(n / 10);
  };

  for (int i = N;; ++i) {
    if (ok(i)) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import sys
k = int(input())
old = [1,2,3,4,5,6,7,8,9]
new = []
count = 9
if k <= count:
    print(old[k-1])
    sys.exit()
else:
    while count < k:
        if len(old) > 0:
            i = old.pop(0)
            last = i%10
            if last != 0:
                new.append(i*10 + (last-1))
                count += 1
                if count == k:
                    break
            new.append(i*10 + last)
            count += 1
            if count == k:
                break
            if last != 9:
                new.append(i*10 + (last+1))
                count += 1
                if count == k:
                    break
        else:
            old = new
            new = []
    print(new[-1])

Measured memory_bytes: 42608
n=int(input())
while n!=0:
    stack_x=[0]
    stack_y=[0]
    position=[[0,0] for i in range(n)]
    for i in range(1,n):
        x,y=map(int,input().split())
        if y==1:
            position[i][0]=position[x][0]
            position[i][1]=position[x][1]-1
            stack_y.append(position[i][1])
        elif y==3:
            position[i][0]=position[x][0]
            position[i][1]=position[x][1]+1
            stack_y.append(position[i][1])
        elif y==0:
            position[i][0]=position[x][0]-1
            position[i][1]=position[x][1]
            stack_x.append(position[i][0])
        elif y==2:
            position[i][0]=position[x][0]+1
            position[i][1]=position[x][1]
            stack_x.append(position[i][0])
    print(max(stack_x)-min(stack_x)+1,max(stack_y)-min(stack_y)+1)
    n=int(input())


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int d[N], ans, n, k;
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; i++) {
		int t;
		scanf("%d", &t);
		for (int j = 1; j <= t; j++) {
			int x;
			scanf("%d", &x);
			d[x]++;
		}
	}
	for (int i = 1; i <= n; i++)if (d[i] == 0)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll h,w;
        cin>>h>>w;
        ll arr[h][w];
        char c;
        for(ll i = 0; i < h ; i++)
        {
            for(ll j = 0; j < w; j++)
            {
                cin>>c;
                if(c == '.') arr[i][j] = 0;
                if(c == '#') arr[i][j] = -1; 
            }
        }
        arr[0][0] = 1;
        for(ll i = 0; i < h ; i++)
        {
            for(ll j = 0; j < w; j++)
            {
                if(arr[i][j]!=-1)
                {
                    if(i-1 >= 0 && arr[i-1][j]!=-1) arr[i][j] = (arr[i][j]%MOD + arr[i-1][j]%MOD)%MOD;
                    if(j-1 >= 0 && arr[i][j-1]!=-1) arr[i][j] = (arr[i][j]%MOD + arr[i][j-1]%MOD)%MOD;
                }
            }
        }
        cout<<arr[h-1][w-1]%MOD<<endl;
    }
    return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int a, b, c; cin >> a >> b >> c;
  int k; cin >> k;
  while(a >= b && k > 0) {
    b *= 2;
    --k;
  }
  while(b >= c && k > 0) {
    c *= 2;
    --k;
  }
  if(a < b && b < c) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3648
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N, X, T; cin >> N >> X >> T;
    pt((N + X - 1) / X * T);
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (s.substr(0, n / 2) == s.substr(n / 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
s = input()
n = len(s)
#print(s[:((n-1)//2)])
#print(s[((n-1)//2)-1::-1] )
#print(s[(n+3)//2-1:n] )
#print(s[n-1:(n+3)//2-2:-1])
if s[:((n-1)//2)] == s[((n-1)//2)-1::-1] and s[(n+3)//2-1:] == s[n-1:(n+3)//2-2:-1]:
    if s[:((n-1)//2)] == s[n-1:(n+3)//2-2:-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	rrep(i,n-1){
		if(a[i+1]<a[i]){
			a[i]--;
			if(a[i+1]<a[i]){
				puta("No");
				return 0;
			}
		}
	}
	puta("Yes");
	return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

dp =[[float('inf')]*W for _ in range(H)]
if field[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if i>0:
            dp[i][j] = min(dp[i][j], dp[i-1][j] + (field[i-1][j]=='.' and field[i][j]=='#'))
        if j>0:
            dp[i][j] = min(dp[i][j], dp[i][j-1] + (field[i][j-1]=='.' and field[i][j]=='#'))
print(dp[H-1][W-1])

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

/*used, gone はスタック*/

int N, M;
int *gone, *used;
int **side;

int culc_pass(int top, int count);

int main(void)
{
  int i, answer;


  /*入力*/
  scanf("%d %d", &N, &M);

  /*辺の格納用の動的配列の作成*/
  side = (int**)malloc(sizeof(int*) * M);
  if (side == NULL) printf("MEMORY ERROR OF side");
  for (i=0;i<M;i++) {
    side[i] = (int*)malloc(sizeof(int) * 2);
    if (side[i] == NULL) printf("MEMORY ERROR OF side %d", i);
  }

  /*辺の入力*/
  for (i=0;i<M;i++) {
    scanf("%d %d", &side[i][0], &side[i][1]);
  }

  /*行った頂点を記憶する配列と、使った辺を記憶する配列を作成*/
  gone = (int*)malloc(sizeof(int) * N);
  if (gone == NULL) printf("MEMORY ERROR OF gone");
  used = (int*)malloc(sizeof(int) * (N - 1));
  if (used == NULL) printf("MEMORY ERROR OF used");

  /*探索*/
  gone[0] = 1;
  answer = culc_pass(1, 1);

  /*出力*/
  printf("%d\n", answer);

  /*メモリ解放*/
  free(gone);
  free(used);

  for (i=0;i<M;i++) {
    free(side[i]);
  }
  free(side);

  return 0;
}


int culc_pass(int top, int count)
{
  int i, j, num, sum = 0, is_continue = 0;
  /*全部いけたらおｋ*/
  if (count == N) return 1;

  /*つぎいけるとこを探索*/
  for (i=0;i<M;i++) {
    /*頂点が今いるとこじゃなかったらだめ*/
    if (side[i][0] != top && side[i][1] != top) {
      continue;
    } else if (side[i][0] == top) {
      num = 1;
    } else {
      num = 0;
    }
    for (j=0;j<count;j++) {
      /*行ったことあったらだめ*/
      if (gone[j] == side[i][num]) is_continue = 1;
      if (j == count - 1) break;
      /*一回通った道だったらだめ*/
      if (used[j] == i) is_continue = 1;
    }
    if (is_continue) {
      is_continue = 0;
      continue;
    }
    /*いけるとこの結果を足し合わせる*/
    used[count - 1] = i;
    gone[count] = side[i][num];
    sum = sum + culc_pass(side[i][num], count + 1);
    used[count - 1] = 0;
    gone[count] = 0;
  }
  return sum;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll A,B;	cin>>A>>B;
	ll ans;
	ans=lcm(A,B);
	cout<<ans<<endl;
	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,c; cin >> a >> b >> c;
    int sa = a - b;
    cout << max(0,c-sa) << endl;
}


Measured memory_bytes: 256
h1,m1,h2,m2,k = map(int,input().split())
if m1 >= m2:
    H = (h2-h1-1)*60
    M = (60-(m1-m2))
else:
    H = (h2-h1)*60
    M = (m2-m1)
print(H+M-k)

Measured memory_bytes: 9176
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int -> Bool
solve n k an =
  VU.constructrN
      (k + 1)
      (\vec -> not $ VU.and $ VU.map
        (\a -> if a <= VU.length vec then vec VU.! (a - 1) else True)
        an
      )
    VU.! 0

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  putStrLn $ if solve n k an then "First" else "Second"


Measured memory_bytes: 1020
s = input()
l = list(s)

numl = []
for i in range(len(l) - 2):
    num = int(l[i] + l[i + 1] + l[i + 2])
    numl.append(num)

diffl = []
for i in numl:
    diff = abs(753 - i)
    diffl.append(diff)

print(min(diffl))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>

int main()
{
	std::uint32_t n;
	std::cin >> n;
	for (std::uint32_t i = 0; i < n; ++i) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if ((x1 - x2) * (y3 - y4) - (x3 - x4) * (y1 - y2) != 0.0) {
			std::cout << "NO" << std::endl;
		}
		else {
			std::cout << "YES" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
# coding: utf-8


def solve(*args: str) -> str:
    S, = args
    n_sep = len(S)-1
    b_max = 2**n_sep

    ret = 0
    for b in range(b_max):
        p = 0
        for i in range(n_sep):
            if b >> i & 1:
                ret += int(S[p:i+1])
                p = i+1
        ret += int(S[p:])

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3060
N = int(input())
ans=1
num=1
ans1=1
a=(10**9)+7
for i in range(N):
    ans*=10
    ans=ans%a
    num*=9
    num=num%a
    
for i in range(N):
    ans1*=8
    ans1=ans1%a


print((ans-2*num+ans1)%(10**9+7))

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

cities = [[] for i in range(N)]
for i in range(M):
    P, Y = map(int, input().split())
    cities[P - 1].append([Y, i])

for i in range(N):
    cities[i].sort()

city_ids = ["" for i in range(M)]

for P in range(N):
    for x in range(len(cities[P])):
        P_str = str(P + 1)
        x_str = str(x + 1)
        if len(P_str) < 6:
            P_str = "0" * (6 - len(P_str)) + P_str
        if len(x_str) < 6:
            x_str = "0" * (6 - len(x_str)) + x_str
        city_ids[cities[P][x][1]] = P_str + x_str

for i in range(M):
    print(city_ids[i])

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
  int n,k;
  sl(n);sl(k);
  int fact=k;
  for(int i=2;i<=n;i++){
	  fact=fact*(k-1);
  }
  cout<<fact<<endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> point(N);
  for (int i=0;i<N;i++){
    cin>>point.at(i);
  }
  sort(point.begin(),point.end(),std::greater<int>());
  int Alice,Bob;
  Alice=Bob=0;
  for (int i=0;i<N;i++){
    if (i%2==0){
      Alice+=point.at(i);
    }
    else{
      Bob+=point.at(i);
    }
  }
  cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
#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 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;
}
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(){
  string a;
  cin>>a;
  for(int i=0;i<a.size();i+=2)
    cout<<a[i];
  cout<<' '<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,n) cin>>a[i];
  ll cnt[100] = {};
  ll last = 0;
  for(ll i = 0; (ll)pow(2,i) <= k; i++) {
    ll t = (ll)pow(2,i);
    ll sum = 0;
    for(ll j = 0; j < n; j++) {
      sum += t & a[j];
    }
    if(sum <= n * t / 2) {
      cnt[i] = 1;
    }
    last = i;
  }
  for(ll i = last; i >= 0; i--) {
    ll p = k >> i & 1;
    if(p == 1 && cnt[i] == 0) {
      break;
    } else if(p == 0 && cnt[i] == 1) {
      cnt[i] = 0;
    }
  }
  ll tmp = 0;
  for(ll i = 0; i <= last; i++) {
    tmp += (ll)pow(2,i) * cnt[i];
  }
  ll ans = 0;
  rep(i,n) {
    ans += tmp ^ a[i];
  }
  cout << ans << endl;
  debug(ans);

  return 0;
}


Measured memory_bytes: 1024
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(n):
	total = 0
	for j in range(m):
		total += a[i][j] * b[j]
	total += c
	if total > 0:
		count += 1
print(count)

Measured memory_bytes: 3064