akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();

    int M = 1_000_000_007;

    long[] choose1 = chooseForN(H - A + B - 1, M);
    long[] choose2 = chooseForN(W - B + A - 1, M);
    long res = 0;
    for (int i = 0; i < Math.min(H - A, W - B); i++) {
      long d = choose1[H - A - 1 - i] * choose2[W - B - 1 - i];
      d %= M;
      res += d;
      res %= M;
    }
    System.out.println(res);
  }

  public static long[] chooseForN(int n, long mod) {
    long[] C = new long[n + 1];
    long[] fact = new long[n + 1];
    long[] factinv = new long[n + 1];

    fact[0] = 1;
    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (n - i) % mod;
    factinv[0] = 1;
    for (int i = 1; i <= n; i++) factinv[i] = factinv[i - 1] * inverse(i, mod) % mod;

    for (int i = 0; i <= n; i++) C[i] = fact[i] * factinv[i] % mod;

    return C;
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 25684
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();

    int n = s.length();
    int count = 0;
    for (int i = 0; i < n / 2; i++) {
      if (s.charAt(i) != s.charAt(n-i-1)) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 4e18, mod = 1e9 + 7;
int n,a,b,c,d,sum = 0;
vector<vi> dp;
vi fact, ifact;

int power(int b, int e){
    if(e == 0) return 1;
    if(e == 1) return b;
    int cur = power(b, e/2);
    return cur * cur % mod * (e%2?b:1) % mod;
}

int rec(int sz, int num){
    if(sz == a-1) return num == 0;
    if(dp[sz][num] != -1) return dp[sz][num];
    dp[sz][num] = rec(sz-1, num);
    for(int i=c;i<=d;i++){
        if(num - sz * i < 0) break;
        int cho = fact[num] * ifact[i*sz] % mod * ifact[num - i*sz] % mod;
        dp[sz][num] = (dp[sz][num] + cho * rec(sz-1, num - i * sz) % mod * fact[sz * i] % mod * power(ifact[sz], i) % mod * ifact[i] % mod) % mod;
    }
    return dp[sz][num];
}

void first_n_inverses(int n, int mod, vi &inv) // assign inv[i] for i=0,...,n
{
    inv.resize(n + 1);
    inv[0] = inv[1] = 1;
    for(int i=2;i<=n;i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    cin >> n >> a >> b >> c >> d;
    dp.resize(b+1,vi(n+1,-1));
    fact.resize(n+1);
    first_n_inverses(n,mod, ifact);
    fact[0] = 1;
    for(int i = 1;i<=n;i++) fact[i] = fact[i-1] * i % mod, ifact[i] = ifact[i-1] * ifact[i] % mod;
    cout << rec(b,n)<<endl;
    return 0;
}


Measured memory_bytes: 8320
n=int(input())
dp=[10**6]*(n+1)
dp[0]=0
for i in range(n+1):
	j=0
	while i-6**j>=0:
		dp[i]=min(dp[i-6**j]+1,dp[i])
		j+=1
	j=0
	while i-9**j>=0:
		dp[i]=min(dp[i-9**j]+1,dp[i])
		j+=1
print(dp[-1])





Measured memory_bytes: 3828
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;
typedef unsigned long long ull;

template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

int main() {
    cin.sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(a+b, min(b+c, a+c)) << endl;
    return 0;
}



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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
   int n, k;
   cin >> n >> k;
   vector<bool> b(n, false);

   rep(i, k) {
       int d;
       cin >> d;
       rep(j, d) {
           int a;
           cin >> a;
           b[a-1] = true;
       }
   }

   int ans = 0;
   rep(i, n) if(b[i] == false) ans += 1;

   cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  vll v(1010,0);
  for(int i=2;i<=N;++i){
    ll tmp=2;
    ll i_tmp = i;
    while(i_tmp>1){
      if(i_tmp%tmp==0){
        v[tmp]++;
        i_tmp/=tmp;
      }
      else tmp++;
    }
  }
  ll ans=1;
  ll mod=1e9+7;
  rep(i,N+1){
    if(v[i]>=1){
      ans *= v[i]+1;
      ans %= mod;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
#define MAX 500000
#define SENTINEL 1000000000
 
int L[MAX/2+1], R[MAX/2+1];
int cnt;
 
void merge(int A[], int left, int right, int mid){
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0, j = 0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(int A[], int left, int right){
  if(right - left > 1){
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, right, mid);
  }
}
 
int main(){
  int n;
  cin >> n;
  int S[MAX];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  mergeSort(S, 0, n);
  for(int i=0;i<n;i++){
    if(i != n-1) cout << S[i] << " ";
    else cout << S[i] << endl;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

void solve() {
  int N; cin >> N;
  string MARCH = "MARCH";
  vl initial(5, 0);
  rep(i,N) {
    string name; cin >> name;
    rep(j,5) {
      if (name[0] == MARCH[j]) ++initial[j];
    }
  }
  
  ll ans = 0;
  for (int i=0; i<3; ++i) {
    for (int j=i+1; j<4; ++j) {
      for (int k=j+1; k<5; ++k) {
        ans += initial[i] * initial[j] * initial[k];
      }
    }
  }

  cout << ans << endl;
  return;
}

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


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    return res ;
}
bool is_prime(long long n){
    if(n==2){
        return true ;
    }
    else if(n<2 || n%2==0){
        return false ;
    }
    else{
        long long i = 3 ;
        while(i*i<=n){
            if(n%i==0){
                return false ;
            }
            i += 2 ;
        }
        return true ;
    }
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n ;
    cin >> n ;
    vll a = factor_array(n);
    vll fac ;
    ll i = 1 ;
    ll ans = 0 ;
    while(i*(i-1)/2<=n){
        fac.PB(i*(i-1)/2) ;
        i++ ;
    }
    vll b ;
    REP(i,SZ(a)){
        if(is_prime(a[i])){
            b.PB(a[i]) ;
        }
    }
    vll c(SZ(b),0) ;
    REP(i,SZ(b)){
        ll m = n ;
        while(m%b[i]==0){
            m /= b[i] ;
            c[i]++ ;
        }
    }
    REP(i,SZ(c)){
        auto itr = LB(ALL(fac),c[i]) ;
        if(BS(ALL(fac),c[i])){
            ans += distance(fac.begin(),itr) ;
        }
        else{
            ans += distance(fac.begin(),itr) - 1  ;
        }
        
    }

    cout << ans <<endl;




    

    return 0;
}



Measured memory_bytes: 19740
#include <bits/stdc++.h>
#define MOD  1000000007;
using namespace std;
char arr[1005][1005];
int dp[1005][1005];

long long cal_ways(int x,int y,int i,int j)
{
    if(dp[i][j]!=-1)
    return dp[i][j]% MOD;
    if(i>x||j>y|| arr[i][j]=='#')
    return dp[i][j]=0;
    if(i==x && j==y )
    return dp[i][j]=1;
    else
    {
    	dp[i][j]=cal_ways(x,y,i+1,j)+cal_ways(x,y,i,j+1);
return dp[i][j]%MOD;
    }
    }

int main()
{
    memset(dp,-1,sizeof(dp));
    int x,y;
    cin>>x>>y;
    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=y;j++)
        cin>>arr[i][j];
    }
    cout<<cal_ways(x,y,1,1);
    
    return 0;
}


Measured memory_bytes: 8636
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = a + b - c - d;
    if (x > 0) {
        cout << "Left" << endl;
    }
    else if (x < 0) {
        cout << "Right" << endl;
    }
    else
        cout << "Balanced" << endl;

    return 0;
}

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

#define MAX 10000
char C[MAX + 2];
int n, m;
void setLeft(char ch) {
	for (int i = 1;; i++) {
		if (C[i] == '#') {
			C[i] = ch;
			return;
		}
	}
}
void setB() {
	for (int i = n; i >= 1; i--) {
		if (C[i] == '#' && C[i - 1] != 'A' && C[i + 1] != 'A') {
			C[i] = 'B';
			return;
		}
	}
	setLeft('B');
}
bool isEmpty() {
	for (int i = 1; i <= n; i++)
		if (C[i] != '#')
			return false;
	return true;
}
void setC() {
	if (isEmpty()) {
		C[n / 2 + 1] = 'C';
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (C[i] == '#')
			continue;
		if (C[i + 1] == '#') {
			C[i + 1] = 'C';
			return;
		}
		if (C[i - 1] == '#') {
			C[i - 1] = 'C';
			return;
		}
	}
}
int getDist(int p) {
	int l = 0, r = 0;
	while (C[p + l - 1] == '#')
		l--;
	if (C[p + l - 1] == 'X')
		l = -1000000;
	while (C[p + r + 1] == '#')
		r++;
	if (C[p + r + 1] == 'X')
		r = 1000000;
	return min((-1) * l, r);
}
void setD() {
	if (isEmpty()) {
		C[1] = 'D';
		return;
	}
	int d, mi, md = -1;
	for (int i = 1; i <= n; i++) {
		if (C[i] != '#')
			continue;
		d = getDist(i);
		if (d > md) {
			md = d;
			mi = i;
		}
	}
	C[mi] = 'D';
}
main() {
	char ch;
	while( cin >> n >> m && n && m ) {
		for(int i = 0;i<=n+1;i++) C[i] = '#';
		C[0] = C[n+1] = 'X';
		for(int i = 1;i<=m;i++) {
			cin >> ch;
			if ( ch == 'A' ) setLeft('A');
			else if ( ch == 'B' ) setB();
			else if ( ch == 'C' ) setC();
			else if ( ch == 'D' ) setD();
		}
		for(int i = 1;i<=n;i++) cout << C[i];
		cout << endl;
	}
}

Measured memory_bytes: 2976
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    ll H, W, N; cin >> H >> W >> N;
    vi A(N), B(N); 
    REP(i, N) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    map<pii, int> mp;
    REP(i,N) {
        for (int x = A[i]-1; x <= A[i]+1; x++) {
            for(int y = B[i]-1; y <= B[i]+1; y++) {
                if (0 < x && x < H-1 && 0 < y && y < W-1) {                   
                    mp[pii(x,y)]++;
                }
            }
        }
    }

    vl h(10, 0);
    ll nonZero = 0;
    for (auto p : mp) {
        h[p.second]++;
        nonZero++;
    }

    h[0] = (H - 2)*(W - 2) - nonZero;

    for (ll i : h) cout << i << endl;

    return 0;
}

Measured memory_bytes: 57344
n, k, q = input().split()
n, k, q = [int(n), int(k), int(q)]
d = dict()
for i in range(0, n):
    d[i+1] = 0

for i in range(0, q):
    A = int(input())
    d[A] += 1
for i in range(0, n):
    times = d[i+1]
    if (k-q+times)>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2.0 << endl;

}

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

int main() {
  	int K,S;
    cin >> K >> S;
  
  	int ans = 0;
  
  	for(int A = 0; A <= K; A++) {
    	for(int B = 0; B <= K; B++) {
        	int C = S - A - B;
          	if(C >= 0 && C <= K) ans++;
        }
    } 
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, Y: int):
    distances = [0] * (N - 1)
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            distance = min(j - i, abs(X - 1 - i) + abs(Y - 1 - j) + 1)
            distances[distance - 1] += 1

    for k in distances:
        print(k)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>

using namespace std;



int main(){

    int a,b;

    cin>>a>>b;

    int N;

    cin>>N;

    bool flag=0;

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

        int s,f;

        cin>>s>>f;

        if((a<f&&b>s)||(s<b&&f>a))flag=1;

    }

    cout<<flag<<endl;

    return 0;

}


Measured memory_bytes: 3104
#include<cstdio>
int main(void){
	int x[100000];
	int y[100000][101];
	int n;
	int q;
	int l;
	int o;
	int p;
	int a, b,c;
	int z;
int zz;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	scanf("%d", &l);
	scanf("%d", &q);
	o = 0;
	p = 0;
	for (; o< n;){
		if (p == n){
			y[o][1] = p - 1;
			o++;
		}
		else if (x[o] + l < x[p]){
			y[o][1] = p - 1;
			o++;
		}
		else {
			p++;
		}
	}
	for (int i = 2; i < 101; i++){
		for (int j = 0; j < n; j++){
			y[j][i] = y[y[j][i - 1]][1];
		}
	}
		for (int qq = 0; qq < q; qq++){
		scanf("%d %d", &a, &b);
		a--;
		b--;
		if (a > b){
			z=b;
b=a;
a=z;
		}
			c = 0;
			z = a;
			for (; z < b;){
				zz = y[z][100];
				if (zz<b){
 c=c+100;
z=zz;
}
				else{
					for (int i = 1; z < b; i++){
						z = y[z][1];
					c++;
					}
				}
			}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 40576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
const int NN = 320;
int n, _n;
ll s[N], ans;
V<ll> m[NN][NN];
ll _sum(int f, int e, int d){
  if(d < NN){
    int _f = f%d;
    return m[d][_f][e/d+1] - m[d][_f][f/d];
  }
  ll t = 0;
  for(int k=f; k<=e; k+=d) t += s[k];
  return t;
}
void check(int a, int b){
  if((a-b)%b || (a-b)/b>=_n/b) maxs(ans, _sum(0, _n, b) + _sum(a, n, b));
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> s[i];
  FOR(i, 1, NN) FOR(j, 0, i){
    m[i][j].pb(0ll);
    ll t = 0;
    for(int k=j; k<n; k+=i){
      t += s[k];
      m[i][j].pb(t);
    }
  }
  _n = --n;
  FOR(a, 1, n){
    _n--;
    for(int b=1; b*b<=_n && b<a; b++) if(_n%b==0) {
      check(a, b);
      if(_n/b < a) check(a, _n/b);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int m,d;cin>>m>>d;
    int cnt=0;
    for(int i=4;i<=m;++i){
        for(int j=22;j<=d;++j){
            int dd= j -(j/10)*10;
            int d10=(j-dd)/10;
            if (dd>=2 && dd*d10==i) ++cnt;
        }
    }
    cout << cnt;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
10 9
0 1
0 2
3 4
5 7
5 6
6 7
6 8
7 8
8 9
3
0 1
5 9
1 3

output:
yes
yes
no

"""

import sys


def assign_color():
    v_color = 0
    for v in range(v_num):
        if color[v] == -1:
            graph_dfs(v, v_color)
            # use int as color to represent different connected groups
            v_color += 1
    return None


def graph_dfs(current, v_color):
    stack = list()
    stack.append(current)
    color[current] = v_color

    while stack:
        current = stack.pop()
        for adj in adj_table[current]:
            if color[adj] == -1:
                color[adj] = v_color
                stack.append(adj)
    return None


def solve():
    for edge in edges:
        source, target = map(int, edge)
        adj_table[source].append(target)
        adj_table[target].append(source)

    assign_color()

    for question in questions:
        q_source, q_target = map(int, question)
        if color[q_source] == color[q_target]:
            print("yes")
        else:
            print("no")

    return color


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, r_num = map(int, _input[0].split())

    edges = map(lambda x: x.split(), _input[1:r_num + 1])

    q_num = int(_input[r_num + 1])
    questions = map(lambda x: x.split(), _input[r_num + 2:])

    adj_table = tuple([] for _ in range(v_num))
    color = [-1] * v_num
    ans = solve()

Measured memory_bytes: 35104
#include<iostream>
#include<cstdio>
using namespace std;
#define N 10000012
#define mod 998244353
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k){int res=1;while(k){if(k&1)res=1ll*res*p%mod;k>>=1;p=1ll*p*p%mod;}return res;}
int n,fac[N],inv[N],ans,ans1,P[N];
int main(){
	P[0]=1;for(int i=1;i<N;i++)P[i]=M(P[i-1]<<1);
	fac[0]=1;for(int i=1;i<N;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-1]=ksm(fac[N-1],mod-2);for(int i=N-2;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	scanf("%d",&n);ans=ksm(3,n);int i;
	for(i=(n>>1)+1;i<=n;i++)ans1=(ans1+1ll*inv[i]*inv[n-i]%mod*P[n-i])%mod;
	ans1=1ll*ans1*fac[n]%mod;ans=M1(ans-M(ans1<<1));printf("%d",ans);return 0;
}

Measured memory_bytes: 117376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    ll a, b, c, x;
    cin >> a >> b >> c >> x;
    cout << (a-b)*(x%2==1 ? -1 : 1) << endl;
}
/*

a b c                   a-b                 a-b
b+c a+c a+b             b+c-(a+c)           a-b
2a+b+c a+2b+c a+b+2c    2a+b+c-(a+2b+c)     a-b

*/

Measured memory_bytes: 3616
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String key = "keyence";
		int left = 0;
		int right = 0;
		int n = 0;
		while(n<key.length()){
			if(S.charAt(n) == key.charAt(n)){
				n++;
			}else{
				break;
			}
		}
		left = n;
		n=0;
		while(n<key.length()){
			if(S.charAt(S.length()-1-n) == key.charAt(key.length()-1-n)){
				n++;
			}else{
				break;
			}
		}
		right = n;
		
		if(left + right >= 7){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& w : a) cin >> w;
  int sum = 0, mn = 1e9, odd = 0;
  // bool exists0 = false;
  //   for (auto&& w : a)
  //     if (w == 0ll) {
  //       exists0 = true;
  //       break;
  //     }
  for (auto&& w : a) {
    sum += abs(w);
  }
  for (auto&& w : a) {
    mn = min(mn, abs(w));
  }
  for (auto&& w : a) {
    if (w < 0) odd++;
  }

  if (odd % 2 == 0 || mn == 0ll) {
    cout << sum << endl;
  } else {
    cout << sum - 2 * mn << endl;
  }

  //  cout << sum << " " << mn << " " << odd << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int main(void){
    int N;
    scanf("%d",&N);
    
    int i, a[N];
    for(i = 0;i < N;i++){
        scanf("%d",&a[i]);
    }

    qsort(a, N, sizeof(int), compare_int);
    int P_a = 0, P_b = 0, j;
    for(j = 0;j < N;j++){
        switch (j % 2){
            case 0:
            P_a +=a[j];
            break;
            
            case 1:
            P_b +=a[j];
            break;
        }
    }
    printf("%d",P_a - P_b);
    return 0;
}

Measured memory_bytes: 128
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto r = N - M;
	writeln(pow(2, M) * (M* 1900 + r * 100));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll a, b, q;
    cin >> a >> b >> q;

    vector<ll> s(a);
    vector<ll> t(b);

    for(int i = 0; i < a; i++) cin >> s[i];
    for(int i = 0; i < b; i++) cin >> t[i];

    vector<ll> qu(q);
    for(int i = 0; i < q; i++) cin >> qu[i];

    for(int i = 0; i < q; i++){
        ll ans = INF;
        ll pos = qu[i];
        ll snearl = lower_bound(s.begin(), s.end(), pos) - s.begin() - 1;
        ll snearu = snearl + 1;
        ll tnearl = lower_bound(t.begin(), t.end(), pos) - t.begin() - 1;
        ll tnearu = tnearl + 1;

        // cout << snearl << endl;
        // cout << snearu << endl;
        // cout << tnearl << endl;
        // cout << tnearu << endl;

        if(snearl >= 0 && tnearl >= 0){
            ans = min(ans, max(abs(pos - s[snearl]), abs(pos - t[tnearl])));
        }

        if(snearu < a && tnearu < b){
            ans = min(ans, max(abs(pos - s[snearu]), abs(pos - t[tnearu])));
        }

        if(snearl >= 0 && tnearu < b){
            ans = min(ans, abs(pos - s[snearl]) * 2 + abs(pos - t[tnearu]));
            ans = min(ans, abs(pos - s[snearl]) + abs(pos - t[tnearu]) * 2);
        }

        if(snearu < a && tnearl >= 0){
            ans = min(ans, abs(pos - s[snearu]) * 2 + abs(pos - t[tnearl]));
            ans = min(ans, abs(pos - s[snearu]) + abs(pos - t[tnearl]) * 2);
        }

        cout << ans << endl;
    }


    
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int has[1000005];
int mark[1000005];
signed main(){
    int n;
    cin >> n;
    int arr[n];
    map<int, int> mp;
    for(int i=0; n>i; i++){
        cin >> arr[i];
        mp[arr[i]]++;
    }
    sort(arr, arr+n);
    for(int i=0; n>i; i++){
        if(has[arr[i]] == 0 && mark[arr[i]] == 0){
            mark[arr[i]] = 1;
            for(int j=2*arr[i]; 1000000>=j; j+=arr[i]){
                has[j] = 1;
            }
        }
    }
    int ans = 0;
    for(int i=0; n>i; i++){
        if(has[arr[i]] == 0 && mp[arr[i]] == 1){
            ans++;
        }
    }
    cout << ans << endl;
}






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

bool dp[100005];
int arr[100005];
int n,k;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>arr[i];

    for(int i=1;i<=k;i++){
        dp[i]=0;
        for(int j=1;j<=n;j++)
            if(i>=arr[j] && !dp[i-arr[j]])
                    dp[i]=1;
    }
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
        return 0;
}


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

const int N = 1e6 + 5;

#define st first
#define nd second

typedef pair<int,int> pun;
typedef long long ll;

int number[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		int a;
		scanf("%d", &a);
		if (a > 0) number[a-1] ++;
		number[a] ++;
		number[a+1] ++;
	}
	int wynik = 0;
	for (int i = 0; i < N; i ++) {
		wynik = max(wynik, number[i]);
	}
	printf("%d\n", wynik);
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  int n, a, b; cin >> n >> a >> b;
  if (abs(b - a) % 2 == 1) cout << "Borys" << endl;
  else cout << "Alice" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)  {
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
      
  if ((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H)  {
    printf("Yes\n");
  }
  
  else  
    printf("No\n");
 
  return 0; 
}

Measured memory_bytes: 1816
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  int p[11111];
  int sum;
  while(1){
    cin>>n>>m;
    sum=0;
    if(n+m==0) break;
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    sort(p,p+n,greater<int>());
    for(int i=0;i<n;i++){
      sum=sum+p[i];
      if((i+1)%m==0){
	sum=sum-p[i];
      }
    }
    
    cout<<sum<<endl;
  }
}

      

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001

using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
const int INF=1e9;
const ll LINF=1e18;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


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


int main(){
    int n;
    cin>>n;
    int op=n/2*2+1;
    int cnt=0;
    if(n%2==0)cnt=n*(n-2)/2;
    else cnt=((n-1)*(n-2)+(n-1))/2;
    cout<<cnt<<endl;
    arep(i,1,n+1){
        arep(j,1,i){
            if(i==j||i+j==op)continue;
            cout<<i<<" "<<j<<endl;

        }
    }
    return 0;
}

Measured memory_bytes: 256
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {  
  int a;
  cin >> a;
  int k =0;
  vector<int>n(10000000);
  int flag=0;
  for(;;){//for
    if(a%2==0){
      n.at(k) = a;
      a = a/2;
	  k++;
    }
    else if(a%2==1){
      n.at(k) = a;
      a = 3*a+1;
      k++;
	}
  
  rep(i,k) {
    if(a == n.at(i)) {
      cout <<i + 4 <<endl;
      flag =1;
      break;
    }
  }
   if(flag==1)break; 
 }//for
}

Measured memory_bytes: 39296
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        int n, k;
        cin >> n >> k;
        cout << n - k + 1 << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
}
mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint choose(ll n, ll r){
    mint mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
    }   
    return mul / div;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;;
    mint x = 2;
    mint ans = x.pow(n) - choose(n, a) - choose(n, b) - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long base = 7;
  for(int i = 1; i < 1000000; i++){
    base %= N;
    if(base == 0){
      cout << i << endl;
      return 0;
    }
    base *= 10;
    base += 7;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3600
s=input()
k=int(input())
n=len(s)
ans=[]
for i in range(n):
    for j in range(i+1,i+k+1):
        ans.append(s[i:j])
ans=list(set(ans))
ans.sort()
if "" in ans:
    ans.pop(0)
print(ans[k-1])


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

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

  else{
    cout << "NO" << endl;
  }
}


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



using namespace std;

int main()
{
    int n;
  	vector<int> h;
  	int cost[1000000];
  	int dp[100000];
  	
    cin >> n; cin.ignore();
    for (int i = 0; i < n; i++) {
        int k,l,m;
        cin >> k >>l>>m; cin.ignore();
        h.push_back(k);
      	h.push_back(l);
	    h.push_back(m);
    }
  	
  	for(int i = 0; i<3; i++){
      cost[i] = h[i];
    }
  	dp[0] = max({cost[0],cost[1],cost[2]}); 	
  
  	for(int i = 1; i<n; i++){
	  cost[3*i] = h[3*i]+max(cost[3*(i-1)+1],cost[3*(i-1)+2]);
      cost[3*i+1] = h[3*i+1]+max(cost[3*(i-1)],cost[3*(i-1)+2]);
      cost[3*i+2] = h[3*i+2]+max(cost[3*(i-1)],cost[3*(i-1)+1]);
      dp[i] = max({cost[3*i],cost[3*i+1],cost[3*i+2]}); 
    }
    cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 4976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

int main() {
ll N;
  ll M;
    ll X;
  cin >>N>>M>>X;
  
  ll A[N][M];
  vl C(N);
  rep(i,N) {
    cin >>C.at(i);
rep(j,M) {
  cin >>A[i][j];
}
  }

 ll sum=10000000;
  for(int bit=0; bit<(1<<N); ++bit) {
    vl ps(M);
    rep(i,M) {
ps.at(i)=0;
    }
    ll fin=0;
    
    rep(i,N) {
if(bit&(1<<i)) {
  
  rep(k,M) {
ps.at(k)+=A[i][k];
  }
  fin+=C.at(i);
  
}
    }
    
    ll s=1;
    rep(k,M) {
if(ps.at(k)<X) {
  s=0;
  break;
}
    }

    if(s==0) {
continue;
    }
else {
sum=min(sum,fin);
}
    
    
  }
  
  
  
  if(sum==10000000)  {
cout<<-1<<endl;
}
 else {
cout<<sum<<endl;
}
}
    
 

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long a[3],aa[3];
	scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
	for(int i = 0;i < 1000000;i++)
	{
		for(int j = 0;j < 3;j++)
		{
			if(a[j]%2==1)
			{
				printf("%d",i);
				return 0;
			}
			aa[j]=a[j]/2;
		}
		a[0]=aa[1]+aa[2];
		a[1]=aa[0]+aa[2];
		a[2]=aa[0]+aa[1];
	}
	printf("-1");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
long double PI = acosl(-1);
const ll inf = 1e18;
//const int inf = 2e9+100;
const int nmax = 3e5+10;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ost;


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

    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0) cout<<(b-a)/2<<"\n";
    else cout<< min(a, n-b+1) + (b-a-1)/2 <<"\n";
}


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

int main(){
  double a,b,x;cin >> a >> b >> x;
  if( 2*x <= a*a*b ){
    double c = 2.0*x/a/b;
    cout << fixed << setprecision(10) << atan(b/c)/(2*M_PI)*360.0;
  }else{
    double c = 2.0*b-2.0*x/a/a;
    cout << fixed << setprecision(10) << atan(c/a)/(2*M_PI)*360.0;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4020
#include<iostream>
#include<string>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	bool flag(true);
	for (int i(0); i < (s.size() - 1) / 2; i++) {
		if (s[i] != s[s.size() - i - 1]) flag = false;
	}
	for (int i(0); i < (s.size() - 1) / 4; i++) {
		if (s[i] != s[(s.size() - 1) / 2 - i - 1])flag = false;
	}
	for (int i(0); i < (s.size() - 1) / 4; i++) {
		if (s[(s.size() + 3) / 2 + i - 1] != s[s.size() - i - 1])flag = false;
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int a,b;
  for(int i=0;i<1101;i++){
    a=i*0.08;
    b=i*0.1;
    if(a==A&&b==B){
      cout<<i<<endl;
      return 0;
    }
    else{
      continue;
    }
  }
  cout<<"-1"<<endl;
}

Measured memory_bytes: 256