akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int N, K;
int A[100010];
ll B[100010];

ll buy(ll L) {
    ll val = 0;
    for (int i = 0; i < N; ++i) {
        if (((L ^ A[i]) | L) == L) {
            val += B[i];
        }
    }

    return val;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    ll ans = buy(K);
    for (int b = 0; b < 30; ++b) {
        if ((K >> b) & 1) {
            ll L = (K ^ (1 << b));
            L |= (1 << b) - 1;
            ans = max(ans, buy(L));
        }
    }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


bool cmp0(const pii a, const pii b) {
    return a.second < b.second;
}
bool cmpP(const pii a, const pii b) {
    return 1LL * b.first * (a.second + 1) < 1LL * a.first * (b.second + 1);
}

const int MAXN = 2e5+5;
const int LOGT = 40;
ll dp[LOGT+5];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n,T; cin>>n>>T;
    vpii shop = READ<pii>(n);
    vpii shop0, shopP;

    for(auto s : shop)
    {
        if(s.first)
            shopP.push_back(s);
        else
            shop0.push_back(s);
    }

    sort(ALL(shop0), cmp0);
    sort(ALL(shopP), cmpP);

    memset(dp, 0x70, sizeof dp);
    dp[0]=0;

    FOR(i,shopP.size()) {
        REV(k, LOGT, 0) {
            if(dp[k] > T) continue;
            ll enter = dp[k]+1;
            ll time = shopP[i].first * enter + shopP[i].second;
            dp[k+1] |= MIN(enter+time);
        }
    }

    int ans = 0;

    FOR(k, LOGT) {
        int leave = dp[k];
        if(leave <= T)
            ans |= MAX(k);
        FOR(i, shop0.size()) {
            leave += 1 + shop0[i].second;
            if(leave <= T)
                ans |= MAX(k + i + 1);
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 4596
def main():
    A, B = map(int,input().split())
    
    want_num = B - A

    if want_num % (A-1) == 0:
        print(int(1+want_num/(A-1)))
    else:
        print(int(2+want_num//(A-1)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "No";
    if((s.charAt(2) == s.charAt(3)) && (s.charAt(4) == s.charAt(5))) ans = "Yes";
    System.out.println(ans);
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
typedef long long ll;

int n, m;
int P[100000], Y[100000];
vector<int> yd[100001];



void solve(){}

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

  rep(i, m){
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }

  rep(i, n){
    sort(yd[i+1].begin(), yd[i+1].end());
  }

  rep(i, m){
    //lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()
    //先頭からの距離を返す
    ll id = ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
    cout << setfill('0') << right << setw(12) << id << endl;
  }

  solve();
}

Measured memory_bytes: 7808
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right


def resolve():
    N = int(input())
    XY = [tuple(map(int, input().split())) + (i,) for i in range(N)]
    XY.sort()
    root = int(math.sqrt(N))

    low = [x for x, y, id in XY[::root]]
    high = [x for x, y, i in XY[root - 1::root]] + [float('inf')]

    XY = [sorted(XY[i:i + root], key=itemgetter(1)) for i in range(0, N, root)]
    XY = [([y for x, y, i in xyi], xyi) for xyi in XY]
    Q = int(input())
    for _ in range(Q):
        sx, tx, sy, ty = map(int, input().split())
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = XY[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <= tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str, ret)))
        print()

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 93228
/**
 * 
 */
import java.util.*;
import java.util.regex.Pattern;
import java.io.*;
/**
 * @author afterCmidday
 *
 */
class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final double eps = 1e-100;
		Scanner scan = new Scanner(System.in);
		double[] x = new double[4], y = new double[4];
		while(scan.hasNext()){
			String str = scan.next();
			for(int i = 0;i < 4;i++){
				x[i] = Double.parseDouble(str.substring(0,str.indexOf(",")));
				str = str.substring(str.indexOf(",") + 1);
				if(str.indexOf(",") == -1){
					y[i] = Double.parseDouble(str.substring(0,str.length()));
					str = str.substring(str.indexOf(",") + 1);
				}else{
					y[i] = Double.parseDouble(str.substring(0,str.indexOf(",")));
					str = str.substring(str.indexOf(",") + 1);
				}
			}
			boolean b1 = true, b2 = true;
			for(int i = 0;i < 4;i++){
				double vax = x[(i + 1) % 4] - x[i], vay = y[(i + 1) % 4] - y[i];
				double vbx = x[(i + 3) % 4] - x[i], vby = y[(i + 3) % 4] - y[i];
				if(vax * vby - vay * vbx < 0){
					b1 = false;
				}else{
					b2 = false;
				}
			}
			if(b1 || b2){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			
		}
	}

}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int add(int x, int y, int mod) {
   if (y >= mod) y %= mod;
   if (x >= mod) x %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
	x %= mod;
  }
  return (x < 0 ? x+mod : x);
}
int PowerMod(int x, int n, int mod) {
  int res = 1;
  for (;n > 0;) {
	if (n & 1) {
	  res 	= mul(res, x, mod);
	}
	x = mul(x, x, mod);
	n /= 2;
  }
  return res;
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n,k;
		cin >> n >> k ;
		for(int i =k;i>=1;i--){
			int tot_multp = k/i;
			dp[i]= PowerMod(tot_multp,n,MOD);
			// avoid overcounting .. so remove multiples..
			int extra= 0 ;
			for(int j=2*i;j<=k;j+=i){
				extra = add(extra, dp[j],MOD);
			} 
			dp[i] =sub(dp[i],extra,MOD);
		}
		int ans=0;
		for(int i =1;i<=k;i++){
			ans = add(ans,mul(i,dp[i],MOD),MOD);
		}
		cout << ans;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n;
vi in;

int main(){
  scanf("%d", &n);
  in.resize(3 * n);
  for(int& e : in) scanf("%d", &e);
  sort(all(in));

  ll ans = 0;
  for(int i = 0, p = sz(in) - 2;i < n;++i, p -= 2)
    ans += in[p];

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1408
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
#define AC io()
const int mod = 1000000007;
//endregion

int n;
ll aa, ps[300005], ans, anss, z, o;

ll modd (ll a, ll b) {
    ll res = 0;
    a = a qmod;
    while (b>0) {
        if (b%2 == 1) res = (res+a) qmod;
        a = (a*2) qmod;
        b /= 2;
    }
    return res qmod;
}
pls give {
    AC;
    cin >> n;
    for (int i=0; i<n; i++) cin >> ps[i];
    for (int i=0; i<60; i++) {
        z = o = anss = 0;
        for (int j=0; j<n; j++) {
            if (ps[j]%2 == 0) z++;
            else o++;
            ps[j] /= 2;
        }
        anss = (o*z) qmod;
        anss = (anss * ((long long)(pow(2, i)) qmod)) qmod;
        ans = (ans+anss) qmod;
    }
    cout << ans;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

struct Res{
  string Name;
  int po;
  int num;
};

Res Rest[100];

int comp(Res G,Res H){
    if(G.Name<H.Name){
        return 0;
    }else if(G.Name>H.Name){
        return 1;
    }
    if(G.po>H.po){
        return 0;
    }
    return 1;
}

signed main(void){
    int N;
    string S[104];
    int P[104];
    cin >> N;
    REP(i,N){
        cin >> S[i]  >> P[i];
        Rest[i].Name=S[i];
        Rest[i].po=P[i];
        Rest[i].num=i+1;
    }
    sort(Rest,Rest+N,comp);
    RREP(i,N){
        cout << Rest[i].num << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
S=input()
if S=='SUN':
  print('7')
elif S=='MON':
  print('6')
elif S=='TUE':
  print('5')
elif S=='WED':
  print('4')
elif S=='THU':
  print('3')
elif S=='FRI':
  print('2')
else:
  print('1')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>

using namespace std;

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

    long long count_R = count(S.cbegin(), S.cend(), 'R');
    long long count_G = count(S.cbegin(), S.cend(), 'G');
    long long  count_B = count(S.cbegin(), S.cend(), 'B');

    /*cout << count_R << endl;
    cout << count_G << endl;
    cout << count_B << endl;*/

    char ch1;
    char ch2;
    char ch3;
    long long  count = 0;

    for (int i = 0; i < N; i++) {
        ch1 = S[i];
        for (int j = i + 1; j < N; j++) {
            if (ch1 != S[j]) {
                ch2 = S[j];
                int k = j + (j - i);
                if (k < N) {
                    if ((S[k] != ch1) && (S[k] != ch2))count++;
                }
            }
        }
    }

    cout << count_R * count_G * count_B - count << endl;

    return 0;
}

Measured memory_bytes: 3524
#include <cstdio>

#define maxn 200010
struct Edge {
	Edge *next;
	int to;
} *last[maxn], e[maxn << 1], *ecnt = e;
char s[maxn];
int cnt[maxn][2];
inline void link(int a, int b)
{
	++cnt[b][s[a] == 'B'];
	*++ecnt = (Edge) {last[a], b}; last[a] = ecnt;
}
bool del[maxn];
int q[maxn];
int main()
{
	int n, m; scanf("%d%d", &n, &m); scanf("%s", s + 1);
	for (int i = 1; i <= m; ++i)
	{
		int a, b; scanf("%d%d", &a, &b);
		link(a, b); link(b, a);
	}
	int head = 0, tail = 0;
	for (int i = 1; i <= n; ++i) if (!cnt[i][0] || !cnt[i][1]) del[q[++tail] = i] = 1;
	while (head < tail)
	{
		int now = q[++head];
		for (Edge *iter = last[now]; iter; iter = iter -> next)
		{
			--cnt[iter -> to][s[now] == 'B'];
			if (!del[iter -> to] && !cnt[iter -> to][s[now] == 'B']) del[q[++tail] = iter -> to] = 1;
		}
	}
	puts(tail == n ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int x,y;
  cin>>x>>y;
  int ans=1000000005;
  if(x<=y){ans=min(ans,y-x);}
  if(-x<=y){ans=min(ans,y+x+1);}
  if(x<=-y){ans=min(ans,-y-x+1);}
  if(-x<=-y){ans=min(ans,-y+x+2);}
  cout<<ans<<endl;
  return 0;
}

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

#define lli long long int
#define li long int
#define ld long double
#define fasttrack ios_base::sync_with_stdio(false)

int main()
{
    string s;
    getline(cin,s);
    int len=s.size();

    if(s[len-1]=='s')
    {
        cout<<s<<"es";
    }
    if(s[len-1]!='s')
    {
        cout<<s<<"s";
    }
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

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

void Main() {
  int n;
  cin >> n;
  vector<int> A(n+1), B(n);
  rep(i, n+1) cin >> A[i];
  rep(i, n) cin >> B[i];
  ll ans = 0;
  rep(i, n) {
    if (A[i] > B[i]) {
      ans += B[i];
      A[i] -= B[i];
      B[i] = 0;
    } else {
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
    }
    if (B[i]) {
      if (A[i+1] > B[i]) {
        ans += B[i];
        A[i+1] -= B[i];
        B[i] = 0;
      } else {
        ans += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1024
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>
using namespace std;
using dl=long long;

int main(){
    int n,k,ans=1,tmp=1;
    cin>>n>>k;
    ans=k*pow(k-1,n-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long ans = 0;
		long[][] ranges = new long[N][2];
		long[] lower = new long[N];
		long[] upper = new long[N];
		for (int i = 0; i < N; i++) {
			long A = input.nextLong();
			long B = input.nextLong();
			ranges[i][0]=A;
			ranges[i][1]=B;
			lower[i]=A;
			upper[i]=B;
		}
		Arrays.sort(lower);
		Arrays.sort(upper);
		if (N%2==0) {
			int L = N/2-1;
			int R = N/2;
			long uppermed = upper[L]+upper[R];
			long lowermed = lower[L]+lower[R];
			long ways = uppermed-lowermed+1;
			ans=Math.max(0, ways);
		}else {
			int index = N/2;
			ans=upper[index]-lower[index]+1;
			ans=Math.max(0, ans);
		}
		System.out.println(ans);
	}	
}

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

int main(void) {
    string s;
    char a,b,c;
    cin >> s;
    a = s[0];
    b = s[1];
    c = s[2];
    if (a == '7' || b == '7' || c == '7') cout << "Yes";
    else cout << "No";
    
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l; 
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for ( int i = g; i < n; i++ ) {
        int v = A[i];
        int j = i - g;
        while( j >= 0 && A[j] > v ) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    // 生成数列G = {1, 4, 13, 40, 121, 364, 1093, ...}
    for ( int h = 1; ; ) {
        if ( h > n ) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for ( int i = G.size()-1; i >= 0; i-- ) {  // 按逆序指定G[i] = g
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    // 使用更快的scanf函数进行输入
    for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
    cnt = 0;
    
    shellSort(A, n);
    
    cout << G.size() << endl;
    for ( int i = G.size() - 1; i >= 0; i-- ) {
        printf("%d", G[i]);
        if ( i ) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);
    
    return 0;
}
    


Measured memory_bytes: 7184
#include<iostream>
#include<vector>
#define moju (long long int)(1e9+7)
using namespace std;
int main() {
	int n, m;
	int i;
	long long int c, ans = 1;
	cin >> n >> m;
	if (m == 0) {
		vector<long long int> b(n);
		for (i = 0; i < n; i++) {
			if (i <= 1)b[i] = i + (long long int)1;
			else b[i] = (b[i - 1] + b[i - 2]) % moju;
			//cout << b[i] << endl;
		}
		cout << b[n - 1] << endl;
		return 0;
	}
	vector<long long int>a(m), b(n);
	for (i = 0; i < m; i++)cin >> a[i];
	for (i = 0; i < n; i++) {
		if (i <= 1)b[i] = i + (long long int)1;
		else b[i] = (b[i - 1] + b[i - 2]) % moju;
		//cout << b[i] << endl;
	}
	//cout << endl;
	for (i = 0; i <= m; i++) {
		if (i == 0)c = a[i] - 2;
		else if (i == m)c = n - a[i - 1] - 2;
		else c = a[i] - a[i - 1] - 3;

		if (c < 0)ans *= (c + 2);
		else ans = (ans * b[c]) % moju;
		//cout << ans << endl;
		//cout << b[c] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import collections

n = int(input())
s = [input() for x in range(n)]
m = int(input())
t = [input() for y in range(m)]
ans = 0

S = collections.Counter(s)
T = collections.Counter(t)

for k, v in S.items():
    tmp = 0
    tmp = v
    if k in T:
        tmp -= T[k]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string a,b;
  cin >> a >> b;
  
  int x = stoi(a+b);

  for(int i = 1; i < 1000;i++){
    if(x == i*i){
      cout << "Yes";
      return 0;
    }
  }
  
  cout << "No";  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
	int H;
	int W;
	int i;
	int j;
	
	H = 1;
	W = 1;
	
	while(1)
	{
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0)
		{
			break;
		}
		
		for(i = 0; i < H; i++)
		{
			for(j = 0; j < W; j++)
			{
				if((i + j) % 2 == 0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
		
	return 0;
}

Measured memory_bytes: 572
cards = list()
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
if len(cards) > 0:
    print("\n" .join(cards))

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

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

constexpr int INF = 1e5 + 10;

int main() {
  int N;
  cin >> N;
  int dp[N + 2];
  fill(dp, dp + N + 2, INF);

  dp[0] = 0;
  for (int i{0}; i <= N; ++i) {
    chmin(dp[i + 1], dp[i] + 1);
    for (int p{1}; i + p <= N; p *= 6) {
      chmin(dp[i + p], dp[i] + 1);
    }
    for (int p{1}; i + p <= N; p *= 9) {
      chmin(dp[i + p], dp[i] + 1);
    }
  }

  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 10000
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n;
	while(cin>>n,n){
		vector<string> s(n);
		set<string> s_set;
		for(auto&i:s)cin>>i;
		rep(i,n){
			bool ok=true;
			rep(j,n) ok&=(i==j or s[j].find(s[i])==-1);
			if(ok) s_set.insert(s[i]);
		}
		s.clear();
		for(auto&i:s_set)s.push_back(i);
		n=s.size();
		
		vvi a(n,vi(n,0));
		rep(i,n)rep(j,n){
			if(i==j) {
				a[i][j]=INF;
				continue;
			}
			int si=s[i].size(), sj=s[j].size();
			for(int p=min(si,sj)-1;p>0;p--){
				if(s[i].substr(si-p) == s[j].substr(0,p)){
					a[i][j]=-p; break;
				}
			}
		}
		vvi dp(1<<n,vi(n,INF));
		rep(i,n) dp[1<<i][i]=0;

		rep(st,(1<<n)){
			rep(i,n) if(dp[st][i]!=INF) rep(j,n){
				if(st & (1<<j))  continue;
				int next=st|(1<<j);
				int cost=dp[st][i]+a[i][j];
				dp[next][j]=min(dp[next][j], cost);
			}
		}
		
		int ans=*min_element(all(dp[(1<<n)-1]));
		for(auto i:s)ans+=i.size();
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 4208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		if(s.contains("7")) {
			
			System.out.println("Yes");
			
		}else {
			
			System.out.println("No");
			
		}
		
		sc.close();
		
	}
	
}

Measured memory_bytes: 35644
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'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'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi a(N);rep(i,N)cin>>a[i];
  int nf=0,odd=0;
  rep(i,N){
    if(a[i]%4==0)nf++;
    else if(a[i]%2==1)odd++;
  }
  if(nf>=odd)cout<<"Yes"<<endl;
  else if(nf+odd==N&&odd ==nf+1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}







Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll H, W, M;
    scanf("%lld", &H);
    scanf("%lld", &W);
    scanf("%lld", &M);

    map<ll, ll> lineTargets, rowTargets;
    map<pair<ll, ll>, bool> targetMap;
    for (ll i = 0; i < M; i++)
    {
        ll h, w;
        scanf("%lld", &h);
        scanf("%lld", &w);
        h--;
        w--;
        lineTargets[h]++;
        rowTargets[w]++;
        targetMap[{h, w}] = true;
    }

    vector<pair<ll, ll>> lineVector(lineTargets.begin(), lineTargets.end());
    vector<pair<ll, ll>> rowVector(rowTargets.begin(), rowTargets.end());
    sort(lineVector.begin(), lineVector.end(), [](auto const &lhs, auto const &rhs) { return lhs.second > rhs.second; });
    sort(rowVector.begin(), rowVector.end(), [](auto const &lhs, auto const &rhs) { return lhs.second > rhs.second; });
    auto line = *lineVector.begin();
    auto row = *rowVector.begin();
    bool isNone = false;
    for (auto &&i : lineVector)
    {
        if (i.second < line.second)
            break;
        for (auto &&j : rowVector)
        {
            if (j.second < row.second)
                break;

            if (!targetMap[{i.first, j.first}])
            {
                isNone = true;
                break;
            }
        }
    }

    ll ans = line.second + row.second - (isNone ? 0 : 1);
    printf("%lld\n", ans);
}


Measured memory_bytes: 87628
// created on : Sun Jun 21 2020
 
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        long n = in.nextLong();
        StringBuilder sb = new StringBuilder();
        while(n > 0){
            long mod = (n - 1) % 26;
            sb.append((char) (mod + 97));
            if(n % 26 == 0){
                n = n/26 - 1;
            }
            else{
                n = n / 26;
            }
        }
        println(sb.reverse().toString());
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void displayRuntime(long startTime){
        long stopTime = System.currentTimeMillis();
        long elapsedTime = stopTime - startTime;
        System.out.println("Runtime: " + elapsedTime / 1000D);
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


Measured memory_bytes: 25424
#include<iostream>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int main(){
	for(int n;cin>>n,n;){
		int g[26][26]={};
		bool tc[26][26]={},use[26]={};
		rep(i,n){
			string s;	cin>>s;
			int u=s[0]-'a',v=s[s.length()-1]-'a';
			g[u][v]++;
			tc[u][v]=true;
			use[u]=use[v]=true;
		}

		bool ok=true;
		rep(u,26){
			int indeg=0,outdeg=0;
			rep(v,26)	indeg+=g[v][u],outdeg+=g[u][v];
			if(indeg!=outdeg){ ok=false; break; }
		}

		rep(k,26)rep(i,26)rep(j,26)	tc[i][j]=tc[i][j]||(tc[i][k]&&tc[k][j]);

		rep(u,26){
			if(use[u]){
				rep(v,26)	if(use[v] && !tc[u][v]){ ok=false; break; }
				if(!ok)	break;
			}
		}
		cout<<(ok?"OK":"NG")<<endl;
	}

	return 0;
}

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


def solve(H: int, A: int):
    ans = 0
    if H % A == 0:
        ans = H // A
    else:
        ans = H // A + 1
    print(ans)
    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()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int> a;
	string s,t;
	cin>>s>>t;
	cin>>a[s]>>a[t];
	string u;
	cin>>u;
	a[u]--;
	cout<<a[s]<<" "<<a[t];
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> v;
  for(int i = 1; i<=9; i++){
     for(int j = 1; j<=9; j++){
              int a = i*j;
              v.push_back(a);
           }
       }
  for(int i = 0; i<=100;i++){
       if(v[i]==n) {
        cout << "Yes" << endl;
       return 0;
      }
   }
   cout << "No" <<endl;
   return 0;
}

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

int main(){
 long long int N,K,x;
 cin >> N >> K;
 x = N;
 long long int min = 1000000000000000000;
 if(x % K < (K - x % K)){ cout << x % K; }
 else cout << K - x % K;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
given a 2d grid, find total path from (0, 0) to (h-1, w-1)

...#
.#..
....

3

..
..

dp
dp[i][j] = dp[i-1][j] + dp[i][j-1] if they are not walls
*/
using ll = long long; 
int add(int a, int b) {
    int MOD = 1e9 + 7;
    return (a + b) % MOD;
}
int main() {
    int H;
    int W;
    scanf("%d%d\n", &H, &W);
    vector<vector<int>> dp(H, vector<int>(W));
    vector<vector<bool>> is_wall(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        scanf("\n");
        for (int j = 0; j < W; j++) {
            char ch;
            scanf("%c", &ch);
            //cout << i << " " << j << " " << ch << endl;
            if (ch == '#') {
                is_wall[i][j] = true;
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            //cout << i << " " << j << " " << is_wall[i][j] << endl;
            if (!is_wall[i][j]) {
                if (i - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i-1][j]);
                }
                if (j - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i][j-1]);
                }    
            }
        }
    }    
	printf("%d\n", dp[H-1][W-1]);
	return 0;
}



Measured memory_bytes: 6272
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int a[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b;
    for(int k = 0; k < n; k++){
        cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(b == a[i][j]) a[i][j] = -1;
            }
        }
    }
    int tot;
    for(int i = 0; i < 3; i++){
        tot = 0;
        for(int j = 0; j < 3; j++){
            tot += a[i][j];    
        }
        if(tot == -3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int i = 0; i < 3; i++){
        tot = 0;
        for(int j = 0; j < 3; j++){
            tot += a[j][i];    
        }
        if(tot == -3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(a[0][0] + a[1][1] + a[2][2] == -3){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2] + a[1][1] + a[2][0] == -3){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  bool ok=0;
  cin >> x >> y;
  if(4*x<y||y<2*x) {cout << "No"; return 0;}
  if(y%2!=0){ok=0;}
  for(int i=0;i<=x;i++){
    if((i*2)+4*(x-i)==y) {ok=1;} 
  }
  if(ok==1){cout << "Yes";}
  else cout << "No";
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[10010][2][110];
string K;
int D;

int main() {
    cin >> K >> D;
    int klen = K.length();
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for(int i = 0; i < klen; ++i) {
        int limit = K.at(i) - '0';
        for(int j = 0; j < 2; ++j) {
            for(int k = 0; k < D; ++k) {
                for(int d = 0; d <= (j ? 9 : limit); ++d) {
                    dp[i+1][j || (d<limit)][(k+d)%D] += dp[i][j][k];
                }
            }
        }
    }

    mint ans = dp[klen][0][0] + dp[klen][1][0];
    ans -= (mint)1;
    cout << ans << endl;
}

Measured memory_bytes: 20872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll a, b, c;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << "-1" << endl;
    }else{
        cout << a * b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=(ll)1e16+7;
int n;
ll f[5002];
struct po{
	int h,p;
	bool operator <(const po &rsh)const
	{
		return h+p<rsh.h+rsh.p;
	}
}a[5001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].h>>a[i].p;
		f[i]=inf;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=n;j>=1;j--)
			if(f[j-1]<=a[i].h) f[j]=min(f[j-1]+a[i].p,f[j]);
	for(;n;n--) if(f[n]!=inf) break;
	cout<<n<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


int main(){
    int n, m , q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> vec(n+m-1, 1);
    rep(i, m-1) vec[i] = 0;
    int ans = 0;
    do{
        int zero_cnt = 1;
        int tmp = 0;
        vector<int> A;
        rep(i, n+m-1){
            if(vec[i] == 0)zero_cnt++;
            else A.push_back(zero_cnt);
        }
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
        }
        ans = max(ans, tmp);
    }while(next_permutation(vec.begin(), vec.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  long ans=1;
  for(int i=0;i<n;i++){
  ans*=(i+1);
    ans%=1000000007;
  }System.out.println(ans);
}
}


Measured memory_bytes: 23636
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int kai = 2;
        int conut = 0;
        if(N == 1){
            System.out.println(1);
            System.exit(0);
        }
        for(int i = 0; i < N ; i++){
            kai = kai * 2;
            if(kai > N){
                kai = kai / 2;
                break;
            }
        }
        System.out.println(kai);
    }
}

Measured memory_bytes: 23252
# include <iostream>
using namespace std;
int main(void)
{
	int n,ans = -1e9-1,minn,x;
	scanf("%d %d",&n,&minn);
	for(int i = 1;i < n;i++)
	{
		scanf("%d",&x);
		ans = max(ans,x-minn);
		minn = min(x,minn);
	}
	printf("%d\n",ans);
	return 0;
} 


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<int> X(N), Y(N), P(N);
    for(int i = 0; i < N; ++i)  cin >> X[i] >> Y[i] >> P[i];
    vector<vector<ll>> cost_x(N, vector<ll>(1 << N)), cost_y(N, vector<ll>(1 << N));
    for(int i = 0; i < N; ++i){
        for(int mask = 0; mask < (1 << N); ++mask){
            cost_x[i][mask] = abs(X[i]), cost_y[i][mask] = abs(Y[i]);
            for(int j = 0; j < N; ++j){
                if(mask >> j & 1){
                    chmin(cost_x[i][mask], (ll)abs(X[i] - X[j]));
                    chmin(cost_y[i][mask], (ll)abs(Y[i] - Y[j]));
                }
            }
            cost_x[i][mask] *= P[i], cost_y[i][mask] *= P[i];
        }
    }
    vector<ll> ans(N + 1, 1e+17);
    ans[0] = 0;
    for(int i = 0; i < N; ++i)  ans[0] += min(cost_x[i][0], cost_y[i][0]);
    auto dfs = [&](auto&& self, int cur = 0, int count = 0, int mask_x = 0, int mask_y = 0) -> void {
        if(cur == N)    return;
        ll total = 0;
        int nxt_mask = mask_x | (1 << cur);
        for(int i = 0; i < N; ++i){
            total += min(cost_x[i][nxt_mask], cost_y[i][mask_y]);
        }
        chmin(ans[count + 1], total);
        self(self, cur + 1, count + 1, nxt_mask, mask_y);
        total = 0;
        nxt_mask = mask_y | (1 << cur);
        for(int i = 0; i < N; ++i){
            total += min(cost_x[i][mask_x], cost_y[i][nxt_mask]);
        }
        chmin(ans[count + 1], total);
        self(self, cur + 1, count + 1, mask_x, nxt_mask);
        self(self, cur + 1, count, mask_x, mask_y);
    };
    dfs(dfs);
    for(int i = 0; i <= N; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 11216
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a=0,sum=0;
  cin >> N;
  long mod = 1000000007;
  vector<string> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  string s;
  cin >> s;

  for (int i = 0; i < N; i++) {
    if(a==1) sum+=B.at(i);
    if(A.at(i)==s) a=1; 
  }
  
  cout << sum << endl;
  //cout << (113 ^ 115) << endl;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			// result[i]はiを割って余りがk以上の数字の数
			long[] result = new long[n + 1];
			Arrays.fill(result, 0L);
			IntStream.rangeClosed(k + 1, n)
					.forEach(i -> result[i] = (n / i) * (i - k) + Math.max((n % i) - Math.max(k - 1, 0), 0));
			System.out.println(Arrays.stream(result).sum());
		}
	}
}


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

#define ll long long 
#define int ll

int32_t main() {
    int n, m; cin >> n >> m;
    
    int even = (n * (n - 1)) / 2;
    if (even < 0) {
        even = 0;
    }
    
    int odd = (m * (m - 1)) / 2;
    if (odd < 0) {
        odd = 0;
    }
    
    cout << even + odd << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int mod = 924844033;
long long int dp[4003][2002][2];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int num, kai;
	cin >> num >> kai;
	dp[0][0][0] = 1;
	int pt = 0;
	for (int i = 0; i < kai * 2; i++){
		int t = 0;
		int nx, ny;
		if (i < kai)nx = i, ny = i + kai;
		else nx = i, ny = i - kai;
		while(true){
			if (nx >= num || ny >= num){
				break;
			}
			t++;
			if (nx < ny){
				nx += kai * 2;
			}else{
				ny += kai * 2;
			}
		}
		for (int j = 0; j < t; j++){
			for (int k = 0; k <= num; k++){
				dp[pt + 1][k][0] += dp[pt][k][0] + dp[pt][k][1];
				dp[pt + 1][k + 1][1] += dp[pt][k][0];
				dp[pt + 1][k][0] %= mod;
				dp[pt + 1][k + 1][1] %= mod;
			}
			pt++;
		}
		for (int k = 0; k <= num; k++){
			dp[pt][k][0] += dp[pt][k][1];
			dp[pt][k][0] %= mod;
			dp[pt][k][1] = 0;
		}
	}
	long long int ans = 0;
	long long int now = 1;
	for (int i = num; i >= 0; i--){
		if (i % 2 == 0){
			ans += dp[pt][i][0] * now;
		}else{
			ans += mod - dp[pt][i][0] * now % mod;
		}
		ans %= mod;
		now *= (num - i + 1);
		now %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 128580